In this article I will share a step by step guide to configure vnc server in RHEL 8 Linux.
Xvnc is the X VNC (Virtual Network Computing) server. It is based on a standard X server, but it has a "virtual" screen rather than a physical one. X applications display themselves on it as if it were a normal X display, but they can only be accessed via a VNC viewer. So Xvnc is really two servers in one. To the applications it is an X server, and to the remote VNC users it is a VNC server. By convention we have arranged that the VNC server display number will be the same as the X server display number, which means you can use eg. snoopy:2
to refer to display 2 on machine "snoopy" in both the X world and the VNC world.
Configure VNC Server in RHEL 8
The first step to configure VNC Server in RHEL 8 Linux is install tigervnc-server
rpm
[root@rhel8-gui ~]# yum search tigervnc
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
============================================== Name & Summary Matched: tigervnc ===============================================
tigervnc-server.x86_64 : A TigerVNC server
tigervnc-license.noarch : License of TigerVNC suite
tigervnc-server-minimal.x86_64 : A minimal installation of TigerVNC server
Now to install vnc server in RHEL 8 execute below command. This will install tigervnc-server and any required dependency rpm
[root@rhel8-gui ~]# yum install tigervnc-server
Create below directory structure under root home directory
[root@rhel8-gui ~]# mkdir -p ~/.config/systemd/user
Next copy /usr/lib/systemd/user/vncserver@.service
to root user's home directory under ~/.config/systemd/user/
[root@rhel8-gui ~]# cp /usr/lib/systemd/user/vncserver@.service ~/.config/systemd/user/ [root@rhel8-gui user]# ls -l total 8 drwxr-xr-x. 2 root root 4096 Sep 14 19:55 default.target.wants -rw-r--r--. 1 root root 1853 Sep 11 11:34 vncserver@.service
Now we must reload the systemd daemon to refresh the systemd configuration
[root@rhel8-gui ~]# systemctl --user daemon-reload
Set vncpasswd for root user
[root@rhel8-gui ~]# vncpasswd
Password:
Verify:
Would you like to enter a view-only password (y/n)? n
A view-only password is not used
Since we do not need a view-only password hence I pressed "n"
Now we are all done with the steps to configure vnc server in RHEL 8. So let us start the vncserver service
[root@rhel8-gui ~]# systemctl --user enable vncserver@:2.service --now Created symlink /root/.config/systemd/user/default.target.wants/vncserver@:2.service → /root/.config/systemd/user/vncserver@.service.
Here we have used :2 as the display ID for our vncserver
Check if the vncserver service has started successfully
[root@rhel8-gui ~]# systemctl --user status vncserver@:2.service ● vncserver@:2.service - Remote desktop service (VNC) Loaded: loaded (/root/.config/systemd/user/vncserver@.service; enabled; vendor preset: enabled) Active: active (running) since Sat 2019-09-14 19:48:21 IST; 29min ago Tasks: 222 (limit: 25023) Memory: 420.0M CGroup: /user.slice/user-0.slice/user@0.service/vncserver.slice/vncserver@:2.service ├─2537 /usr/bin/Xvnc :2 -auth /root/.Xauthority -desktop rhel8-gui.example:2 (root) -fp catalogue:/etc/X11/fontpath> ├─2545 /bin/sh /root/.vnc/xstartup ├─2546 /usr/libexec/gnome-session-binary ├─2555 dbus-launch --sh-syntax --exit-with-session ├─2556 /usr/bin/dbus-daemon --syslog --fork --print-pid 7 --print-address 9 --session ├─2567 /usr/bin/ssh-agent /etc/X11/xinit/Xclients ├─2580 /usr/libexec/at-spi-bus-launcher ├─2585 /usr/bin/dbus-daemon --config-file=/usr/share/defaults/at-spi2/accessibility.conf --nofork --print-address 3 ├─2590 /usr/libexec/at-spi2-registryd --use-gnome-session ├─2591 /usr/libexec/gvfsd ├─2598 /usr/libexec/gvfsd-fuse /run/user/0/gvfs -f -o big_writes ├─2621 /usr/bin/gnome-keyring-daemon --start --components=pkcs11 ├─2633 /usr/bin/gnome-shell ├─2646 ibus-daemon --xim --panel disable ├─2651 /usr/libexec/ibus-dconf ├─2652 /usr/libexec/xdg-permission-store <Output trimmed>
Check if the service is enabled to come up after boot
[root@rhel8-gui ~]# systemctl --user is-enabled vncserver@:2.service enabled
Enable user lingering. If enabled for a specific user, a user manager is spawned for the user at boot and kept around after logouts. This allows users who are not logged in to run long-running services.
[root@rhel8-gui ~]# loginctl enable-linger
# firewall-cmd --permanent --zone=public --add-port=5950/tcp # firewall-cmd --permanent --zone=public --add-port=5951/tcp # firewall-cmd --permanent --zone=public --add-port=5952/tcp # firewall-cmd --reload
We are all done with the steps to configure vnc server in RHEL 8. Now you can try to connect to your RHEL 8 server using vnc viewer.
I am using vnc viewer installed on my Windows laptop to connect to the vnc server. As you see I am able to connect to my vnc server now using display ID ":2"
Lastly I hope the steps from the article to configure vnc server in RHEL 8 Linux was helpful. So, let me know your suggestions and feedback using the comment section.