如果你的centos系统压根就没装CDE、Gnome等桌面,那你先执行这条命令,把GUI环境装上,no GUI no VNC
yum -y groupinstall 'GNOME Desktop Environment' #Centos 5.x
yum -y groupinstall 'Desktop' #Centos 6.x
1.下载VNCserver
yum install -y tigervnc tigervnc-server
2.配置VNCserver
vi /etc/sysconfig/vncservers
VNCSERVERS="2:root"
VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -localhost"
注:这里的root就是连接的用户名了,如果你还禁止root登录就改成你现在的登录用户名吧!
3.设置VNC连接密码,[注意这个密码仅是VNC连接的密码,跟系统用户密码没关系]
[root@localhost ~]# vncpasswd
Password:
Verify:
4.调整xstartup脚本
vncserver &
vi /root/.vnc/xstartup
我这里只需要
#twm &
gnome-session &
其他两处都未做修改
5.重启VNC服务
service vncserver restart
6.在客户端使用vncviewer软件 以 “ip:1”的形式连接,输入密码后进入到vncserver中。