Operations > Computing > FAQ

Unix VNC Sessions

VNC allows graphical programs (e.g. MATLAB, CAD software, etc.) to be run remotely with the ability to reconnect to that session should the network connection fail. The EE linux lab systems and other systems in the department should have VNC software installed; VNC clients are available for many platforms; clients that integrate SSH support are especially nice, for example Chicken on Mac OS X or the TightVNC Java Viewer.

Another option is to use Xming to run X11 applications.

Start a VNC Session

  1. Connect to an EE unix system using a SSH client. For the Linux Lab systems, it is best to use linux12 through linux26.
  2. Run vncserver -list to see what sessions have been started.
  3. If none have been started, launch a new server with the following command:
    vncserver -interface
    This binds to the loopback interface, which will prevent users on other systems from connecting to the server. Connections to this server must be made over SSH. The first time, a password will be asked for; this password will prevent other users on the same system from accessing your session. Using a long random string and then storing that string in a password safe program (e.g. Keychain on Mac OS X or Password Safe) may be ideal.
  4. Now the -list command should show a session:
    linux13$ vncserver -list
    TigerVNC server sessions:
    :1		5528
  5. Use the lsof command to show the port number the process is listening on, in this case 5901. The port number may vary if other sessions exist. The port can be manually specified via the -rfbport option to vncserver when starting the session, though this may fail if some other process is using that port.
    linux13$ /usr/sbin/lsof -i -P | grep vnc | grep localhost
    Xvnc 7131 nemo   6u IPv4 594464   0t0  TCP localhost:5901

Connect to VNC Session

The VNC client will need to connect to localhost at the correct port, in this case 5901. The SSH host should be the server that the VNC server was started on. If the VNC client lacks SSH support, a SSH tunnel will need to be setup first (see below).

On Windows or Linux, use the TightVNC Java Viewer. This requires JavaSE to be installed.

SSH Port Forwarding

If your VNC client lacks SSH tunneling support, a SSH tunnel will need to be established between the client and server system. This tunnel opens a port on the loopback interface of the client system, and forwards it to the loopback port that the VNC server is listening on on the remote server. The exact configuration will vary by SSH client; on the command line, the -L argument to OpenSSH will create a tunnel.

ssh -L 1234:localhost:5901 linux13.ee.washington.edu

Once the SSH connection is established, a VNC session should be opened to port 1234 on localhost (of the client), which SSH will forward to port 5901 on localhost (of the server).

$ java -jar TightVncViewer.jar HOST localhost PORT 1234
Connecting to localhost, port 1234...
Connected to server
RFB server supports protocol version 3.8
Using RFB protocol version 3.8
Performing standard VNC authentication
(and so forth)

To use the built-in SSH forwarding of TightVncViewer, no prior SSH connection would be necessary, and the VNC viewer would be launched with the following arguments.

java -jar TightVncViewer.jar \
  SOCKETFACTORY com.tightvnc.vncviewer.SshTunneledSocketFactory \
  SSHHOST linux13.ee.washington.edu HOST localhost PORT 5901

Cleanup VNC Sessions

Use the vncserver -list command and then vncserver -kill command to quit any sessions that need not remain open.

linux13$ vncserver -list

TigerVNC server sessions:

:1		7131
linux13$ vncserver -kill :1
Killing Xvnc process ID 7131
EE logo