一、實驗環(huán)境
操作系統(tǒng):CentOS7.3 桌面版
用戶: 管理員root痹筛、普通用戶Michael
二、安裝 VNC server
# yum ?-y install epel-release
# ??yum ?-y?install tigervnc-server
三帚稠、配置?
VNC server
# cp /lib/systemd/system/vncserver@.service ? ?/etc/systemd/system/vncserver@:1.service
# cp /lib/systemd/system/vncserver@.service ? ?/etc/systemd/system/vncserver@:2.service
# vim ?/etc/systemd/system/vncserver@:1.service
#####################################################
[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target
[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 || :'
[Install]
WantedBy=multi-user.target
######################################################
# vim ?/etc/systemd/system/vncserver@:2.service
#####################################################
[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target
[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?Michael?-c "/usr/bin/vncserver %i"
PIDFile=/home/Michael/.vnc/%H%i.pid
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
[Install]
WantedBy=multi-user.target
#####################################################
四、設(shè)置密碼
# vncserver
# su - Michael
$ vncserver
.
注:設(shè)置和修改密碼,需切換到相應(yīng)用戶杆麸,第一次設(shè)置密碼用 vncserver浪感,以后如果需要修改密碼影兽,用 vncpasswd
五莱革、 啟動服務(wù)
# systemctl daemon-reload
# systemctl enable vncserver@:1.service
# systemctl enable vncserver@:2.service
# systemctl start ? vncserver@:1.service
# systemctl start ? vncserver@:2.service
# systemctl status ? ?vncserver@:1.service
# systemctl status ? ?vncserver@:2.service
六盅视、設(shè)置防火墻
# systemctl start firewalld
# systemctl enable firewalld
# firewall-cmd --permanent --add-service vnc-server
# firewall-cmd --reload
七、安裝VNC客戶端
Windows上使用VNC Viewer連接遠程CentOS服務(wù)器
https://www.realvnc.com/en/connect/download/vnc/windows
八拇砰、參考
怎樣在 CentOS 7.0 上安裝和配置 VNC 服務(wù)器
https://linux.cn/article-5335-1.html
Download and Install VNC Viewer on Windows
https://www.realvnc.com/en/connect/download/viewer/windows
How to Install and Configure VNC Server in CentOS 7 / RHEL 7
https://www.itzgeek.com/how-tos/linux/centos-how-tos/configure-vnc-server-on-centos-7-rhel-7.html
How To Install and Configure VNC Remote Access for the GNOME Desktop on CentOS 7
How To Set Up SSH Tunneling on a VPS
https://www.digitalocean.com/community/tutorials/how-to-set-up-ssh-tunneling-on-a-vps