In this article, we will have explained the necessary steps to install and configure VNC Server on CentOS 8. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.
VNC (Virtual Network Computing) is a Server-client protocol, which allows user accounts to connect and control a remote platform supplied by the Graphical User Interface.
Install VNC Server on CentOS
Step 1. The first command will update the package lists to ensure you get the latest version and dependencies.
Step 2. Install VNC Server on CentOS 8.
Install VNC server by running the commands below:
Step 3. Configure VNC Server.
Once the installation completes, create the user account for VNC logins:
Then, create a per user VNC systemd configuration file under, /etc/systemd/system/ directory:
Add the following lines:
ExecStartPre=/bin/sh-c'/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
Restrict connection to the VNC server only through localhost (Loopback) interface by adding the keyword, -localhost to the ExecStart line:
Reload systemd system initialization program to pick up the new vnc configuration file:
Next, create the VNC password for the user whose VNC display has been configured. The password can set using the vncpasswd command.
Next, create the VNC password. When prompted to set the read-only password, you can choose to not to set it
The VNC passwords are stored under $HOME/.vnc/passwd.
VNC server can be run as a normal systemd service. However, to run it, you need to assign a display number to the service:
Step 5. Set the Firewall Rule if firewall is enabled on your Linux server.
In case just one instance of VNC server is started, you only need to open the first allocated VNC port: 5901/TCP by issuing the below commands to apply the firewall configuration at runtime:
Step 6. Connecting to CentOS Desktop via VNC Client.
In this example we’ll be using TigerVNC. Open your VNC viewer, enter localhost:5901 and click on the Connect button.
Congratulation, you have learned how to install and configure VNC server on CentOS 8. If you have any question, please leave a comment below.