How to Configure VNC Server in CentOS/RHEL 8
This post explains the steps to easily setup VNC server in CentOS/RHEL 8. Should be able to access VNC session after completing the steps outlined in this post.
Follow these steps to install and configure VNC server.
1. Install required rpms for tigervnc. It will list many dependencies. Should continue the installation with the listed dependencies.
# dnf install tigervnc-server
Installing:
tigervnc-server
Installing dependencies:
dbus-x11
libICE
libSM
libX11
libX11-common
libX11-xcb
libXau
libXcursor
libXdamage
libXdmcp
libXext
libXfixes
libXfont2
libXi
libXinerama
libXmu
libXrandr
libXrender
libXt
libXtst
libXxf86misc
libXxf86vm
libdrm
libfontenc
libglvnd
libglvnd-glx
libjpeg-turbo
libmcpp
libpciaccess
libxcb
libxkbfile
libxshmfence
llvm-libs
mcpp
mesa-dri-drivers
mesa-filesystem
mesa-libGL
mesa-libglapi
perl-Carp
perl-Errno
perl-Exporter
perl-File-Path
perl-IO
perl-PathTools
perl-Scalar-List-Utils
perl-Socket
perl-Text-Tabs+Wrap
perl-Unicode-Normalize
perl-constant
perl-interpreter
perl-libs
perl-macros
perl-parent
perl-threads
perl-threads-shared
pixman
tigervnc-license
tigervnc-selinux
tigervnc-server-minimal
xorg-x11-server-utils
xorg-x11-xauth
xorg-x11-xinit
xorg-x11-xkb-utils
Enabling module streams:
llvm-toolset
1. Install the required gnome RPM packages with the following command. Accept the dependencies and proceed with installation.
# dnf install gnome-autoar.x86_64 gnome-bluetooth.x86_64 gnome-bluetooth-libs.x86_64 gnome-boxes.x86_64 gnome-calculator.x86_64 gnome-characters.x86_64 gnome-classic-session.noarch gnome-color-manager.x86_64 gnome-control-center.x86_64 gnome-control-center-filesystem.noarch gnome-desktop3.x86_64 gnome-disk-utility.x86_64 gnome-font-viewer.x86_64 gnome-getting-started-docs.noarch gnome-initial-setup.x86_64 gnome-keyring.x86_64 gnome-keyring-pam.x86_64 gnome-logs.x86_64 gnome-menus.x86_64 gnome-online-accounts.x86_64 gnome-remote-desktop.x86_64 gnome-screenshot.x86_64 gnome-session.x86_64 gnome-session-wayland-session.x86_64 gnome-session-xsession.x86_64 gnome-settings-daemon.x86_64 gnome-shell.x86_64 gnome-shell-extension-apps-menu.noarch gnome-shell-extension-common.noarch gnome-shell-extension-desktop-icons.noarch gnome-shell-extension-horizontal-workspaces.noarch gnome-shell-extension-launch-new-instance.noarch gnome-shell-extension-places-menu.noarch gnome-shell-extension-window-list.noarch gnome-software.x86_64 gnome-system-monitor.x86_64 gnome-terminal.x86_64 gnome-terminal-nautilus.x86_64 gnome-themes-standard.x86_64 gnome-user-docs.noarch gnome-video-effects.noarch
3. The way of configuring VNC has changed from Oracle Linux 8 onwards. Until OL7, running command “vncserver” creates a vnc session but in OL8 it gives the following message.
# vncserver
vncserver has been replaced by a systemd unit.
Please read /usr/share/doc/tigervnc/HOWTO.md for more information.
4. Add the following option in /etc/tigervnc/vncserver-config-defaults:
# vi /etc/tigervnc/vncserver-config-defaults
session=gnome
5. Set the vnc password for the required user:
# su - vncuser1
# vncpasswd
Password:
Verify:
Would you like to enter a view-only password (y/n)? n
A view-only password is not used
6. Add the vnc user in the /etc/tigervnc/vncserver.users. Here “:2” represents the VNC display number:
# vi /etc/tigervnc/vncserver.users
:2=vncuser1
7. Start the vnc service for the above user as root user with below command. In the service name, specify the VNC number as required. In this case it is :2 that is defined in the step 5.
# systemctl start vncserver@:2.service
# systemctl status vncserver@:2.service
● vncserver@:2.service - Remote desktop service (VNC)
Loaded: loaded (/usr/lib/systemd/system/[email protected]; disabled; vendor preset: disabled)
Active: active (running) since Wed 2020-12-16 12:24:59 EST; 10s ago
Process: 16171 ExecStart=/usr/libexec/vncsession-start :2 (code=exited, status=0/SUCCESS)
Main PID: 16177 (vncsession)
Tasks: 1 (limit: 4179)
Memory: 1.4M
CGroup: /system.slice/system-vncserver.slice/vncserver@:2.service
‣ 16177 /usr/sbin/vncsession vncuser1 :2
8. To access the VNC session, use applications like tigervnc. Launch the application and input [HOSTNAME/IP]:2 as the VNC server. Here 2 refers to the X DISPLAY session value from the step 6. This should open a VNC session.
9. To stop the VNC session, run the following command.
# systemctl stop vncserver@:2.service
10. If there is pop-up comes up after the VNC session login with a message “Authentication is required to refresh system repositories”, perform the following steps.
# vi /etc/polkit-1/localauthority/50-local.d/46-allow-update-repo.pkla
[Allow Package Management all Users]
Identity=unix-user:*
Action=org.freedesktop.packagekit.system-sources-refresh
ResultAny=yes
ResultInactive=yes
ResultActive=yes
11. Stop and start the VNC service.
# systemctl stop vncserver@:2.service
# systemctl start vncserver@:2.service