二、安装vnc服务端

1. 安装vnc服务端;
[root@Centos1 ~]# yum -y install vnc *vnc-server*
2. 修改vnc主配置文件;
[root@Centos1 ~]# vim /etc/sysconfig/vncservers
====================================================================
# VNCSERVERS="2:myusername"                                       ||
# VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -localhost"   ||
-----------------将如上两行改为如下配置------------------------------ ||
VNCSERVERS="2:user2 3:user3"                                      ||
VNCSERVERARGS[2]="-geometry 800x600 -alwaysshared"                ||
VNCSERVERARGS[3]="-geometry 800x600 -alwaysshared"                ||
====================================================================
3. 设置VNCserver远程连接密码;
[root@Centos1 ~]# vncserver
4. 修改vnc桌面配置文件. vnc连接密码设置完后会在root目录下生产一个.vnc目录;
[root@Centos1 ~]# vim /root/.vnc/xstartup
=======================================
# twm &                               ||
----将如上改为如下----------------------||
gnome &                               ||
=======================================
5. 关闭iptables/selinux防火墙;
[root@Centos1 ~]# iptables -F
[root@Centos1 ~]# iptables -X
[root@Centos1 ~]# service iptables stop
[root@Centos1 ~]# vim /etc/sysconfig/selinux
============================
SELINUX=enforcing         ||
---将如上改为如下-----------||
SELINUX=disabled         ||
===========================
6. 为用户设置vnc连接密码;
[root@Centos1 ~]# su - user2
[user2@Centos1 ~]$ vncpasswd
7. 重启vnc服务端,让配置文件生效;
[root@Centos1 ~]#service vncserver restart
8. 停止vnc窗口;
[root@Centos1 ~]#  vncserver -kill:2

二、客户端连接

[root@Centos1 ~]# vncserver :2