Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Install tigervnc on Ubuntu

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.

  1. Install fvwm and xterm:
$ sudo apt install fvwm xterm
  1. Remove any pre-existing vnc software, like RealVNC 4:
$ sudo apt remove --purge vnc4server xvnc4viewer
$ sudo apt autoremove
  1. 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
  1. Unarchive the file:
$ tar xzf tigervnc-1.9.0.x86_64.tar.gz
  1. IMPORTANT! Set permissions on usr subdirectory of extracted files:
$ cd tigervnc-1.9.0.x86_64
$ sudo chown -R root:root usr
  1. By default everything gets installed to /usr. Change this to /usr/local (because we never mess with /usr):
$ sudo mv usr local
  1. 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/
  1. 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
  1. 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
  1. 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
  1. Update the system icon cache:
$ sudo update-icon-caches /usr/local/share/icons/*
  1. 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 &
  1. 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)
@plembo
Copy link
Author

plembo commented Feb 11, 2019

Settling on TigerVNC was a process for me. It was what I used back when I ran Red Hat derived distros. My company also ran it on all our RHEL boxes (with TWM as the window manager). If I recall correctly, when I first came over to Ubuntu the TigerVNC package (actually built by a Debian project team) had issues, so I turned to TightVNC. But the TightVNC code for Linux, like the original free cross-platform RealVNC, is no longer in development. Hence my return to TigerVNC, whose generic binaries for Linux work just fine on Ubuntu. The long term maintenance of an Ubuntu LTS machine has turned out to be a lot like my experience running RHEL/CentOS as a desktop. Although many commercial software packages are available for it, a growing number of packages in the official repositories are becoming stale: forcing me to go down the path of 3rd party repos and vendor binaries.

@Mackster01
Copy link

Mackster01 commented Apr 21, 2020

Hello, I followed your instructions to install TigerVNC on Ubuntu 19.10. With regard to the start up Gnome script, I don't have a 'vnc' directory under 'etc' .([ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup).

When I execute 'vncserver', below is the output. Any suggestions would be appreciated.

smackey@UbuntuNUC:/etc$ vncserver

New 'UbuntuNUC:1 (smackey)' desktop is UbuntuNUC:1

Starting applications specified in /home/smackey/.vnc/xstartup
Log file is /home/smackey/.vnc/UbuntuNUC:1.log_

@plembo
Copy link
Author

plembo commented Apr 22, 2020

@Mackster01
Copy link

Mackster01 commented Apr 23, 2020

Thanks for the response; I'm trying to find a way to remote desktop to my ubuntu from Win 10. I've used Teamviewer but it randomly generates new passwords which defeats the purpose. Are KDE/gnome required for VNC to work? If you have any other suggestions for remote desktop from windows to linux, any suggestions would be appreciated!

@plembo
Copy link
Author

plembo commented Apr 23, 2020

@Mackster01
Copy link

Mackster01 commented Apr 25, 2020

@plembo
Copy link
Author

plembo commented Apr 25, 2020

The 32-bit version of NoMachine doesn't setup correctly on Ubuntu 19.10 (or 18.04, for that matter). The 64-bit version (which I just tested, nomachine_6.9.2_1_amd64.deb) does. Same is true for tigervnc (tigervnc-1.10.1.x86_64.tar.gz). Most modern distributions are primarily designed as 64-bit software platforms, so compatibility with 32-bit software is usually a gamble.

@peter279k
Copy link

peter279k commented Jun 19, 2020

After trying many of VNC server on Ubuntu 18.04, the TigerVNC server I think it's most appropriate for my work purpose.

And thanks for your this post to let me know how to install and configure TigerVNC server :).

I also create this repository to let TigerVNC server loading automatically when the machine is booted.

@dausruddin
Copy link

dausruddin commented Dec 4, 2020

There is no vncserver in the latest release.

@plembo
Copy link
Author

plembo commented Dec 4, 2020

Yep. VNC has fallen out of favor and the Windows version of the server is no longer included in the latest binaries (1.11.0, release in September 2020). The main reason is performance. Bandwidth requirements are much greater than they were decades ago, and the compression available with VNC continues to have problems keeping up. If you're on Windows I'd strongly recommend NoMachine if you're connecting across the Internet. For local LAN only, the native Windows Remote Desktop is fine. If on Linux it's really a toss up between VNC and NoMachine. Given that I've been using it for almost 20 years, my personal preference is TigerVNC server on Linux, configured to use a lightweight window manager like FVWM. Gnome's remote desktop on Ubuntu 18.04 is still too broken for me to recommend. I've also tried various RDP servers for Linux, but all of them have proved broken enough that I won't use them.

@merc74
Copy link

merc74 commented Dec 11, 2020

Hi this works for me pretty well with version 9 and Lubuntu, LXDE or XCFE didn't work well at all.
It would be nice to have an install procedure with 1.11.0 that version has x0vncserver, I have no idea of how to make this all work with that.

@plembo
Copy link
Author

plembo commented Dec 12, 2020

I've been using the above process long enough that with v1.11.0 I didn't look carefully at the files actually included in the official binaries. When I went back and did today I realized for the first time that the vncserver perl script is missing from the bundle. It is also missing from the official source. That script is what does the heavy lifting when it comes to handling x0vncserver. Where I did find it is in a fork repo here, https://github.com/metalefty/tigervnc . I have run this with the 1.11.0 binaries and it tested good. As a result, I have modified the instructions in the gist to incorporate the downloading and installation of the file.

@plembo
Copy link
Author

plembo commented Dec 21, 2020

After a brief colloquy on this issue thread for tigervnc, I've realized that my own current usage doesn't even require tigervnc. Instead, I can more than get by using "ssh -X" (see this gist that I just wrote up). The need for vnc originally arose in the context of rolling out flights of Oracle Application and EBS servers. We were a Solaris shop that was for the first time deploying Linux servers in massive numbers. The use of vnc was Oracle's idea (although my own experience with vnc went back to deploying it to thousands of Windows NT workstations during Y2K as a backstop to our sometimes unreliable LANDesk clients). The main advantage of a vnc session compared to X over ssh is that you can close the client on a running vnc session and later connect back up with it to continue whatever you were doing. But, as they say in Kentucky Fried Movie, "that would be wrong" (from a security perspective).

@jimlinntu
Copy link

jimlinntu commented Jan 29, 2021

Hi @plembo, is it possible for you to take a look at my question!

https://askubuntu.com/questions/1311713/can-anyone-help-me-with-my-tigervnc-xstartup-script-for-ubuntu-18-04s-gnome-doc

I am stuck at icon missing issue.
I thought you may encounter similar issues before.

Thanks in advance!

@plembo
Copy link
Author

plembo commented Feb 4, 2021

Answered over in that other forum, but the "gist" of it is that the default Gnome icon set for the Ubuntu desktop is incomplete. Try installing the gnome-icon-theme package and see if that helps.

@cainmagi
Copy link

cainmagi commented Apr 19, 2022

Good script. It helps me solve my problem for a long time. But now I find an alternative approach for launching tigervnc. The vncserver file can be absent, see TigerVNC/tigervnc#1174 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment