The University of Arizona

Resources

Using VNC for X11 Applications

VNC from within CS or from home

You can use VNC (Virtual Network Computing) to access a virtual X11 desktop and open up X applications on Windows or Unix (Solaris or Linux) machines. VNC is part of most Linux distributions and is available for free in various implementations for Windows, (e.g., TightVNC, RealVNC, and UltraVNC) and Mac (e.g., Chicken of the VNC).  As with conventional X11 sessions, there are client and server components.  

  1. Use SSH Secure Shell or PuTTY to open a window to a Unix server such as lectura.
  2. On the Unix machine, run the command vncserver (/usr/bin/vncserver on lectura). The first time you run this, it will prompt you for a password and will create a ~/.vnc directory in your home area. The second time you run it, it will start and output a message something like: New 'lectura.cs.arizona.edu:n (username)', where n is a number. Make a note of this information, especially the number.
  3. On a Unix machine you can run vncviewer to access the desktop (usr/bin/vncviewer on lectura). This will prompt you for the vnc server (lectura.cs.arizona.edu:n), for the password you have set, and will open the virtual X11 desktop on your screen. You can customize the applications and/or the window manager that are started by editing the file ~/.vnc/xstartup.
  4. On a Windows machine, run the VNC viewer program. The Windows machines in the GS228 and GS930 labs have TightVNC installed under TightVNC on the start menu, so you would start TightVNC viewer. It will prompt you for the vnc server (lectura.cs.arizona.edu:n), for your password, and will open the virtual X11 desktop on your screen. This will look the same as it does using vncviewer on a Unix machine.
  5. To stop using the X session, logout of the session, then use 'vncserver -kill :n' (on the machine where you started vncserver) to stop the vncserver process.

Note: Since lectura is our main timesharing system, sessions are expected to be relatively short-lived. Therefore, VNC sessions on lectura will not be allowed to run for more than 7 days.

Setting the Window Manager

By default, VNC uses 'twm' as the window manager (i.e., GUI). You may wish to change this to 'startxfce4', 'gnome', or 'kde' ('startxfce4' is more lightweight than 'gnome' or 'kde' so it may work better with VNC). To change the windows manager, edit the file /home/yourusername/.vnc/xstartup. Replace the line

   twm &

with

   exec gnome-session   (for gnome)

or

   startkde &   (for kde)

For more information, search the web for "VNC window manager".

Tunneling VNC with SSH

There are some limitations with VNC.  From outside the department, we only allow a limited range of VNC port numbers (for security reasons).  And VNC is not the most secure program around.  Tunneling VNC sessions through SSH from outside the department is encouraged since SSH is very secure and a wide range of ports is available.



Tunnel VNC to lectura with PuTTY



Initial Setup

none

 

none

 

none

 

Using the Tunnel

VNC ports are relative to 5900.  If you run vncserver and it displays New 'lectura.cs.arizona.edu:5 (username), then vnc is listening on port 5905.  Since we selected a specific port for tunneling, we need to tell vncserver to use that port by specifying our port minus 5900 (e.g., 6961 - 5900 = 1061).

As above, to stop using the X session, logout of the session, then use

   vncserver -kill :n

(on lectura) to stop the vncserver process.

* If you start vncserver and see "A VNC server is already running as :nnnn", then you will need to go back to the PuTTY configuration and select a different port number and try again.



Tunnel VNC to another machine through lectura

 VNC is only allowed to certain machines in CS.  For machines that cannot be reached directly by VNC (e.g., those with private IP addresses), tunneling provides a method for access.

The following example shows how to set up a VNC tunnel through lectura to a fictitious machine foo

Initial Setup

none

 

none

 

none

 

Using the Tunnel

As above, we need to tell vncserver to use that port by specifying our port minus 5900 (e.g., 27231 - 5900 = 21331).

As above, to stop using the X session, logout of the session, then use 'vncserver -kill :n' (on foo) to stop the vncserver process.

Last updated August 19, 2011, by Tom Lowry
Send questions about this page to