Skip to content Skip to navigation

Using VNC

Introduction

UNIX/Linux applications with a graphical user interface require the use of special display software when connecting from a remote location. Two methods are currently supported: X-windows and VNC. See Using X-windows for information about X-windows.

VNC is a protocol and associated software that supports remote display on a variety of computer platforms. It is useful when certain applications fail to run properly under X-windows, or when a persistent connection to the remote display is required. You can disconnect from a VNC session and reconnect to it later as long as the terminal session used to start the VNC server application is still running.

The university maintains the necessary server application for use with Stanford FarmShare, but users must download and install a suitable client application; see below for recommendations. Because secure connections are required in the Stanford FarmShare environment, SSH must be used to encrypt the VNC connection. SSH does not have any special support for VNC so encryption must be accomplished manually using SSH port forwarding.

Before you begin

If you have never used VNC before you must set a VNC password before you start vncserver for the first time (see below). This password will control access to the display and will prevent a third-party from viewing or controlling your VNC session.

  1. Connect to any Stanford UNIX corn.
  2. Create a VNC application directory if one does not already exist:

    mkdir ~/.vnc
  3. Run the vncpasswd command to set a new password. This password is not very secure, so it should not be the same as your SUNet ID password (or other sensitive passwords).

Using VNC on Mac OS X

There are a number of freely available VNC clients for Mac OS X. The following instructions assume you are using Chicken (used to be called Chicken of the VNC, make sure you get the newer one) but should be adaptable to other software.

  1. Download and install Chicken
  2. Open a terminal session by launching the Terminal application (located in the Utilities subfolder of the Applications folder).
  3. Connect to any Stanford timeshare using the ssh command; for example:

    ssh sunetid@corn.stanford.edu
  4. Run the vncserver command to create a new display. Depending upon how many remote displays are already present on the current system, several warning messages may be displayed before vncserver reports that it has created a new one; take note of the host name and display number reported:

    New 'X' desktop is corn02.Stanford.EDU:3
  5. Launch Chicken and select New Server. The Host option should be the host name of ths system where vncserver is running, the Display option should be the display number reported, and the Password option should be your VNC password (not your SUNet ID password). Check the Tunnel over SSH box, enter the host name (again) for the SSH host, and click Connect:

    • Host: corn02.stanford.edu
    • Display or port: 3
    • Tunnel over SSH: (checked)
    • SSH host: sunetid@corn02.stanford.edu (replacing "sunetid" with your own SUNet ID)
  6. The corn desktop should be displayed in a new window. You can launch remote applications with a graphical user-interface using an xterm window in your VNC desktop.
  7. To end the session, quit all remote applications and close Chicken. Then, terminate the display by running vncserver with the -kill option; you must specify the display to terminate using a colon:

    vncserver -kill :3

    Type exit in your primary terminal session to close the SSH connection. Finally, return to your secondary terminal session and press CONTROL + C` to discontinue port forwarding. The standard prompt should now be displayed.

Using VNC on Windows

There are a number of freely available VNC clients for Windows, but SSVNC is recommended for most users. This client includes built-in support for SSH tunnelling of the VNC display, which streamlines the connection procedure. You must also have SecureCRT or another SSH client installed in order to establish a primary terminal session.

  1. Download and install SecureCRT and the Windows version of SSVNC.
  2. Open SecureCRT and connect to any Stanford corn.
  3. Run the vncserver command to create a new display. Depending upon how many remote displays are already present on the current system, several warning messages may be displayed before vncserver reports that it has created a new one; take note of the host name and display number reported:

    New 'X' desktop is corn02.Stanford.EDU:3
  4. Open ssvnc by double-clicking the sshvnc script (located in the Windows subdirectory of the ssvnc application directory).
  5. Use the following connection settings and then click Connect to establish a new session:
    • VNC Host:Display: The host should be localhost and the display should be set to the display number reported by vncserver; for the example above, use localhost:3.
    • Proxy/Gateway: The gateway should be set to the hostname of the specific corn to which you are connected, and you must specify your user name explicitly; for the example above the correct value would be: sunetid@corn02.stanford.edu.
    If prompted, store the remote host key by pressing y, and enter your SUNet ID password when required. ssvnc will prompt you for your VNC password once the SSH connection has been established.
  6. The desktop should be displayed in a new window. You can launch remote applications with a graphical user-interface using an `xterm` window in your VNC desktop.
  7. To end the session, quit all remote applications and close ssvnc. Then, terminate the display by running vncserver with the -kill option; you must specify the display to terminate using a colon:

    vncserver -kill :3

    Finally, return to SecureCRT and type exit to close the SSH connection.

Using VNC on UNIX/Linux

Some distributions of Linux include a VNC client as part of the default desktop configuration, but others are freely available. Check the standard software repositories for your distribution to determine the options.

  1. Open a new terminal session and connect to any Stanford corn using the ssh command; for example:

    ssh sunetid@corn.stanford.edu
  2. Run the vncserver command to create a new display. Depending upon how many remote displays are already present on the current system, several warning messages may be displayed before vncserver reports that it has created a new one; take note of the host name and display number reported:

    New 'X' desktop is corn02.Stanford.EDU:3
  3. You must now configure port forwarding for this display.
    • Open a second terminal session.
    • The local port is always 5900, but the remote port number is determined by adding 5900 to the reported display number. In the example above, the port number is 5903. Forward the port using ssh as follows; note that the local port is specified first, the remote port last, and that you must connect to the particular host used to start vncserver:

      ssh -NCTL5900:localhost:5903 sunetid@corn02.stanford.edu
       
    • Note that the SSH program will run, but not redisplay the prompt. You can return to your primary terminal session, already connected.
  4. Launch VNC. When connecting, the host should be localhost and the display (or port number) should be 0 (or 5900). Connect and specify your VNC password (not your SUNet ID password) when prompted.
  5. The timeshare desktop should be displayed in a new window. You can launch remote applications with a graphical user-interface using an xterm window in your VNC desktop.
  6. To end the session, quit all remote applications and close VNC. Then, terminate the display by running vncserver with the -kill option; you must specify the display to terminate using a colon:

    vncserver -kill :3

    Type exit in your primary terminal session to close the SSH connection. Finally, return to your secondary terminal session and press CONTROL + C` to discontinue port forwarding. The standard prompt should now be displayed.
Last modified November 27, 2012