TigerVNC使用非加密的鏈接,默認會被firewalld blocked 掉,想要 vnc正常工作就需要讓firewalld開放相應的端口才行。
vnc默認的端口號為5900,而每個vnc window的端口號是: 5900+window_number(or,display_number)
如:systemctl start vncserver-username@:2.service 那么這個vnc window的端口號就是 5902
1. Installing VNC Server
~]# yum install tigervnc-server
2. Configuring VNC Server
~#cp /usr/lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service |
2.1 修改配置文件vncserver@:1.service,把USER修改為root
[Service] |
2.2 To make the changes take effect immediately, issue the following command:
~]#
systemctl daemon-reload
2.3 Set the password for the user or users defined in the configuration file.
~]$ vncpasswd Password: Verify: |
3. Starting VNC Server
~]#
systemctl start vncserver@:1.service
查看端口監聽狀態:
[root@rusky system]# netstat -an | grep 5901 |
要關閉服務器上的防火牆。
4. 使用VNCViewer客戶端連接到VNC服務
IP:端口或是IP: displayNumber
或是使用IP:displayNumber來連接
點擊Connect,密碼為2.3設置的密碼。
二、Configuring VNC Server for Two or more Users
配置多個用戶來連接到VNC服務器:
1. 復制一份配置文件:vncserver@:2.service
~]# cp vncserver@:1.service vncserver@:2.service
2. 修改配置文件:把Home修改為對應的Username:
[Service] [Install] |
3. 切換到rusky用戶,並設置vnc密碼
[root@rusky ~]# su - rusky |
4. 切換回root賬號,啟動vncserver@:2.service服務
~]# systemctl start vncserver@:2.service
[root@rusky ~]# netstat -an |grep 590* |
之后,可使用IP:2或IP:5902進行連接