How to Install VNC Server on RHEL 8

VNC (Virtual Network Computing) is a popular platform for graphical desktop sharing which allows you to remotely access, view and control other computers over a network such as the Internet.

VNC uses the Remote Frame Buffer protocol (RFB) and works on the client-server principle: a server shares its output (vncserver) and a client (vncviewer) connects to the server. Note that the remote computer must have a desktop environment installed.

In this article, we will explain how to install and configure VNC Remote Access in the latest release of RHEL 8 Desktop edition through a tigervnc-server program.

Requirements:

  1. RHEL 8 with Minimal Installation
  2. RHEL 8 with RedHat Subscription Enabled
  3. RHEL 8 with Static IP Address

Once your RHEL 8 system meets the above-listed requirements, you are ready to set it up as a VNC server.

Step 1: Disabling Wayland Display Manager and Enabling X.org

1. The default Desktop Environment (DE) on RHEL 8 is GNOME which is configured to use Wayland display manager by default. However, Wayland isn’t a remote rendering API like X.org. So, you need to configure your system to use the X.org display manager.

Open the GNOME Display Manager (GDM) configuration file using your favorite command line editor.

# vi /etc/gdm/custom.conf

Then uncomment this line to force the login screen to use Xorg.

WaylandEnable=false
Disable Wayland in Gnome

Disable Wayland in Gnome

Save the file and close it.

Step 2: Install VNC Server in RHEL 8

2. TigerVNC (Tiger Virtual Network Computing) is an open source, a widely-used system for graphical desktop sharing which allows you to remotely control other computers.

# dnf install tigervnc-server tigervnc-server-module

3. Next, switch to the user you want to run and use the VNC program by setting the user’s VNC server password (which should be at least six characters), as shown.

# su - tecmint
$ vncpasswd
Set User VNC Password

Set User VNC Password

Now switch back to the root account by running the exit command.

$ exit

Step 3 Configure VNC Server in RHEL 8

4. In this step, you have to configure the TigerVNC server to start a display for the above user on the system. Start by creating a configuration file named /etc/systemd/system/[email protected] as follows.

# vi /etc/systemd/system/[email protected]

Add the following configuration in it (remember to replace tecmint with your actual username).

[Unit] 
Description=Remote desktop service (VNC) 
After=syslog.target network.target 

[Service] 
Type=forking 
WorkingDirectory=/home/tecmint 
User=tecmint 
Group=tecmint 

PIDFile=/home/tecmint/.vnc/%H%i.pid 

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 the file and close it.

Before we move any further, let’s briefly understand how the VNC server listens to requests. By default, VNC uses TCP port 5900+N, where N is the display number. If the display number is 1, then the VNC server will run on display port number 5901. This is the port you have to use while connecting to the server, from the client.

Step 4: Enable VNC Service in RHEL 8

5. To start the VNC service, you need to disable SELinux which is enforcing mode by default on RHEL 8.

# setenforce 0
# sed -i 's/enforcing/disabled/g' /etc/selinux/config

6. Now reload the systemd manager configuration to apply the recent changes and then start the VNC service, enable it to auto-start at system boot time and check if it is up and running using the following systemctl commands.

# systemctl daemon-reload
# systemctl start [email protected]:1
# systemctl status [email protected]:1
# systemctl enable [email protected]:1
Enable VNC Service

Enable VNC Service

7. At this point, the VNC service is up and running, verify that the VNC server is listening on TCP port 5901 using the netstat command.

# netstat -tlnp
Check VNC Listening Ports

Check VNC Listening Ports

8. Next, open the port 5901 in the system firewall service which is running by default, as shown. This allows access to VNC service from clients.

# firewall-cmd --permanent --add-port=5901/tcp
# firewall-cmd --reload

Step 5: Connecting to VNC Server via VNC Client

9. Now it is time to look at how to access the VNC server from a client side. VNC is not a secure system by default meaning your connections are not at all encrypted. But you can secure connections from the client to the server using a technique known as SSH tunneling as explained below.

Remember that you need to configure passwordless SSH authentication between the server and the client machine, to increase the trust between the two Linux systems.

Then on Linux client machine, open a terminal window and run the following command to create an SSH tunnel to VNC server (don’t forget to change the path to the identity file (~/.ssh/rhel8) and IP address (192.168.56.110) of the server accordingly):

$ ssh -i ~/.ssh/rhel8 -L 5901:127.0.0.1:5901 -N -f -l tecmint 192.168.56.110

10. After creating the SSH tunnel, you can install vncviewer client such as TigerVNC Viewer on the client machine.

$ sudo apt install tigervnc-viewer         #Ubuntu/Debian
# yum install tigervnc-viewer              #CnetOS/RHEL
# yum install tigervnc-viewer              #Fedora 22+
$ sudo zypper install tigervnc-viewer      #OpenSUSE
# pacman -S tigervnc                       #Arch Linux

11. When the installation is complete, run your VNC client, specify the address localhost:5901 to connect to display 1 as follows.

$ vncviewer localhost:5901
OR
$ vncviewer 127.0.0.1:5901

Or else, search and open the VNC client program from the system menu, then enter the address above and then click Connect as shown in the following screenshot.

Open VNC Client

Open VNC Client

If the connection is successful, you will be prompted for the VNC login password created earlier on in Step 2, point 3. Provide it and click OK to proceed.

Enter VNC Login Password

Enter VNC Login Password

Upon a successful VNC server authentication, you will be presented with the remote RHEL 8 system desktop interface. Click Enter to access the login interface and provide your password to access the desktop.

RHEL 8 Desktop Accessed via VNC Client

RHEL 8 Desktop Accessed via VNC Client

In this article, we have shown how to install and configure VNC server on RHEL 8. As usual, you can ask questions via the feedback form below.

Best Affordable Linux and WordPress Services For Your Business
Outsource Your Linux and WordPress Project and Get it Promptly Completed Remotely and Delivered Online.

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Get your own self-hosted blog with a Free Domain at ($3.45/month).
  4. Become a Supporter - Make a contribution via PayPal
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

Aaron Kili

Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

Got something to say? Join the discussion.

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.