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.

If you liked this article, then do subscribe to email alerts for Linux tutorials. If you have any questions or doubts? do ask for help in the comments section.

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

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

8 thoughts on “How to Install VNC Server on RHEL 8”

  1. And yes, the service is active:

    # systemctl status [email protected]:1.service
    
    ● [email protected]:1.service - Remote desktop service (VNC)
       Loaded: loaded (/etc/systemd/system/[email protected]; enabled; vendor pres>
       Active: active (running) since Sun 2020-07-26 10:29:46 BST; 7min ago
      Process: 1098 ExecStart=/usr/bin/vncserver -autokill :1 (code=exited, status=>
      Process: 1068 ExecStartPre=/bin/sh -c /usr/bin/vncserver -kill :1 > /dev/null>
     Main PID: 1115 (Xvnc)
        Tasks: 196 (limit: 49623)
       Memory: 575.9M
       CGroup: /system.slice/system-vncserver.slice/[email protected]:1.service
    
    Reply
    • @Peter

      The error could be “Failed to import environment: Process org.freedesktop.systemd1 exited with status 1” as stated in your other comment. Allow us to find more about this error.

      Reply
  2. I also get a blank screen after connecting. Could the error be “Failed to import environment: Process org.freedesktop.systemd1 exited with status 1“?

    Xvnc TigerVNC 1.9.0 - built Apr 22 2020 15:03:05
    Copyright (C) 1999-2018 TigerVNC Team and many others (see README.rst)
    See http://www.tigervnc.org for information on TigerVNC.
    Underlying X server release 12003000, The X.Org Foundation
    
    
    Sun Jul 26 10:29:43 2020
     vncext:      VNC extension running!
     vncext:      Listening for VNC connections on all interface(s), port 5901
     vncext:      created VNC server for screen 0
    The XKEYBOARD keymap compiler (xkbcomp) reports:
    > Internal error:   Could not resolve keysym XF86MonBrightnessCycle
    > Internal error:   Could not resolve keysym XF86RotationLockToggle
    Errors from xkbcomp are not fatal to the X server
    Failed to import environment: Process org.freedesktop.systemd1 exited with statu
    s 1
    
    Sun Jul 26 10:29:49 2020
     ComparingUpdateTracker: 0 pixels in / 0 pixels out
     ComparingUpdateTracker: (1:-nan ratio)
    
    Sun Jul 26 10:31:42 2020
     Connections: accepted: 192.168.1.78::53734
     SConnection: Client needs protocol version 3.8
     SConnection: Client requests security type VncAuth(2)
    
    Sun Jul 26 10:31:43 2020
     VNCSConnST:  Server default pixel format depth 24 (32bpp) little-endian rgb888
     VNCSConnST:  Client pixel format depth 6 (8bpp) rgb222
    
    Reply
  3. I got a blank screen too. Couldn’t figure it out with the instruction on the above article. This one worked for me.

    Reply
  4. OMG. First you don’t disable SELinux. Second, you don’t let vncserver run on 0.0.0.0 if you then want to connect to it via an ssh tunnel. The third vncviewer has a need switch called “via”. Forth, why open port 5901 if connecting via ssh tunnel (in which case only the ssh port needs to be open)?

    Reply
  5. Thank you, followed it step by step but I’m still tracking the failed>

    job for vncserver!:1.service failed because a timeout exceeded.

    Reply

Got something to say? Join the discussion.

Have a question or suggestion? Please leave a comment to start the discussion. Please keep in mind that all comments are moderated and your email address will NOT be published.

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