Background
Linux cloud servers typically connect via SSH and use key pairs for secure passwordless access. However, SSH connections are generally character interfaces, and sometimes we need to use a graphical interface for some complex operations.
VNC Viewer is a free and open source remote control software that can realize batch management, remote monitoring, and batch opening of links. Operating one is equivalent to operating N sets at the same time, which is easy to use.
Preparation
1. An ECS running CentOS 7.6 has been created, and an EIP has been bound to the cloud server to ensure that it can connect to the Internet. For details, see Elastic Cloud Server - Creating an Elastic Cloud Server.
2. VNC Viewer client has been installed on the local PC.
VNC Viewer download address: https://www.realvnc.com/en/connect/download/viewer/
Install gnome desktop environment for CentOS 7.6 cloud server
1. Log in to the cloud server remotely using SSH tool or console. Account: root; password: the password you set when creating the cloud server.
2. Execute the following command to install the GUI.
yum groupinstall "GNOME Desktop" "Graphical Administration Tools" -y
1. Execute the following command to set the default startup GUI.
ln -sf /lib/systemd/system/runlevel5.target /etc/systemd/system/default.targ
1. Execute the following command to restart the cloud server.
reboot
1. Login to the cloud server via eSurfing Cloud console remote login method, for details, see Log in to a Linux ECS instance.
After logging into the cloud server, you can view the visual interface, which indicates that the setup is successful. Follow the prompts to configure and enter the desktop, where you can perform relevant operations as needed. As shown in the figure:
Install VNC Server to implement local remote graphical access
1. Execute the following command to install vncserver.
yum install -y tigervnc-server
1. Configure vncserver to execute vncsever command to configure vnc password (you need to enter the password twice when starting for the first time).
vncserver
You will require a password to access your desktop.
Password: (enter and remember the password)
Verify: (re-enter and remember the password)
Execute the following command to generate and edit the configuration file.
cp -p /lib/systemd/system/vncserver@.service /lib/systemd/system/vncserver@:1.service
Execute the following command to modify the configuration:
vim /lib/systemd/system/vncserver@:1.service
Press Esc to exit Edit mode, then type :wq to save and exit.
1. Run the following command to restart systemd.
systemctl daemon-reload
1. Configure to start at boot.
systemctl enable vncserver@:1.service
1. Run the following command to start VNC Server.
systemctl start vncserver@:1.service
1. Run the command ps - ef | grep vnc to confirm if the service has started. If a result similar to the following is returned, the service has started.
Change security group rules
1. Log in to the ECS Management Console.
2. Click the name of the ECS to go to the details page.
3. On the Security Group tab, click Change Security Group Rules to release port 5901.
![]()
Connect the (CentOS7.6) instance using the viewer client connection software.
1. Connect the instance using the viewer client connection software provided in the preparation. Click file --- New connection to create a new connection.
1. Enter the appropriate information.
1. Double-click the previously created connection and click to connect.
1. Enter the password set when installing VNC Server.
1. The connection is successful.