RHEL7安裝配置TigerVNC


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]
Type=forking
# Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
ExecStart=/usr/sbin/runuser -l root -c "/usr/bin/vncserver %i"
PIDFile=/root/.vnc/%H%i.pid
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'

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
tcp        0      0 0.0.0.0:5901            0.0.0.0:*               LISTEN    
tcp6       0      0 :::5901                 :::*                    LISTEN

要關閉服務器上的防火牆。

4. 使用VNCViewer客戶端連接到VNC服務

IP:端口或是IP: displayNumber

image
或是使用IP:displayNumber來連接
image
點擊Connect,密碼為2.3設置的密碼。
image

二、Configuring VNC Server for Two or more Users

配置多個用戶來連接到VNC服務器:

Technorati Tags: linux

1. 復制一份配置文件:vncserver@:2.service

~]# cp vncserver@:1.service vncserver@:2.service

2. 修改配置文件:把Home修改為對應的Username:

[Service]
Type=forking
# Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
ExecStart=/usr/sbin/runuser -l rusky -c "/usr/bin/vncserver %i"
PIDFile=/home/rusky/.vnc/%H%i.pid
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'

[Install]

3.  切換到rusky用戶,並設置vnc密碼

[root@rusky ~]# su - rusky
Last login: Wed Nov  2 12:01:47 CST 2016 on pts/0
[rusky@rusky ~]$ vncpasswd
Password:
Verify:

4. 切換回root賬號,啟動vncserver@:2.service服務  

~]# systemctl start vncserver@:2.service

[root@rusky ~]# netstat -an |grep 590*
tcp        0      0 0.0.0.0:5901            0.0.0.0:*               LISTEN    
tcp        0      0 0.0.0.0:5902            0.0.0.0:*               LISTEN    
tcp        0      0 192.168.1.202:5901      192.168.1.100:42832     ESTABLISHED
tcp6       0      0 :::5901                 :::*                    LISTEN    
tcp6       0      0 :::5902                 :::*                    LISTEN    

之后,可使用IP:2或IP:5902進行連接

image

Black SheepSchool busBlack Sheep


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM