Search Contact information
University of Cambridge Home Department of Engineering
University of Cambridge >  Engineering Department >  computing help

Remote access to CUED using VNC

Contents

VNC lets you run a CUED desktop and see the results on a machine elsewhere. You can use the VNC commands (vncserver, etc) from the command line or use a friendlier program (see the Program-specific details section) that runs the lower-level programs for you. You may have trouble the first time you try to connect because it's easy to go wrong, but after that you can save your configuration, making subsequent connections easier.

How to do it - the basics

This is what you do if you're user abc123 and you have the basic software installed.

Customising

You can make this sequence shorter by customising your software, but the details depend on the programs you're using

When vncserver starts, it runs the commands in your ~/.vnc/xstartup file. You can customise this. If you put just this into the file

gnome-session

vncserver -kill $DISPLAY

(and ensure the file is executable) you'll get your usual desktop. The last line is so that when you logout out of the session, vncserver exits also.

You might also want to control the initial size of the desktop. Typing

       vncserver -geometry 1024x768

should give you a vncviewer session that fits on your desktop comfortably.

The first time you try this something is bound to go wrong. Mostly likely the cause will be a typing error, or commands done in the wrong order, but eventually you may need to know more about what's going on behind the scenes. The rest of the document attempts to explain ports, tunneling and passwords, starting with a simplified scenario and eventually reaching the CUED scenario.

How it works

Many things can go wrong. Before reading the Troubleshooting section it's worth knowing a few technical details

So the following set-up is possible.

This is easy to do but there's a problem with it. Because everything you see and type passes between these 2 programs, the connection needs to be secure, otherwise snoopers could get your passwords. ssh ("secure shell") provides secure connections between machines. Don't use VNC without it. ssh uses port 22. Commercial versions of VNC have ssh integrated in. To combine ssh and VNC you'll need to use tunneling.

Tunneling (Port-forwarding)

Tunneling is when traffic for one port travels via another port. ssh has port-forwarding options. For example, this is possible

  ssh -L 5901:localhost:5901 -N -f abc123@remote_machine.eng.cam.ac.uk
where

You'll get the following

More complications

Unfortunately, life's not that simple

Troubleshooting VNC

Lots can go wrong - the installed software can be faulty; the networking and firewalls can block communications; you might get mixed up with passwords; and it's easy to make typing errors. So first try the following simple scenario - it will check to see whether you're using the right passwords and show you what to expect when things do work. First just try things out on the local machine.

If that works, your password and xstartup file are ok. Kill the viewer and run

vncserver -kill :4

to kill the server. Now try to use a remote machine that's within CUED.

If that works, you're ready to try accessing the CUED machines from outside CUED.

Other Pages

These page have more specialised information

Mac

Windows/Vista

Port forwarding

General

Technical Background

VNC essentially keeps copying screendumps over from a virtual screen on the remote machine to the screen you're sat at. It does this efficiently, so that only modified areas of the screen are copied over. An extra program needs to run on the distant machine and on the local machine, but these needn't be too complex. Because VNC only deals with the end product - the graphics - it doesn't care how the graphics are produced. Some kinds of graphics will produce more network traffic with X11 than with VNC, and some less. According to VNC over SSH2 - A TightVNC Tutorial "Compared to running X over SSH, TightVNC uses more CPU resources on the server side; however, it uses less bandwidth in the remote Desktop Environment tests that were conducted."

VNC is stateless - you can disconnect from a server and reconnect from another machine to continue the session.

Getting the Software

Using Krdc

Krdc is a Linux program to help with remote access.

Using Terminal Server Client

This program, available on Linux, can save you some typing.

Using Chicken of the VNC

Using Putty

The references in the Windows/Vista include general instructions.

Avoiding VNC

One alternative is to do the following - if you're running X windows on your machine (Xwin32/XMing on Windows, or X on MacOS) from your machine, and your ID is abc123 do

    slogin -X abc123@gate.eng.cam.ac.uk  

then from gate do

    slogin -X ts-access

On ts-access you can now type a program's name (e.g. xclock &) and have the display appearing on your machine. This is safe, but it won't be fast (try Matlab for an example). Also you won't be able to enjoy the full CUED desktop experience. But it's easy (especially from a Mac - you might not need to install anything) and might be all you want.

© Cambridge University Engineering Dept
Information provided by Tim Love (tpl)
Last updated: October 2010