centos7 VNC installation

root user:

yum install tigervnc-server
cp /lib/systemd/system/[email protected] /etc/systemd/system/vncserver@:1.service
vim /etc/systemd/system/vncserver@:1.service
sudo systemctl enable vncserver@:1.service
vncpasswd ## The connection password needs to be changed for the first startup
systemctl start vncserver@:1.service
vim /etc/sysconfig/iptables
systemctl restart iptables
The content of vncserver@:1 .service is as follows:
[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target

[Service]
Type=simple
# 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

Here the number 1 represents the root user, and the port corresponds to 5901. After starting VNC, you need to check whether the firewall allows access. Many services cannot be accessed because the firewall blocks them.

If there is a new user, you can copy the vncserver@:1.service file and name it as vncserver@:56.service, and then change the root in the file to the user name accordingly. The port when connecting is 5956

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324845840&siteId=291194637