簡介:
VNC (Virtual Network Computer)是虛擬網絡計算機的縮寫。
VNC 是一款優秀的遠程控制工具軟件,VNC 是在基於 UNIX 和 Linux 操作系統的免費的開源軟件,遠程控制能力強大,高效實用,其性能可以和 Windows 和 MAC 中的任何遠程控制軟件媲美。
一、檢查系統有沒有安裝 VNC
shell > rpm -qa | grep -i vnc shell > ## 空的,NEXT
二、使用 YUM 安裝 VNC
shell > yum -y install tigervnc tigervnc-server shell > rpm -qa | grep -i vnc ## 安裝成功 tigervnc-1.1.0-8.el6_5.x86_64 tigervnc-server-1.1.0-8.el6_5.x86_64
三、配置、啟動 VNC
shell > vim /etc/sysconfig/vncservers 21 VNCSERVERS="1:root 2:wang" ## 配置遠程桌面登陸的用戶名,1/2 為用戶序號,用戶間要有空格 22 VNCSERVERARGS[1]="-geometry 1024x768" ## [1] 為用戶序號;指定分辨率為 1024x768 23 VNCSERVERARGS[2]="-geometry 1024x768" 多用戶分別指定 shell > vncserver :1 ## 為序號為 1 的用戶啟動 VNC You will require a password to access your desktops. Password: ## 啟動必須為該用戶設置 VNC 密碼(vncpasswd 專門用於設置VNC密碼) Verify: 可惜我使用這個命令卻沒成功,不知道為什么 xauth: creating new authority file /root/.Xauthority New 'localhost:1 (root)' desktop is localhost:1 Creating default startup script /root/.vnc/xstartup Starting applications specified in /root/.vnc/xstartup Log file is /root/.vnc/localhost:1.log shell > netstat -anpt | grep vnc tcp 0 0 0.0.0.0:5901 0.0.0.0:* LISTEN 1895/Xvnc tcp 0 0 0.0.0.0:6001 0.0.0.0:* LISTEN 1895/Xvnc tcp 0 0 :::6001 :::* LISTEN 1895/Xvnc
## 序號為 1 的VNC用戶 root 監聽的端口為 5901 ,多個用戶以依次為 5902 、5903 ……( 規則為 5900+用戶序號 )
shell > su - wang ## 必須切過去 [wang@localhost ~]$ vncserver :2 ## 為序號為 1 的用戶啟動 VNC、設置密碼 You will require a password to access your desktops. Password: Verify: xauth: creating new authority file /home/wang/.Xauthority New 'localhost:2 (wang)' desktop is localhost:2 Creating default startup script /home/wang/.vnc/xstartup Starting applications specified in /home/wang/.vnc/xstartup Log file is /home/wang/.vnc/localhost:2.log [wang@localhost ~]$ netstat -anpt | grep vnc (Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.) tcp 0 0 0.0.0.0:5902 0.0.0.0:* LISTEN 2304/Xvnc tcp 0 0 0.0.0.0:6002 0.0.0.0:* LISTEN 2304/Xvnc tcp 0 0 :::6002 :::* LISTEN 2304/Xvnc
## 序號為 2 的VNC用戶 wang 所監聽的端口為 5902
[wang@localhost ~]$ exit ## vncserver :1 或 :2 啟動某個用戶的 VNC(如不是當前用戶需 su - 到這個用戶) vncserver -kill :1 或 :2 關閉某個用戶的 VNC(如不是當前用戶需 su - 到這個用戶) vncserver -list 查看當前登陸用戶有沒有開啟 VNC (如不是當前用戶需 su - 到這個用戶) service vncserver start|stop|restart 開啟、關閉服務(所有用戶的 VNC) shell > chkconfig --add vncserver ## VNC 加入開機啟動 shell > chkconfig --level 35 vncserver on
四、防火牆允許 VNC 通過
shell > vim /etc/sysconfig/iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 5901 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 5902 -j ACCEPT
## 也可以使用 iptables 命令添加,如果你只開一個 VNC 則只允許 5901 即可
shell > service iptables restart ## 重啟防火牆使規則生效
五、Windows 客戶端測試
VNC Viewer for Windows 下載地址 http://www.realvnc.com/download/binary/1613/
客戶端 VNC Server: 處輸入 IP:1 、IP:2 如 :192.168.1.80:1 等 然后輸入該用戶 VNC 密碼
