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.
- Use SSH Secure Shell or PuTTY to open a window to a Unix server such as lectura.
- 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.
- 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.
- 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.
- 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
- Create a new session to lectura.cs.arizona.edu called lec_vnc_tunnel and click Save

- Expand the SSH Category and Enable X11 forwarding

- Set the tunnel details. Choose an arbitrary port > 6000 as the Source port. This needs to be unique, so the number chosen below (6961) is just an example. Set the destination to lectura.cs.arizona.edu:port number, then click Add

- Scroll back up to the Session Category, highlight lec_vnc_tunnel, and click Save
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).
- highlight the lec_vnc_tunnel session, click Load, then click Open (note: there may be a delay before seeing the "login as:" prompt)
- login to lectura as normal
- start the VNC server*
vncserver :1061 - run the VNC viewer (on your machine) specifying the VNC server as
localhost:6961 - you should be prompted for the VNC password; enter that and the X11 desktop should appear on your screen
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
- Create a new session to lectura.cs.arizona.edu called lec_foo_vnc_tunnel and click Save
- Expand the SSH Category and Enable X11 forwarding

- Set the tunnel details. Choose an arbitrary port > 6000 as the Source port. This needs to be unique, so the number chosen below (27231) is just an example. Set the destination to foo.cs.arizona.edu:port number, then click Add

- Scroll back up to the Session Category, highlight lec_foo_vnc_tunnel, and click Save
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).
- highlight the lec_foo_vnc_tunnel session, click Load, then click Open (note: there may be a delay before seeing the "login as:" prompt)
- login to lectura as normal
- login to foo from lectura
- start the VNC server (on foo)
vncserver:21331 - run the VNC viewer (on your machine) specifying the VNC server as
localhost:27231 - you should be prompted for the VNC password; enter that and the X11 desktop should appear on your screen
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