VNC access to Linux machines from your Mac

VNC - Virtual Network Computing - permits you to set up a persistent graphical 'console' on one of the shared Linux machines, which can be left running while you are away from ARC, and reconnected to as needed provided you have an SSH connection.

Setup

IconFirst you need to install a VNC viewer package on OS X. I recommend JollysFastVNC since it includes SSH tunnelling support, freeing you from having to understand the details of SSH. You also need to have an SSH keypair configured so that you can SSH from your Mac to the Linux system without entering a password, as we don't allow password-only logons to the Linux systems - ask Ian or Robert to help you set this up.

On the Linux side, you need to do a few one-off setup tasks. SSH to the Linux machine and...

  • run vncpasswd to set a password on your VNC session. Your VNC session will be protected via SSH, but this stops a local user on the Linux machine from taking over your session. Do not use your login password for this! You can opt to not set a view-only password when prompted.
  • create a file called ~/.vnc/xstartup containing the following lines:
    #!/bin/sh
    /usr/bin/startkde
    killall -9 Xvnc
    rm -rf /tmp/.X*-lock
  • make the file executable by running chmod +x ~/.vnc/xstartup
you may, if you wish, simply make a copy of a template file by running cp /software/local/etc/xstartup ~/.vnc/

Note that the last two lines may not be suitable if you expect to run more than one VNC session at a time - consult Robert or Ian for such advanced cases.

Running...

To setup a VNC session once you have followed the setup tasks above it's pretty simple to set up a VNC session. From your Mac, open a Terminal and run ssh you@tpol.pst.qub.ac.uk vncserver. You should see something like this:

eve > ssh rsir@tpol.pst.qub.ac.uk vncserver
New 'X' desktop is tpol.pst.qub.ac.uk:1
Starting applications specified in /home/rsir/.vnc/xstartup
Log file is /home/rsir/.vnc/tpol.pst.qub.ac.uk:1.log

Of particular interest is the number of the desktop - in this case, 1. If other users have sessions running this will be higher as their sessions will be running on virtual screens 1, 2, 3 etc.

Now launch JollysFastVNC, and click the plus button in the bottom left corner to add a new session. Give the session an appropriate name, and set the following options:

  • Network address - tpol.pst.qub.ac.uk
  • Port/Display - set this to 5900 + your screen number - so 5901 for the example above
  • Security Type - SSH
  • SSH Options - if your username on the Mac is not the same as on the Linux machine, set this to -l linuxusername - replacing linuxusername as appropriate
You can save the details once initially set up so you won't have to alter most details in the future, though the display number may well change. Then simply press connect. You will be prompted for your VNC password - you can store this so you are not prompted again - and then your Linux KDE desktop will appear.

If you need to leave the KDE session for a while, but do not wish to entirely log out, then simply quit the VNC viewer, and reconnect later. All will be as you left it. When finished with your VNC session, simply opt to log out as usual.

Last updated Thursday August 20, 2009