Remote Desktop (VNC) with SSH Tunnel

Starting a VNC session with an SSH tunnel

On Mac, you will need the TurboVNC Viewer client (https://sourceforge.net/projects/turbovnc/)

On Windows, you will need the TurboVNC Viewer client (https://sourceforge.net/projects/turbovnc/) and PuTTY (https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html)

Quick overview using server nc4:

1. ssh as usual into username@nc4.ucsd.edu

2. Set up your preferred virtual desktop number (e.g., call vncserver :22)

3. tunnel in using the port number 5900 + your virtual desktop number, e.g., ssh -L 5922:localhost:5922 username@nc4.ucsd.edu

4. connect to localhost:desktopNumber (e.g., localhost:22) in the GUI

Detailed Instructions:

Starting the VNC server

Connect to the remote server using SSH and then start your VNC server with a specific session ID, for example using ID# 15:

vncserver :15

The resolution of the VNC desktop could also be specified in the 'vncserver' command. For example:

vncserver -geometry 1600x1200 :15  

On the first time that you run the vncserver command, you will be prompted to enter a VNC password to secure your VNC session. This password can be set to any strong password as desired.

The output of the vncserver command is important: it tells you where to point your client to access your desktop in format remoteServer:displayNumber

Desktop 'TurboVNC: remoteServer:15 (sscf-silas)' started on display remoteServer:15

Creating an SSH tunnel

The VNC <port> is 5900 + the virtual display number. In my example, 5900 + 15 = 5915.

On Mac, use Terminal to create the SSH tunnel by following this format:

ssh -L <port>:localhost:<port> <username>@<server name>.ucsd.edu

Using the above example, the command would be:

ssh -L 5915:localhost:5915 sscf-silas@remoteServer.ucsd.edu

On Windows, open PuTTY. For hostname, enter: remoteServer.ucsd.edu

Navigate to Connection->SSH->Tunnels

Source port: <port>

Destination: localhost:<port>

Using the above example, the source port would be 5915 and the destination would be localhost:5915

Connecting to VNC desktop session

Open the TurboVNC Viewer client, and connect to localhost:<displayNumber>. The TurboVNC viewer client will prompt you for your VNC password.

To end your VNC session, you can kill the desktop by using this command with the session ID:

vncserver -kill :15