How to install and configure TigerVNC on Ubuntu 20.04

TigerVNC is in the default repositories here on Ubuntu, but the version in the repository is broken and will not work on Ubuntu anymore because of the behaviours of the gnome desktop launch sequence mostly. We must manually install the binary package provided by TigerVNC directly. There are new special configuration to be done now also, with a bit of lack of documentation because of major recent changes to how TigerVNC starts up, and handles loading and managing desktop environments. Developers advise through the forums on github, that the reason is because desktop environments themselves have changed themselves so much over time it requires new optimizations.

Specifically, TigerVNC now changes the way it runs as a service, and needs a whole new systemd configuration file. Though, tigervnc can automatically generate the systemd configuration file.

It's also worth noting that you can only have one session per user with this protocol, including physical sessions. So the desktop user should be logged out. This software is designed for enterprise purposes, where in this case the performance is more important than the flexibility, at least for now. You should create new users on the physical system for your unique remote sessions if you need to.

Download & Install TigerVNC

You must manually download the binaries for TigerVNC now, the repository is not a good source for the package. Use the TigerVNC github releases link, and under the latest release description / changes notes, you will see:

Binaries are available from SourceForge:

and a link to the latest available .deb package for Ubuntu. You might have to look under the folder "ubuntu-18.04LTS", then under "amd64". Don't worry the package will work on 20.04 anyways.

  $ wget <<Insert direct link to tigervncserver_x.x.x.x.....deb>>

This command forcefully installs an older dependency file that tigervnc depends on. For whatever reason, it is not compiled with this latest lib font binary file. Downgrading one small version of this has had no known side effects for me, but take caution!

  $ sudo apt install libc6=2.31-0ubuntu9.2 libc-bin=2.31-0ubuntu9.2

After forcefully downgrading your dependency, you can safely install tigervncserver. Make sure you do not have any tigervncserver packages from the repository, as they will conflict heavily with this. Uninstall, remove, purge, any other versions of TigerVNC prior to installing this deb package.

  $ sudo apt install ./tigervncserver_1.11.80+20210616git9ec1f360-1ubuntu1_amd64.deb

Disable Wayland

Wayland is default for Gnome on Ubuntu. It is not compatible with VNC protocol. We must disable it to be able to run the service.

 $ sudo vim /etc/gdm/custom.conf

Uncomment the following line:

 WaylandEnable=false

Wayland support is unlikely to come to TigerVNC soon st this time of writing, based on developer comment only 2 days ago:

"As an independent software developer, I have to go where the money is, and the industries that financially sponsor most of my work on this project are always at the tail end of the curve, not the front end. This will only become a high priority for them (and, by extension, me) when commercial applications (and the GUI frameworks on which they are built) stop supporting X11 altogether. As long as Qt, GTK, etc. have dual X11 and Wayland support, applications that use those frameworks should continue to work with TurboVNC, even if they use Wayland on the local display. Commercial ISVs cannot, at this point, choose to support only Wayland, because there are still enterprise/LTS Linux distributions in active support that don't have Wayland capabilities at all. That's why I feel that things will begin to move on this front once large enterprises start moving from RHEL 7 to RHEL 8, which won't happen for a few years. "

https://github.com/TurboVNC/turbovnc/issues/18

Configure template TigerVNC use by default for new systemd services.

 $ sudo vim /etc/tigervnc/vncserver-config-defaults

Here you can read in this file a brief description about some example variables. Change these to your own personal needs, but there is one variable you need to set that isn't in the example list. You must add the following to the end of the file:

  session=ubuntu

TigerVNC gnome sessions need to specify the session from the list of available sessions in "/usr/share/xsessions" ending in *.desktop. On ubuntu, this is called "ubuntu.desktop", whereas other distros might call it "gnome.desktop" so we use the session=ubuntu line, rather than the default "session=gnome".

Configure VNC Users

Add users if necessary, or use existing users. We set a VNC specific password that is used for access control with the VNC protocol for each user's display. VNC is meant to have 1 display per user.

Set VNC password

Run as the user you want to use VNC with, vnc password is used for connection authorization, nothing else. It is not the same as the user account password.

  $ vncpasswd

Add user(s) to the TigerVNC user-mapping config file

  $ sudo vim /etc/tigervnc/vncserver.users

Then you see simple instrcutions on how to configure the file, commented in the top lines of the file. Add your user as follows, to the bottom of the file.

 $ :1=vncuser

Enabling the systemd service, automating on startup.

The systemd service template already gets installed when you install the package. Run the command below to enable, and start vnc server for specific display / user.

  $ sudo systemctl enable [email protected]:1
  $ sudo systemctl start [email protected]:1

Firewall rules

Each display is given an iterative port number from 5900 and up, based on their display number. Open port on 'home' network zone, if you wish to access over the LAN. For display :1

  $ sudo ufw allow from x.x.x.x/24 to any port 5901

The above command allows IP from a specific subnet range to connect to port 5901, which is default port for display ":1".

Fin

These instructions are based off of Fedora documentation here (out of date instructions but still useful to glean from), and some comments found on the TigerVNC github by the developer

https://docs.fedoraproject.org/en-US/fedora/f33/system-administrators-guide/infrastructure-services/TigerVNC/

https://github.com/TigerVNC/tigervnc

Also a useful reference material:

https://wiki.archlinux.org/index.php/TigerVNC

Another source for some relevant material:

https://www.tecmint.com/install-vnc-server-on-rhel-8/

Another resource that helped to find step to manually downgrade version of broken dependency.

https://askubuntu.com/questions/1315906/unmet-dependencies-libc6-the-package-system-is-broken