How to run a remote desktop from Linux

How to run a remote desktop from Linux: Not only do remote desktops enable you to access your old familiar machine from anywhere on the internet, they also enable you to build a multi-desktop, multi-user environment out of a single machine that doesn't necessary even need a screen.

This is a great solution on netbooks, for example, where you may occasionally need the extra horsepower of a full-blown PC. Just connect to the server from your netbook desktop and you've got a full desktop on top of a small one.

1. VNC

There are several ways to run a remote desktop from Linux. The X server itself was designed to run remotely, and you can still forward windows from a local server to a remote one with relative ease, especially if you use SSH.

But the X protocol is inefficient, and only fast enough for general use if you're connected to the same network as the server.

A far better alternative is FreeNX. This breaks window and cursor movement up into a series of commands that can be transferred much more efficiently than X, and the remote desktop is much more responsive as a result.

But there's a problem with FreeNX: It can be a complete pain to install, and there seems to be a different method for every distribution we look at. The day FreeNX becomes easy to install is the day we'll write instructions on how to get it to work. This leaves us with VNC.

VNC sends chunks of compressed image data rather than interpreting any drawing routings, and as a result sits half-way between the X server and FreeNX for efficiency. But it does have one big advantage, and this is that you can find VNC clients everywhere.

Many mobile phones, PDAs and netbooks will have a VNC client available, and both Windows and OS X have free and paid-for client applications that can connect to VNC running on your Linux box. From a Linux perspective, KDE and Gnome both have built-in support for connecting to VNC servers.

2. Running the server

There are several variations of VNC, but our favourite is called TightVNC, which includes a few performance improvements over the original VNC protocol.

On your server, you should be able to install the tightvncserver package from the package manager.

To start a VNC session, you need to open a command line and type vncserver :1. This will launch a new server which will be attached to the second (:1) graphics console on the machine.

The first would be :0, but this will be the current display on that machine, unless it's running in pure console mode. Any other machine running on the LAN will now be able to connect to the VNC server by using the IP address of the server followed by :5901.

As VNC uses just one port (5901) you can easily tunnel this port to a remote connection through SSH.

This is a great solution if you want to access your Linux box from the wilds of the internet, as it means you only need to leave the relatively secure SSH port open (port 22), with just the SSH server facing the internet. The VNC server is safely tucked away behind the firewall.

An SSH tunnel is a little like a wormhole. It takes the data from port 5901 on the server, for instance, tunnels this through the standard SSH data connection on port 22, and reconstitutes the data on the client at the local port 5901.

All you then have to do is use a VNC client to connect to localhost:5901 rather than the remote IP address.

Comments