VNC or Virtual Network Computing is a computer technology that allows you to share your desktop remotely. VNC technology works as a client/server model and uses the RFP (Remote FrameBuffer) protocol to transmit keyboard and mouse events from the VNC client to the VNC server.
In this tutorial we will show you how to install the VNC server on CentOS 8 Server. We use TigerVNC as the VNC server and Gnome Desktop for the graphical user interface.
You can use different applications for the client depending on the operating system. You can use Remmina, RealVNC, TigerVNC, etc.
Requirements
- CentOS 8 Server
- 4 GB RAM
- Root rights
What we will do:
- Install Gnome Desktop
- Install TigerVNC and add a new user
- Set up TigerVNC as a service
- Set up the firewall
- Testing
Step 1 – Install Gnome Desktop
First we install the “Gnome Desktop” on the CentOS 8 server. The “Gnome Desktop” is available under CentOS 8 as part of the “Server with GUI” package.
Install “Gnome Desktop” with the dnf command below.
dnf group install "Server with GUI"
We will then configure the server to start the graphical environment automatically at every startup.
systemctl set-default graphical
Next, edit the gdm configuration “/etc/gdm/custom.conf” with the editor vim.
vim /etc/gdm/custom.conf
Remove the comment character from the “WaylanEnable” option and leave the value at “false”.
WaylandEnable=false
Save and close.
Now restart the server.
sudo reboot
After restarting the server, you will receive the “Gnome Desktop” as the default graphical environment.
Step 2 – Install TigerVNC and add a new user
After we have installed the “Gnome Desktop”, we install TigerVNC and add a new user.
Install the TigerVNC server with the dnf command below.
dnf install tigervnc-server tigervnc-server-module -y
After installation, create a new user “hakase” and assign a password for it.
useradd -m -s /bin/bash hakase passwd hakase
Next, log in as user “hakase” and create a new VNC password.
su - hakase vncpasswd
Enter the secure password VNC Login for the user “hakase” and repeat it.
Now we have installed the TigerVNC server and created a new user for VNC access.
Step 3 – Set up TigerVNC as a service
In this step we will configure TigerVNC as a systemd service. To do this, we need to create a new service file for TigerVNC.
Go to the directory “/etc/systemd/system” and create a new service file “[email protected]” with the editor vim.
cd /etc/systemd/system/ vim [email protected]
Change the user and the home directory with your own and add the following configuration.
[Unit] Description=Remote Desktop VNC Service After=syslog.target network.target [Service] Type=forking WorkingDirectory=/home/hakase User=hakase Group=hakase ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :' ExecStart=/usr/bin/vncserver -autokill %i ExecStop=/usr/bin/vncserver -kill %i [Install] WantedBy=multi-user.target
Save and close.
Now reload the systemd Daemon Manager.
systemctl daemon-reload
Start the VNC service and add that it is started automatically on boot.
systemctl start vncserver@:1.service systemctl enable vncserver@:1.service
Then check the VNC service.
systemctl status vncserver@:1.service
The VNC service is set up and running on the CentOS 8 server.
Step 4 – Set up the firewall
In this step we add the port of the VNC server to the firewall.
Execute the command firewall-cmd to add the port of the VNC server.
firewall-cmd --add-service=vnc-server --permanent
Now reload the firewalld and check all available services.
firewall-cmd --reload firewall-cmd --list-all
You will find the VNC server port in the list.
Step 5 – Testing
Make sure you have installed the VNC client for your own operating system.
For this guide we will use the Reminna Remote Desktop Client.
Open the Reminna application and add a new connection.
Now enter the IP address of the server, the port and the user and password.
Click on the“Save and connect” button.
As soon as you have established the connection, you will see the following screen.
Below you can see a screenshot of Nautilus on the CentOS 8 server.
Below you can see the terminal information about the server.
You have now installed the VNC server with the “Gnome Desktop” on the CentOS 8 server.