Longwood University Department of Computer Science Advanced Computing Lab

12 Feb 2014

What is VNC

The simplest way to connect to the machines in the lab from your comptuer at home is to use SSH as described here. SSH is a simple, fast, and secure way to access your account. However, when you need to run a graphical program (such as firefox) remotely, forwarding graphics over SSH can be slow and frustrating. A solution is to use VNC (Virtual Network Computing) to forward graphics over the network instead of X11 forwarding. VNC uses compression and a more streamlined communication algorithm to make accessing graphical applications efficient.

These instructions assume that you have created a .config file in your .ssh folder that allows you to use SSH forwarding to connect directly to workstations as described on the Remote Login page.

Starting the VNC server

The workstations in the lab have non-routeable IP addresses, which means they aren't visible to the outside world. That means that you can't connect directly to a VNC server running on a workstation. Instead, we can use SSH tunneling (which also has some security advantages).

To establish a tunnel, connect to your workstation like this:

ssh frodo -L 8900/localhost/5901

replacing "frodo" with the name of the workstation you want to access.

Now you can launch a vncserver by typing:

vncserver -localhost

The first time you run this command, you will be prompted for a password. You can type in anything you will remember. If necessary, you can change the password by typing

vncpasswd

After it launches, the vncserver program should print out a "desktop identifier" which will look something like "frodo:1" and give you back your command prompt. Remember this identifier. You will need it later to shut down the VNC server.

Connecting to the server

To connect to your server, open up a new terminal on your system and type:

vncviewer localhost::8900

This will pull up a remote desktop window which you can use to do your work.

Logging out

To log out, you can simply cloes the viewer window. However, your login session will stay active. If you run the vncviewer command again, your programs will still be running.

It is good etiquette not to leave a vncserver running when you aren't actively using it. To stop the server, switch back to your ssh window and type:

vncserver -kill :1

replacing :1 with the appropriate desktop identifier you were given when you launched VNC. If you have forgotten the desktop identifier you can type:

vncserver -list

to see it again.

Selecting a desktop environment

By default, vnc uses the twm window manage, which is very light-weight (i.e. fast) but rather awkward to use. If you would like to use a more familiar environment (such as KDE or xfce), you can modify the file .vnc/xstartup under your home directory.

KDE

Replace the .vnc/xstartup file with:

#!/usr/bin/sh
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS

exec startkde

xfce

Replace the .vnc/xstartup file with:

#!/usr/bin/sh
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS

exec startxfce4