dcsimg

Set Up a VNC Linux Server in 5 Easy Steps

By Juliet Kemp (Send Email)
Posted Mar 1, 2010


Virtual Network Computing (VNC) allows you to log into a full desktop on a remote server (as opposed to just opening windows on your local machine, as with X11 over SSH). It can be very useful, and it's very fast to set up.

Step 1

Tip of the Trade: VNC makes it easy to log into a full desktop on a remote server. Follow these steps, and your Debian Linux server will be up and running in no time.

I chose to use vnc4 (there are other options, such as TightVNC), so the first step was the vnc4server Debian/Ubuntu package on my remote server. Once vnc4 is installed, run it for the first time to finish setup, and set a VNC password:

vncserver :1
This starts a daemon off, rather than vnc4 running in the foreground. You'll get your shell prompt back once it's running.

Step 2

To kill the server again, use

vncserver -kill :1

Step 3

You will probably want to edit the ~/.vnc/xstartup file to control which applications and window manager are kicked off at startup. The default window manager is x-window-manager. I prefer Xfce4, which is lightweight and therefore good for running remotely. You can also use Gnome.

To specify, comment out the x-window-manager line and add a line for your preferred session:

xfce4-session &

Step 4

Finally, it's better to run the session through an SSH tunnel (rather than unencrypted on port 5901, as by default). Run this command on the client machine:

ssh -f -N -L 5901:localhost:5901 user@yourserver.co.uk

Then start your server on the remote machine:

vncserver :1

Step 5

Finally, use a VNC client (e.g. xvnc4viewer for Linux, or Chicken of the VNC for Mac) to connect to localhost on port 5901 (the SSH connection is set to forward local port 5901 to remote port 5901), using your VNC password. And you're in! Just remember to kill the VNC server and your ssh process once you're done.

Juliet Kemp has been messing around with Linux systems, for financial reward and otherwise, for about a decade. She is also the author of "Linux System Administration Recipes: A Problem-Solution Approach" (Apress, 2009).

Follow ServerWatch on Twitter

Page 1 of 1


Comment and Contribute

Your name/nickname

Your email

(Maximum characters: 1200). You have characters left.