VNC on Rocky Linux with X11VNC

Wiki.TerraBase.info
Revision as of 13:26, 21 August 2023 by Root (talk | contribs)
Jump to navigation Jump to search

Question(s)

Why is it so difficult to configure VNC or any "Remote Desktop" like GUI interface in Linux?

Err, wait, the question is actually: How can VNC Server be installed on Rocky Linux using X11VNC?

Objective

Install X11VNC Server on Rocky Linux 9. Forget about Tiger VNC. Nothing wrong with it at all, but this is just for basic X11VNC

Installation

First, remove all other instances of VNC Server (tigervnc*, etc.)

  • yum or dnf install x11vnc (VNC Server is installed as part of this package)
  • systemctl daemon-reload
  • type this command to start the VNC Server: x11vnc

All done? Nope. The real challenge is to get it to start as a Service. An even bigger challenge is to get it to start pre-login.

Run as a Service

Alas, not finished yet. Running the x11vnc command isn't the same as having the VNC Server running after a reboot.

Below is a very, very simple startup script. No password (can be added later);

[Unit]
Description=Start x11vnc at startup.
After=display-manager.service

[Service]
Type=simple
ExecStart=/usr/bin/x11vnc -display :0 -auth guess -forever -loop -rfbport 5900 -o /var/log/x11vnc.log

ExecStop =/usr/bin/x11vnc -remote stop

[Install]
WantedBy=multi-user.target

Good to go? Nope. That doesn't allow it to run until a user is logged in. Attempted to use the -create Switch, but it didn't work properly.

Workaround and Solution for Pre-Login VNC Server Access

...just couldn't do it.

So the work around is to have the system automatically login, thus starting the VNC service.

To facilitate automatically logging in, it depends on the version of Linux, which Desktop, and apparently barometric pressure on that particular day. Yes, it's that difficult and obnoxious (unlike Windows). Anyway, in this instance, it's going to be configured for Rocky Linux 8.8 using GNOME (the lightweight XFCE Desktop should be similar).

One or two of the following are necessary to configure (didn't test them individually, but together it works);

In /etc/gdm/custom.conf, add the following;

WaylandEnable=false
AutomaticLoginEnable=true
AutomaticLogin=root

In /etc/systemd/system/getty.target.wants/getty@tty1.service, change whatever is on the ExecStart line to the following;

ExecStart=-/sbin/agetty --noclear --autologin root %I $TERM

That automatically logs the root user in and starts the "display :0" session of the Desktop Manager to allow X11VNC Server to accept connections

Other Notes

To determine Desktop GUI being used: echo $XDG_CURRENT_DESKTOP

To determine Linux version and Install: lsb_release -a (may need to install it first: yum or dnf install lsb_release)

There are some indications that X11VNC will have difficulty on Rocky Linux 9 or later: https://forums.rockylinux.org/t/x11vnc-systemd-on-rocky9/8671 (might be because of GNOME Desktop, but doesn't seem to affect XFCE Desktop and includes the Wayland VS MATE stuff)

Use this command to see if the X11 Display Server (https://en.wikipedia.org/wiki/Windowing_system#Display_server) is being used: echo $$XDG_SESSION_TYPE (if the answer is x11, then you should be good to go)