Connecting to the Linux GUI Remotely

It is possible to log in to the Ubuntu Linux Graphical User Interface from a remote workstation or laptop. This Note tells you how to tunnel VNC connections to a Linux system in Cardiff School of Computer Science & Informatics.

When you sit in front of a Linux workstation, you are presented with a graphical login screen. Log in and you enter the Mate Graphical User Interface (GUI) desktop.

It's possible to connect to the GUI desktop from a remote location, for example a from PC or laptop in Halls or at home or elsewhere on the Internet (or even from a PC in another part of the University). The graphical login process on the Ubuntu 16.04 LTS Linux systems in the School of Computer Science & Informatics is configured to allow VNC connections.

The connection is protected by a firewall. In order to connect, you will need to direct VNC through an SSH tunnel.

VNC

VNC (Virtual Network Computing) allows you to view a GUI desktop environment from anywhere on the Internet. It is available for many different computer platforms. There are two parts to any VNC connection, the VNC server on the host system, and the VNC client on your laptop or personal workstation.

A VNC server is configured on Ubuntu Linux system lapis.cs.cf.ac.uk. It connects the client to the Mate graphical login screen.

VNC viewer clients are available for Windows, Linux and Macintosh workstations. For Windows you can install the free client from RealVNC at https://www.realvnc.com/download/viewer/. Clients from other suppliers can also be found on the Web.

Linux systems use a vncviewer client. Fedora has the vncviewer client from RealVNC, for Ubuntu there's xvnc4viewer. Install the appropriate package from your Linux repository.

A good free client for Macintoshes is Chicken of the VNC from http://sourceforge.net/projects/cotvnc/.

Secure Shell Applications

In order to make a VNC connection to lapis, you will need a secure shell client program on your computer. This is needed to create a tunnel from your local system to lapis. For Linux and Macintosh systems, you can use the ssh command that comes with the system. For Windows, you will need an additional program like plink which is available from the suppliers of PuTty. Go to http://www.putty.org/ for a link to the PuTty download site.

Using an SSH Tunnel

To use VNC to connect to lapis, you must create an SSH tunnel from your workstation to lapis.

Set up the SSH tunnel from your workstation to lapis such that:

  • The tunnel's entrance listens for VNC connections on your own workstation;
  • The tunnel encrypts the VNC traffic and sends it to the School's Linux server lapis;
  • The tunnel's exit decrypts the traffic and connects to the VNC server on lapis.

You can now connect your VNC viewer client to the opening of the tunnel on your local host. The tunnel will then connect you transparently to the VNC service on the remote host, lapis.

Connecting from Windows

Open a Command (cmd) Window, and change to the directory where you have installed plink.exe.

Set up an SSH tunnel with the command:

plink -N -L 5900:localhost:5900 cxxxxxx@lapis.cs.cf.ac.uk

where cxxxxxx is your username (in lower case!). Do not terminate the cmd window until you have finished using the tunnel.

Note, you may have configured a VNC server on your own PC when you installed RealVNC. If a local server is running, it is listening on port 5900, so the SSH tunnel will fail because it cannot connect its own entrance to port 5900 on your PC so you will need to amend the configuration of RealVNC to turn off the local server.

Once the tunnel is established, start the VNC client from its icon or from the Start menu.

In the connection panel, specify :0 as the server. This will connect VNC to the tunnel on the local machine and so to desktop 0 on lapis.

Connecting from Linux

The vncviewer command on Linux can be told to send VNC via an SSH tunnel. Use the -via flag to set up the tunnel. There is no need to call SSH explicitly, vncviewer does this for you. In a terminal window, type:

vncviewer -via cxxxxxx@lapis.cs.cf.ac.uk :0

where cxxxxxx is your user name. This will connect the viewer to the GUI login screen on lapis.

Connecting from Macintoshes

Set up an SSH tunnel from a Terminal window.

ssh -N -L 5900:localhost:5900 cxxxxxx@lapis.cs.cf.ac.uk

where cxxxxxx is your username.

Now start Chicken of the VNC and connect it to desktop 0 on localhost.