Saturday, April 19, 2025

Installing TigerVNC in Ubuntu 24.04

Installing TigerVNC in Ubuntu 24.04

Ubuntu 24.04 supports RPD protocol but it behaves in a way that is not fit for my needs. The Desktop Sharing mode needs to have a user logged in or set to automatically login on reboot. Anyone will have access to your desktop if they are physically present. The Remote Login would have been the best option but when the connection is lost, all applications running on that session are gone. So you can't reconnect to that same session.

So, we are back to the tried and tested VNC protocol. To get TigerVNC working on Ubuntu 24.04 is a little tricky due to Wayland becoming the default in 24.04. To workaround Wayland, we need to install XFCE, like so:
$ sudo apt install --no-install-recommends xubuntu-desktop
This installs base XFCE4 with very applications specific to XFCE.

Install xfce4-terminal for convenience. GNOME-Terminal is pretty heavy and uxterm/xterm are not to my liking.
$ sudo apt install xfce4-terminal
Now install TigerVNC
$ sudo apt install tigervnc-standalone-server
Then set the password that will be used to connect to the VNC server by running it like below:
$ vncpasswd
Now we have to define the mapping between a VNC session and user for that session. To do this open /etc/tigervnc/vncserver.users, like:
$ sudo vim /etc/tigervnc/vncserver.users
Below is an example that shows user u1 is mapped to VNC server session 2:
# TigerVNC User assignment
#
# This file assigns users to specific VNC display numbers.
# The syntax is <display>=<username>. E.g.:
#
# :2=andrew
# :3=lisa
:2=u1
Now run VNC server, like:
$ vncserver -geometry=1360x768 -xstartup /usr/bin/startxfce4 :2 -localhost no
Using RealVNC client on Windows, you can calculate geometry of the server like this to get maximum client area:
Add-Type -AssemblyName System.Windows.Forms;
$wa = [System.Windows.Forms.Screen]::PrimaryScreen.WorkingArea
$titleBarHeight = [System.Windows.Forms.SystemInformation]::CaptionHeight
$offset = 16
$w = $wa.Height - $titleBarHeight - $offset
$h = $wa.Width - $offset
Write-Host "$($h)x$($w)"
Should you need to close/kill the session, do:
$ vncserver -kill :2


There is a big caveat that I haven't figured out, yet. No user should be logged in to the console/physical session. Otherwise, everything goes crazy.
References:
https://medium.com/oracledevs/your-next-developer-desktop-with-ubuntu-24-04-and-tigervnc-on-oci-d0356ffa0cf9

No comments:

Running QNX on emulated cortex-a15 using QEMU

Running QNX on emulated cortex-a15 using QEMU General information: - Host (for running QEMU) OS: Ubuntu 24.04.2 LTS - QEMU: QEMU emulator...