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

posted on 2016-11-02 15:49  遠離塵世の方舟  阅读(3447)  评论(0编辑  收藏  举报

导航