1. 安裝軟件(使用root賬號)
# yum install tigervnc-server
2. 配置VNC用戶密碼
[root@localhost ~]# su - michael
Last login: Wed Jan 9 13:52:12 CST 2019 on pts/2
[michael@localhost ~]$ vncpasswd
Password:
Verify:
3. 配置並啓動VNC Service
按照/lib/systemd/system/[email protected]中的:
# Quick HowTo:
# 1. Copy this file to /etc/systemd/system/vncserver@:1.service
# 2. Edit /etc/systemd/system/[email protected], replacing <USER>
# with the actual user name. Leave the remaining lines of the file unmodified
# (ExecStart=/usr/sbin/runuser -l <USER> -c "/usr/bin/vncserver %i"
# PIDFile=/home/<USER>/.vnc/%H%i.pid)
# 3. Run `systemctl daemon-reload`
# 4. Run `systemctl enable vncserver@:<display>.service`
4. 配置防火牆(注意每個使用的端口都要配置)
# iptables -I INPUT -m state --state NEW -p tcp --destination-port 5901 -j ACCEPT
# iptables -I INPUT -m state --state NEW -p tcp --destination-port 5902 -j ACCEPT
# service iptables save
5. 完成,現在應該可以通過客戶端連接了。