VNCSetup

Setting up a VNC server session on a Linux/UNIX host

VNC is a remote computer display system. For more background see http://en.wikipedia.org/wiki/VNC

 

Setup your VNC server process

  1. Login to the system which will host the vnc server process
  2. Set a password for your vnc desktop using the command vncpasswd. Note the is seperate from your standard login password.
  3. Edit you vnc startup file, which is ~/.vnc/xstartup. By default the very simple window manager "twm" will be started. You may which to replace twm with startkde or startxfce4 for a richer desktop.
  4. You can start the vnc server process with the command vncserver. This will return the hostname and display number, such as login1:1. The default desktop size will be 1024x768. To create a different size, use the option -geometry widthxheight.

 

Connecting via a ssh tunnel

  1. For security, we want to encrypt all VNC traffic through an ssh tunnel. To setup the tunnel from a UNIX or Mac OS X client, use a command such as ssh -C -L 5901:localhost:5901 username@host in a terminal window.
  • For example, if the hostname and display returned from vncserver were login1:1, then the command would be

 

ssh -C -L 5901:localhost:5901 username@login1.phy.duke.edu

.

  • If the display number is greater than one, you will need to increament the second port number. For example, if the hostname and display returned from vncserver were login1:2, then the command would be

 

ssh -C -L 5901:localhost:5902 username@login1.phy.duke.edu

.

  • This will prompt you for your login password.
  1. Now start a VNC client on your local computer and connect to localhost:1. This will forward the VNC connection through the ssh tunnel and connect to the VNC session on the remote host.
  • From a UNIX client, just enter vncviewer localhost:1. This will prompt you for the VNC password.
  • From a Mac OS X client using "Chicken of the VNC" select "Host:" as localhost and "Display:" as 1 and enter your VNC password in the password field.

 

SSH tunnel on a Windows PC

Please try SSVNC which is a simple Tunneling client and VNC viewer.

ssvnc-01.png

This is SSVNC on Windows connecting as user jdorff to host login2 on VNC port 5

ssvnc-03.png

After connecting, there is a terminal window prompt for the login password, then a GUI prompt for the VNC password.

 

Disconnecting the session

  • To disconnect, first exit your VNC client then exit the ssh shell which is doing the port forwarding. Note that the state of processes running on the VNC desktop will not be changed. This make VNC ideal for long running processes.

 

Stopping the VNC server process

  • To stop the VNC server process, login to the host which is running the VNC server and use the command vncserver -kill :X where X is the display number.