服務端環境:CentOS 6.7
客戶端環境:Windows 7
1.服務器安裝VNC服務端
可以直接rpm安裝vnc的服務端:rpm -ivh tigervnc-server-1.1.0-16.el6.x86_64.rpm
如果rpm安裝時發現有依賴,建議直接使用yum安裝,輕松解決依賴問題:
yum install tigervnc-server
如果系統安裝時並沒有安裝桌面選項,那么就還需要用yum安裝一下桌面:
yum groupinstall "X Window System" "Desktop"
2.編輯vnc配置文件
編輯/etc/sysconfig/vncservers, 添加以下內容:VNCSERVERS="1:root"
VNCSERVERARGS[1]="-geometry 800x600 -alwaysshared -depth 24"
注:分辨率可以根據實際情況調整,分辨率不合適可能導致vnc連接顯示黑屏的現象。
3.設定VNC的密碼
vncserver 第一次輸入提示需要設定VNC的密碼:[root@JY-DB ~]# vncserver
You will require a password to access your desktops.
Password:
Verify:
xauth: creating new authority file /root/.Xauthority
New 'JY-DB:1 (root)' desktop is JY-DB:1
Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/JY-DB:1.log
[root@JY-DB ~]#
后期若想修改vnc用戶密碼,可使用vncpasswd命令修改
[root@JY-DB ~]# vncpasswd
Password:
Verify:
4.查看vnc的會話信息
重啟vncserver服務:/etc/init.d/vncserver restart
查看vnc的會話信息:
vncserver -list
5.客戶端測試vnc連接
客戶端是vncviewer,我這里是Windows系統,下載對應的vnc安裝包HA-vnc-4.0-x86_win32-KC.exe 安裝選擇只安裝VNC Viewer即可。輸入192.168.56.102:1,

確定之后,提示輸入密碼,這里的密碼是指vnc的密碼,

確定后,即可通過vnc連接到服務端的桌面環境了。

注:這里的"192.168.56.102"是服務端的IP地址,而":1"對應的是VNCSERVERS的配置,這里就是root用戶。
個人認為VNC的最大優勢是:網絡突然斷開,也不會影響之前正在做的操作。
