How to set up a Linux server for remotely starting a XFCE desktop environment from a VNC client?

My problem

Assuming:

  • I have a macOS system with a VNC client (Screens 4)
  • I have a Rocky Linux 9 system installed on a server without monitor, keyboard, mouse…
  • Rocky Linux 9 was installed with minimal packages (no X11, no desktop environment…)
  • Both systems are on the same local network

I want to be able to connect to the Rocky Linux server from macOS with a VNC client and start graphical applications in a XFCE desktop.

What I tried

  • I installed and configured a ssh server. I can connect to the Rocky Linux system from macOS.
  • I installed the following packages to have a XFCE desktop environment and a X11 server:
sudo dnf install -y xorg-x11-xauth
sudo dnf groupinstall -y "xfce"
sudo dnf install -y x11vnc
sudo dnf install -y xterm

Now, from what I understood, I should run startx and then run x11vnc.
When running startx, I get the following output:

xauth:  file /home/username/.serverauth.1502 does not exist

/usr/libexec/Xorg.wrap: Only console users are allowed to run the X server
xinit: giving up
xinit: unable to connect to X server: Connection refused
xinit: server error
Couldn't get a file descriptor referring to the console.

By curiosity, I tried to run it with sudo:

xauth:  file /root/.serverauth.1530 does not exist

...

Failed to connect to bus: No medium found
dbus-update-activation-environment: error: unable to connect to D-Bus: /usr/bin/dbus-launch terminated abnormally without any error message

** (process:1562): WARNING **: 17:08:37.589: Could not make bus activated clients aware of XDG_CURRENT_DESKTOP=GNOME environment variable: Failed to execute child process ?dbus-launch? (No such file or directory)
xinit: connection to X server lost

waiting for X server to shut down (II) Server terminated successfully (0). Closing log file.

I do not know if I am trying to do the right thing and if yes, I do not know why I cannot startx without error.

Question

What are the correct setup steps to be able to connect to a Linux server installed with minimal packages, from another system with a VNC client and start a XFCE desktop environment?

Asked By: Mat.R

||

Instead of VNC you can try to run X applications directly. The Linux machine will execute application, but all graphics command will be sent to your desktop.

You would need an "X server" on your desktop for it. If you have Mac, then try https://www.xquartz.org/

Once you have XQuartz, open ssh connection to the Linux machine and run any X application. xclock for example, since it is almost always installed as part of X11 package.

If it doesn’t run immediately – try enabling X11 forwarding over ssh:

  • Go to main ssh config /etc/ssh/sshd_config or your personal ~/.ssh/config.
  • Uncomment or add:
        X11Forwarding yes
        X11UseForwarding yes

Then just run the applications you need.

If you insist on VNC – it would be easier to make a server into normal workstation first (add keyboard, monitor). Install all apps you need and VNC server. Done.

Answered By: White Owl
Categories: Answers Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.