精簡版
yum install tigervnc tigervnc-server -y
chkconfig vncserver on
vncpasswd
vncserver
#多個用戶都到相應用戶下生成文件
vi /root/.vnc/xstartup
把最後的 twm & 刪掉 加上 gnome-session &
vi /etc/sysconfig/vncservers
VNCSERVERS="1:root 2:drudy"
#有幾個用戶能夠直接在後面加
#VNCSERVERARGS[1]="-geometry 1024x768 -nolisten tcp -nohttpd "
/etc/init.d/vncserver start
service iptables stop
Centos 6.4 開啓 VNC
1、查看是否安裝 VNC
好像 6.0 之後 VNC 名字 由 vnc 改爲 tigervnc
[root@xen ~]# rpm -qa|grep tigervnc
tigervnc-1.0.90-0.17.20110314svn4359.el6.x86_64
tigervnc-server-1.0.90-0.17.20110314svn4359.el6.x86_64
若是沒有就安裝下了
[root@xen ~]# yum install tigervnc tigervnc-server -y
添加啓動項
[root@xen ~]# chkconfig --add vncserver
[root@xen ~]# chkconfig vncserver on
2、設置 VNC 密碼
[root@xen ~]# vncserver
Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/xen:1.log
會在當前用戶主目錄下 生成 .vnc 目錄和配置文件
[root@xen ~]# vncpasswd
Password:
Verify:
設置的密碼保存在 /root/.vnc/passwd
3、 VNC 配置 xstartup ,vncservers
修改 xstartup 文件 把最後的 twm & 刪掉 加上 gnome-session &
編輯 /root/.vnc/xstartup ,
vi /root/.vnc/xstartup
若是直接 啓動
[root@xen .vnc]# /etc/init.d/vncserver start
正在啓動 VNC 服務器: no displays configured [ 失敗 ]
因此要修改 /etc/sysconfig/vncservers 文件添加如下內容
vi /etc/sysconfig/vncservers
將最後兩行配置信息取消註釋,添加系統帳號
VNCSERVERS="1:root 2:admin"
VNCSERVERARGS[1]="-geometry 1024x768 -nolisten tcp -nohttpd "
VNCSERVERARGS[2]="-geometry 1024x768 -nolisten tcp -nohttpd "
VNCSERVERS 是用來設定可使用VNC的服務器帳號,能夠設定多個,例如上面root、admin,可是中間要用空格隔開。使用VNCVIEWER登陸時,192.168.48.128:1表示是以root帳號登陸,以此類推。
關於參數配置說明:
1:-geometry 表示桌面分辨率,默認爲1024x768,因此上面的1024x768也能夠不寫。
2:-nohttpd 表示不監聽HTTP端口(58xx)。
3:-nolisten tcp 表示不監聽TCP端口(60xx)
4:-localhost 只運行從本機訪問。
5:AlwaysShared 默認只容許一個VNCVIEWER鏈接,此參數表示同一個顯示端口容許多用戶同時登陸.
6:-depth 表示色深,參數有8,16,24,32.
7: SecurityTypes None 登陸不須要密碼認證VncAuth默認值,要密碼認證。
啓動 vncserver
[root@xen ~]# /etc/init.d/vncserver start
正在啓動 VNC 服務器: 2:root xauth: (stdin):1: bad display name "xen:2" in "add" command
New 'xen:2 (root)' desktop is xen:2
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/xen:2.log
[ 肯定 ]
4、 VNC 鏈接
防火牆處理
iptables -t filter -A INPUT -s xxx.xxx.xxx.0/24 -j ACCEPT
iptables -t filter -A OUTPUT -d xxx.xxx.xxx.0/24 -j ACCEPT
192.168.0.132
:5902
關閉服務器上本身的vnc鏈接
vncserver -kill :桌面號
例如:關閉上面的vnc鏈接
vncserver -kill :1