How to setup VNC over SSH on Ubuntu server

Want an alternative to SSH or just fancy a change? No worries – here’s a quick guide I’ve put together to setup a VNC server on your Ubuntu server and connect through an SSH tunnel:

1. SSH to your box and and install tightvncserver (on a clean Ubuntu install I had to apt-get update and upgrade first):

me@myserver:~$ sudo apt-get install tightvncserver

2. Install session manager (I like GNOME, you can use what you like:)

me@myserver:~$ sudo apt-get install gnome-session

3. Add the session manager to your xstartup in ~/.vnc on the server:

xrdb $HOME/.Xresources
xsetroot -solid blackxport
gnome-session &

4. Start the server (the geometry and depth flags let you define the display resolution and the colour depth respectively):

me@myserver:~$ vncserver -geometry 1280x1024 -depth 16

5. Create the SSH tunnel from the local machine:

me@mylaptop:~$ ssh me@myserver -L 5901/

4. Fire up your VNC client – I’m using Chicken of the VNC on this Mac – and enter your connection info. Make sure to enter as the server to connect to:

5. Hit connect and you should see your desktop on the server:

ubuntu VNC server tutorial 2

One more thing I needed to do was disable a keyboard shortcut that had my D key held hostage. Go to System > Preferences > Keyboard Shortcuts and look under Window Management for ‘Hide all Windows and set focus to the Desktop’ and disable it:

ubuntu VNC server tutorial 3

This entry was posted in Tutorials. Bookmark the permalink.

4 Responses to How to setup VNC over SSH on Ubuntu server

  1. feruq says:

    Thank you very much i did it and it solved a huge problem I had … Now i’m controlling my ubuntu server from windows … Thanks :)

  2. jae says:

    Hi, thanks for this useful information.

    I have a problem and is that when I connect with the vnc client, I can’t see the session.

    Besides, it only works the first time, after that I got this error:
    open failed: connect failed: Connection refused

  3. SirKingChase says:

    I set up a computer using a guide simular to this one that referenced chickenvnc, however this is not it. This guide does not work for me, anyone having trouble follow the link below. I have set up 3 computers using that guide. Make sure you uninstall tightvncserver first, it will conflict and act weird.

  4. AGanesh says:

    You are a star, This worled like a charm, Thanks

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>