How To Install VNC Server on RHEL 8

0

The following simple guide helps you to install VNC server on RHEL 8 machines. VNC server lets you access the desktop remotely from other machines which have a client installed.

The VNC server is not installed, by default. You need to set up the VNC server manually.

Prerequisites

The steps mentioned in this article will only work if you have enabled RHEL 8 subscription or configured the local yum repository on your system.

Install Gnome Desktop

Before installing the VNC server, you would need to install the Gnome desktop using YUM command.

READ: Install Gnome Desktop on RHEL 8

Disable Wayland

As you already know from the features of RHEL 8, The GDM (Gnome) uses Wayland as the default display server in Red Hat Enterprise Linux 8, replacing X.Org server that was used in Red Hat Enterprise Linux 7.

In RHEL 8, VNC protocol got depreciated. So, the screen sharing and screencasting functionalities are not available to Wayland. But, this functionality is still available in X.org. So, we will switch GDM to use X.org as the default display server in Red Hat Enterprise Linux 8.

Edit the GDM configuration file.

vi /etc/gdm/custom.conf

Make sure the below line is uncommented.

WaylandEnable=false

Install VNC Server

The VNC server package is available on the base operating system repository. Here, we will install the TigerVNC server and X11 fonts packages using the YUM command.

yum install -y tigervnc-server xorg-x11-fonts-Type1

Configure VNC Server

Create a configuration file in /etc/systemd/system/ to run VNC service as a system service. By default VNC server listens on port 5900, but if we set up port-offset for VNC, we can run a VNC server on a sub-port of the default port 5900.

 /etc/systemd/system/vncserver@:<port>.service

For example, if we mention port 1, the desktop will be accessible in 5901. You can connect to the VNC desktop session by specifying ipaddress:<sub-port> (192.168.1.10:1 or 192.168.1.10:5901).

For this demo, I will use port 5.

vi /etc/systemd/system/vncserver@:5.service

Replace raj with your username.

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

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

PIDFile=/home/raj/.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

Restart=on-success
RestartSec=15

[Install]
WantedBy=multi-user.target

Start VNC Server

Start VNC server after switching to raj.

[raj@server ~]$ vncserver

Set the password.

Warning: rhel8.itzgeek.local:1 is taken because of /tmp/.X11-unix/X1
Remove this file if there is no X server rhel8.itzgeek.local:1

You will require a password to access your desktops.

Password: << Enter Password
Verify:  << Re-Enter Password
Would you like to enter a view-only password (y/n)? n
A view-only password is not used
xauth:  file /home/raj/.Xauthority does not exist

New 'rhel8.itzgeek.local:2 (raj)' desktop is rhel8.itzgeek.local:2

Creating default startup script /home/raj/.vnc/xstartup
Creating default config /home/raj/.vnc/config
Starting applications specified in /home/raj/.vnc/xstartup
Log file is /home/raj/.vnc/rhel8.itzgeek.local:2.log

SELinux

Consider disabling the SELinux if you are unable to start the VNC server service using the systemctl command.

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

Enable VNC Server

Switch to the root user.

su -

Reload the systemctl daemon.

systemctl daemon-reload

Start the VNC server service.

systemctl start vncserver@:5.service

Enable the VNC server on system startup.

systemctl enable vncserver@:5.service

Firewall

Add firewall a rule to allow the VNC remote desktop connection. The following rule is set to allow the port-offset 5905 mentioned in the previous step.

firewall-cmd --permanent --add-port=5905/tcp
firewall-cmd --reload

Access VNC Remote Desktop Session

Open up a VNC viewer from Windows/Linux machine and enter a remote desktop address.

ipaddress:5905

OR

ipaddress:5

You will be asked to enter the VNC session password. Enter the password that you have created earlier.

Install VNC Server on RHEL 8 - VNC Password
Install VNC Server on RHEL 8 – VNC Password

Now you should get the VNC desktop session.

Install VNC Server on RHEL 8 - VNC Remote Desktop
Install VNC Server on RHEL 8 – VNC Remote Desktop

Conclusion

In this post, you have learned how to install and configure VNC server on RHEL 8. If you have any issues or feedback, please share it in the comments section.

You might also like