How to connect using VNC

Overview

VNC is a protocol that allows you to connect to a graphical desktop session on a remote machine. There are two parts to this:

  1. remote machine running the vnc session
  2. local machine that connects to the remote vnc session

Procedure

Here's how you can start a remote vncserver session (just as an example; your actual numbers might be slightly different):

  1. be connected to the McMaster VPN.

  2. create an ssh tunnel from localhost to remotehost
    ssh -L 5901:127.0.0.1:5901 username@remotehost (if your computer can't find the remotehost, you might have to use the full qualified domain name, usually in the form of remotehost.department.mcmaster.ca.

  3. In that same terminal session, check to see whether you already have a vncserver session running
    vncserver -list

    If a vnc session is already running, you'll see something like:
    TigerVNC server sessions:

    X DISPLAY # PROCESS ID
    :1 30602

    If a vnc session does not exist, the above output will not have the line that begins with :1 so you'll have to start a vnc session: vncserver

    You'll want to note down the desktop number. You might see something like the following:
    New 'remotehost:1 (username)' desktop is remotehost:1

  4. On your local machine, open your vnc client and then point the connection to: localhost:5901
    But that's only assuming your desktop was at remotehost:1. If it was at remotehost:3, you'd use port 5903.

  5. Your local machine should ask you for your vnc password (remember, this is not necessarily the same as your ssh password).

You should then be greeted with a desktop environment.


If vncserver is not recognized as a command on your remote machine, please send us a request to install it.

Add comment

You can add a comment by filling out the form below. Plain text formatting. Web and email addresses are transformed into clickable links. Comments are moderated.