# Setting Up VNC Session

(Difference between revisions)

Virtual Network Computing (VNC) is a cross-platform desktop sharing system to interact with remote system's desktop using a graphical environment. This page covers basic instructions to access Cheaha using VNC. These basic instructions should be helpful for many use cases. If you are interested in knowing more options or detailed technical information, then please take a look at man pages of specified commands.

## One Time Setup

Follow these instructions on Cheaha to configure VNC server for the first time. You can directly run a vncserver command to start a VNC session with default options, however, commands listed below will help you to get started quickly with Gnome desktop environment.

• Create a password for your VNC server sessions using vncpasswd command. It stores an obfuscated version of the password in the given file (default $HOME/.vnc/passwd). Remember this password as you will be prompted for it when you try accessing the VNC session later. The password is validated each time a connection comes in, so it can be changed on the fly using vncpasswd command anytime later. $ vncpasswd

• By default a VNC server displays graphical environment using a tab-window-manager. Since we want to use a normal dekstop environment (default: Gnome on Cheaha), we need to add following settings to ~/.vnc/xstartup file. If this xstartup file is absent, then a file with default tab-window-manager settings will be created by the vncserver command during startup.
$cat >$HOME/.vnc/xstartup <<\EOF
#!/bin/sh

# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc

EOF

$chmod +x$HOME/.vnc/xstartup


This completes one-time setup in which we set up VNC server password and display environment options. In the following section we will take a look at commands to start a VNC server.

## Starting a VNC server

A VNC server can be started using vncserver command on Cheaha.

$vncserver New 'cheaha.uabgrid.uab.edu:24 (pavgi)' desktop is cheaha.uabgrid.uab.edu:24 Starting applications specified in /home/pavgi/.vnc/xstartup Log file is /home/pavgi/.vnc/cheaha.uabgrid.uab.edu:24.log  The above command output indicates that a VNC server is started on VNC port 24 which is system port 5924. The actual system port on which VNC server is listening for connections is obtained by adding a VNC base port (default 5900) and a VNC server port (24 in above case). Alternatively you can specify a high numbered system port directly (e.g. 5927) using '-rfbport <port-number>' option and the vnc server will try to use it if it's available. See vncserver's man page for details. ## Connecting to VNC server • As shown in above example, a VNC server starts listening on a higher numbered port which isn't directly accessible from the internet. Hence, we need to use SSH local port forwarding to connect to this server. On Linux or Mac systems we can setup SSH port forwarding as shown below. # ssh -L <local-port>:<remote-system-host>:<remote-system-port> USERID@<SSH-server-host>$ ssh -L 5924:localhost:5924 USERID@cheaha.uabgrid.uab.edu


Above command will forward connections on local port 5924 to a remote system's (same as SSH server host Cheaha - hence localhost) port 5924. Following is an example configuration using Putty client on Windows.

• Once we have a local port available for connection, we can access the VNC server using a VNC client. Following is a list of VNC client softwares and you can any one of it to access VNC server.
* http://www.tightvnc.com/ (Mac, Linux and Windows)
* http://www.realvnc.com/ (Mac, Linux and Windows)
* http://sourceforge.net/projects/cotvnc/ (Mac)


Note, Mac OS comes with a native VNC client support and hence you don't need to use any third-party software. On Linux systems you can use vncviewer command to access a VNC server. If you using Windows OS then you will need to install one of the supported VNC client as mentioned above. Once we have a VNC client installed, we can access VNC server using following connection string:

# vnc://<vnc-server>:<vnc-port>
vnc://localhost:5924


Since we are using SSH local port forwarding to access our VNC server, our VNC connection string will look as shown above.

Once we have a VNC session established with Gnome desktop environment, we can use it to launch any graphical application on the Cheaha or use it to open GUI (X11) supported SSH session with a remote system. The later use case is particularly useful when we are trying to open a GUI session with the remote system from Windows OS, as native X11 setup on Windows is difficult than above VNC setup. For example, it's much easier to start X11 based SSH session with the remote system from above Gnome desktop environment than doing all X11 setup on Windows.


$ssh -X$USER@172.x.x.x