centos7 搭建vnc
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 |
要关闭服务器上的防火墙。
4. 使用VNCViewer客户端连接到VNC服务
IP:端口或是IP: displayNumber
转:https://www.cnblogs.com/rusking/p/6023170.html