Remote Desktop with TurboVNC
Table of Contents
1 Setting
This assumes two machines:
- the remote machine, called
remote
here, where you run the VNC server. - the local machine, called
local
here, where you run the VNC client.
To make the presentation more concrete we discuss the case where you want to connect from a Mac OS X laptop (local
) to a Linux desktop (remote
).
The OS and user names on remote
and local
are given in Table 1.
machine name | OS | user name |
---|---|---|
remote |
Linux | jsmith |
local |
Max OS X | john |
There are two VNC servers available on our Linux workstations: TigerVNC and TurboVNC. The main difference is that TigerVNC let's you resize the window at any time; with TurboVNC the size of the window is fixed at the time the VNC server is fixed. But TurboVNC offers better performance in 3D graphics. This comes from using VirtualGL which adds hardware accelerated OpenGL to TurboVNC.
2 Starting the VNC server on remote
Connect to remote
with ssh:
$ ssh -Y jsmith@remote.princeton.edu
Before you can start a TurboVNC server, you first need load the environment module
$ module load turbovnc
Then the vcnserver is started with the command
$ vncserver
The first time you run vncserver
on the remote machine, it will ask you to set up a password. You should pick a different password from your netid one. The VNC password encryption is weak. When asked "Would you like to enter a view-only password (y/n)?" say no.
Once the vncserver is started it will give you a message similar to this one:
Desktop 'TurboVNC: remote:N (jsmith)' started on display remote:N Creating default startup script /home/jsmith/.vnc/xstartup.turbovnc Starting applications specified in /home/jsmith/.vnc/xstartup.turbovnc Log file is /home/jsmith/.vnc/remote:N.log
N
should be an actual number. This is the display number. The vncserver assigns the display numbers incrementally starting at 1.
3 Starting the VNC client on local
and connecting to the server on remote
3.1 Installing TurboVNC viewer
You need to install the TurboVNC viewer on your local machine. Follow the steps in Obtaining and Installing TurboVNC.
3.2 Ssh port forwarding
To connect to the remote VNC server you first need to establish a connection between local
and remote
by using the port forwarding feature of ssh. The port number that you need to forward is computed as
PORT = 5900 + N
where N
is the display port that was assigned to you when you started the server in Starting the VNC server on remote
.
The command for port forwarding with ssh is
$ ssh -LPORT:localhost:PORT jsmith@remote.princeton.edu
As an example if the display port N=2
, then the the port number is PORT=5902
and the ssh command is
$ ssh -L5902:localhost:5902 jsmith@remote.princeton.edu
3.3 Launching TurboVNC viewer and connecting to the server
On Mac OS, to launch the TurboVNC viewer, you can either go to the Application menu or launch it from a terminal with
$ open -a TurboVNC\ Viewer
Then a window similar to 1 should pop up.
Figure 1: TurboVNC viewer connection applet.
To connect to the server you need to enter localhost:N
where N
is the display number, in the "VNC server:" box. The figure 1 shows an example for N=2
. A window similar to the one in figure 2.
Figure 2: TurboVNC remote desktop.
4 Running graphical applications in VNC
To run graphical applications in the VNC desktop, you need to prefix the executable of you application with vglrun
.
For instance, to run paraview
, assuming paraview
is in your path, run
$ vglrun paraview
For Matlab
$ vglrun matlab
5 Quitting the VNC client and server
To disconnect the VNC client from the server you simply close the VNC window.
The vncserver will still be running on remote
. This means that you can start working at one place, disconnect, and reconnect from somewhere else and your windows on the remote server are still open.
But the vncserver does use resources so once you are done with your work please kill the vncserver running on the remote machine. To do so, simply log onto remote
and enter
$ module load turbovnc $ vncserver -kill :N
where again N
is the display number. Don't forget the ":" in front of N
.
In case you forgot your display number, you can list all your running vncservers with
$ vncserver -list
Note that you only have to load the turbovnc module once for each ssh session, or you can add
$ module load turbovnc
to your .bashrc
.
6 Changing the size of the remote desktop
With TurboVNC the size of the desktop is fixed at the time the server is started. But you can specify a size at startup with the -geometry
option, for instance
$ vncserver -geometry 1280x800
will give you a remote desktop with a resolution of 1280x800
.
7 Changing your VNC password
To change your vnc password simply use
$ vncpasswd
on the remote host.
8 TigerVNC
The steps for using TigerVNC instead of TurboVNC are the same as the ones for TurboVNC. The only differences are that you don't load the turbovnc environment module before starting the vncserver and, of course, you need a TigerVNC client installed on the local machine.