Thursday, July 29, 2010

How to install TightVNC Server on Ubuntu

The TightVNC server provided by the universe repository of Ubuntu doesn't work well in a xdmcp/gnome environment.

The server frequently crashes (segfaults), keyboard mappings are broken and X forwarding doesn't work out of the box. To let the server crash on Ubuntu 10.04 you had to open a few applications and eventually it would crash when opening or closing an application. Using Ubuntu 9.10 it would always crash when having two apps open like firefox and open office.

If you aren't tied to TightVNC, I would suggest using the vnc4server package that doesn't seem to suffer the same issues. I did find it slightly slower and I couldn't run a 8 bit environment effectively. It lost too much information in 8 bit to be usable. When using vnc4server I would suggest a minimum colour depth of 15 bit.

Compile and install the new version of TightVNC from source
The stability is fixed in TightVNC server 1.3.10. The version 1.3.9 currently included in Ubuntu doesn't work.

Unzip the archive and review the README file on how to compile the source. I had to install the following dependencies to build the source:
  • xorg-dev
  • libjpeg62-dev
  • zlib1g-dev
  • xmkmf
It is important to note that you do need to build the viewer and other libraries before going into the XVnc folder and building it.

After the build was successful, use the vncinstall script to copy the required binaries. I installed to /usr/local/bin and had to create the /usr/local/man/man1 directory for the man pages to be copied successfully.

Update alternatives
Since you installed the binaries manually you have to set up the alternatives for XVnc to point to your new libraries.

I always forget the syntax, so here it is for a quick reference:
update-alternatives --install /usr/bin/Xvnc Xvnc /usr/local/bin/Xvnc 80
where /usr/local/bin/Xvnc is your newly built tightvnc viewer.

Make sure your new installation is selected by executing "update-alternatives --config Xvnc"

Configure xdmcp in gdm.
/etc/gdm/custom.conf was missing from my installation and xdmcp wasn't enabled.

Create a /etc/gdm/custom.conf file and add the following content:





Setup TightVNC
While setting up VNC it is important to note that your newly built TightVNC server tries to fetch X fonts from a different location to what Ubuntu uses. When you configure the service you have to append the following to the Xvnc command:
-fp /usr/share/fonts/X11/misc/,/usr/share/fonts/X11/Type1/,/usr/share/fonts/X11/75dpi/,/usr/

A service entry will then look something like this:
service vnc-1024x768x8-tightvnc
protocol = tcp
socket_type = stream
wait = no
user = nobody
server = /usr/bin/Xvnc
server_args = -inetd -query localhost -once -geometry 1024x768 -depth 8 -fp /usr/share/fonts/X11/misc/,/usr/share/fonts/X11/Type1/,/usr/share/fonts/X11/75dpi/,/usr/share/fonts/X11/100dpi/

Follow the instructions on:, skipping the sections on how to install TightVNC and remember to add the font path (-fp) section from above to the server_args.

Test the server
At this point the server should be up and running and you should be able to connect to the server. If you can't, verify that the font path is correct in your service setup. If TightVNC can't find the font, the server closes the connection without a warning or message. Also check your firewall to see if it is blocking the connection.

At this point X forwarding won't work and your keyboard mappings may be stuffed in gnome.

Keyboard mapping fix
This issue only appears to be affecting gnome. I couldn't find a fix, but there is a workaround where you tell gnome to not do any keyboard mappings.

Add the following line to /etc/gdm/Xsession:
and restart the gdm service. The gdm service now uses upstart, so type "restart gdm" to restart it. That line is executed every time a X session starts for a user logging in using gdm.

Enabling X forwarding

Add the following line to /etc/gdm/Xsession:
xhost +localhost
That allows anybody logged into the machine access the the local X server. Have a look at for more details.

Your server should be up and running with no crashing, no keyboard issues and with X forwarding enabled.

I hope you found this post useful and saved some time trying to get TightVNC to work properly.

Until later,


  1. Thanks very much, Pieter, the 64 bit Ubuntu 10.04 LTS tightvnc was very unstable. Rather than putting in a font path, I just made made a directory with soft link

    sudo mkdir /usr/X11R6/lib/X11
    sudo ln -s /usr/share/fonts/X11 /usr/X11R6/lib/X11/fonts

    seems to be ok and nothing exploded yet

  2. This was just what I needed. Thank you for posting this.

    I didn't want to follow the instructions to install xinetd to fix the font issue so I followed this:

    All I had to do was edit vncserver and add:

    $fontPath = join ',',qw(

    Under the line: "$fontPath = "unix/:7100";"

    1. Hey Jeff, your $fontPath code fixed it for me. Thanks!

  3. Good article but for a beginner, it is *very* confusing on a few parts:

    1) You talked briefly about vnc4server but then you went on to say download the latest tightvnc... Then there is mention of Xvnc as well. At the end of the day, what are we using? xtightvnc? tightvnc? vncserver? vnc4server? Xvnc? I'm assuming it's vnc4server but there never was any directions to install vnc4server, and there was never any mention near the end of the article to start vnc4server, it was just supposed to start on it's own? (It didn't.)

    2) The code, "-fp /usr/share/fonts/X11/misc/,/usr/share/fonts/X11/Type1/,/usr/share/fonts/X11/75dpi/,/usr/share/fonts/X11/100dpi/" Has a line break in the middle of it, which made me think I just needed to put in the first half.

    3) Linking to an external source of instructions: It would be much clearer and easier to follow if the snippets needed from were included in this article.

    Anyway, I'm glad I found this article. I'd be lost without the information here. Thanks!

  4. Great article -- really helpful. However it turns out that installing to /usr/local/bin is not a good idea because that typically appears before /usr/bin in your path. This is why everyone's having problems with fonts and such. The only think that actually needs changing is /usr/bin/Xtightvnc. Here are the steps I used to get my config working.

    pushd ~
    sudo apt-get install xorg-dev libjpeg62-dev zlib1g-dev xmkmf
    mkdir -p vnc-problem/new
    cd vnc-problem/new
    tar xzf tightvnc-1.3.10_unixsrc.tar.gz
    cd vnc_unixsrc
    make World
    cd Xvnc
    time make
    sudo mv /usr/bin/Xtightvnc /usr/bin/Xtightvnc-1.3.9
    sudo cp programs/Xserver/Xvnc /usr/bin/Xtightvnc-1.3.10
    sudo chown root:root /usr/bin/Xtightvnc-1.3.10
    sudo chmod 755 /usr/bin/Xtightvnc-1.3.10
    sudo update-alternatives --install /usr/bin/Xtightvnc Xtightvnc /usr/bin/Xtightvnc-1.3.9 50
    sudo update-alternatives --install /usr/bin/Xtightvnc Xtightvnc /usr/bin/Xtightvnc-1.3.10 60
    sudo update-alternatives --config Xtightvnc # choose Xtightvnc-1.3.10
    sudo update-alternatives --set Xtightvnc /usr/bin/Xtightvnc-1.3.10

  5. Karamba online casino - Kadangpintar
    Karamba online casino. Karamba online kadangpintar casino. Karamba online casino. Karamba online casino. 메리트카지노 Karamba online casino. Karamba online casino. Karamba online casino. 샌즈카지노 Karamba