NOTE: Given its current state, I've given up on tigervnc and now rely on "ssh -X" to execute remote gui apps. As a result I won't be updating this gist any more, but will leave it up as a reference for others.
Installing TigerVNC on Ubuntu 18.04 LTS
This is for Ubuntu 18.04 LTS. TigerVNC is a remote desktop session server and viewer solution sponsored by Red Hat that is still in active development. While I recently tested under Ubuntu 19.10, I have no plans to test non-LTS versions in the future.
There are packages for TigerVNC in the repositories of the major distributions, but the latest versions for Ubuntu are broken. My workaround is to use the latest stable version from the TigerVNC project Github release page, where generic binaries for 32 and 64-bit Linux are distributed as tarballs (dmg and exe installers for Mac and Windows are also available).
NOTE: A key file is missing from the latest official binary release of TigerVNC for Linux, a perl script named
vncserver. Fortunately, this file is available from a fork of the official repo. Instructions on
how to download and install this file are provided below.
While I continue to use the default Gnome Shell desktop on 18.04 LTS locally, it no longer works in a remote desktop session. If you really want to use Gnome remotely, you should look for a different solution like the proprietary NoMachine or Gnome's built-in desktop sharing option. For remote sessions using vnc I specify fvwm in my xstartup file (fvwm is slightly better than the even older twm). This has the advantage of using a lot less bandwidth and makes things more responsive over the network. Since my personal use of remote desktop sessions is to manage servers, the lack of a full desktop experience is not a drawback for me.
- Install fvwm and xterm:
$ sudo apt install fvwm xterm
- Remove any pre-existing vnc software, like RealVNC 4:
$ sudo apt remove --purge vnc4server xvnc4viewer $ sudo apt autoremove
- Download the latest release archive:
$ wget https://bintray.com/tigervnc/stable/download_file?file_path=tigervnc-1.9.0.x86_64.tar.gz -O tigervnc-1.9.0.x86_64.tar.gz
- Unarchive the file:
$ tar xzf tigervnc-1.9.0.x86_64.tar.gz
- IMPORTANT! Set permissions on usr subdirectory of extracted files:
$ cd tigervnc-1.9.0.x86_64 $ sudo chown -R root:root usr
- By default everything gets installed to /usr. Change this to /usr/local (because we never mess with /usr):
$ sudo mv usr local
- Then copy the binaries to their respective locations:
NOTE: Before you do this, set perms as indicated in previous step!
$ sudo tar czf local.tgz local $ sudo tar xzf local.tgz -C /usr/
- In a different console, double check that the binaries are where they should be:
$ which vncserver /usr/local/bin/vncserver $ which vncviewer /usr/local/bin/vncviewer
- The vncserver perl script is missing from the official binary release of TigerVNC for Linux beginning with v1.11.0, but is available from a fork of the official repo. This file should be downloaded and copied to /usr/local/bin.
$ wget https://raw.githubusercontent.com/metalefty/tigervnc/master/unix/vncserver $ sudo cp vncserver /usr/local/bin $ sudo chmod ugo+x /usr/local/bin/vncserver
- Run vncserver and vncviewer as an ordinary user just to ensure they are working:
$ vncserver :2 New 'test002:2 (plembo)' desktop is test002:2 Starting applications specified in /home/plembo/.vnc/xstartup Log file is /home/plembo/.vnc/test002:2.log
Kill the remote session once done testing:
$ vncserver -kill :2
- Update the system icon cache:
$ sudo update-icon-caches /usr/local/share/icons/*
- Create a new xstartup under .vnc (in the home directory of the user who will be launching remote sessions) to use fvwm as the remote desktop:
#!/bin/sh # xstartup to launch fvwm desktop session xsetroot -solid '#222E45' vncconfig -iconic & xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" & LANG=C fvwm &
- Now run vncserver again, and view the remote desktop with vncviewer (entering the remote password chosen previously).
A few additional notes:
- The main reason I continue to use vnc after all these years is that it allows me to quickly start a remote session by connecting to the remote host over ssh and then launching vncserver in that remote console. Other solutions either require the remote service to always be up and running (a security risk), or having someone on the remote desktop consent to the connection using a gui dialog (an impossibility when dealing with 1,000s of servers in a data center).
- You'll be invited to set a password the first time you run vncserver: do it! For the current version of TigerVNC, passwords are limited to 8 characters.Remember, the vnc server is not integrated with your host's authentication system: that password is the only thing that keeps outsiders from getting into an existing session.
- While you can certainly launch a vnc session as root, it is not recommended.
- TigerVNC does not support multiple monitors. If you're using fvwm as your remote desktop that won't be a problem: fvwm doesn't support multiple monitors either!
- Try to remember to kill your remote session when done, unless you really want to have Firefox open on a server for 465 days.
- That said, remote vnc sessions can be an alternative to managing processes that you might otherwise have to launch in the background, or with services or applications that can't be controlled from the command line.
- I now always specify a vnc port, as the default (":1") sometimes conflicts with other services. The standard vnc ports start at TCP 5900, so ":2" is actually TCP 5902. In the event of a conflict, you can use lsof to find what other processes may be using those ports:
$ lsof -i :5902 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME Xvnc 24358 plembo 6u IPv4 8362514 0t0 TCP *:5902 (LISTEN) Xvnc 24358 plembo 7u IPv6 8362515 0t0 TCP *:5902 (LISTEN)