How to use VNC

From CCM
Jump to: navigation, search


The idea of a VNC connection is that a client connects to a server installed in a remote computer. Then, the client receives a duplicate of the remote computer's display screen from the server. This is really useful when an interactive connection to a remote computer is needed.

ALT TEXT


For instance, if you have a connection to a cluster via SSH and you need to download some data from a web page where a manual installation is needed, a VNC connection is the best solution for you.

RealVNC is one of the most useful and complete platforms to perform a VNC connection as one can see in this comparison. It has an open version which is all you need for non-commercial interactive connections, as well as, some other options paying the commercial version.

Install VNC Server in a remote machine

In order to install a VNC Server in a cluster machine, you need to have an SSH connection to the cluster. For instance, if you want to install a VNC Server in colibri, the steps are the following:

1) A first SSH connection to colibri or the cluster machine where the VNC Server is going to be installed:

ssh username@colibri.ucdenver.edu 

2) Find the URL from where to download the Real VNC Connect

In the case of colibri, the URL is https://www.realvnc.com/download/file/vnc.files/VNC-Server-6.3.2-Linux-x86-ANY.tar.gz.

3) Install Real VNC Connect using the previous URL

Type in the terminal

wget previous_URL

In the case of colibri, type in the terminal

wget https://www.realvnc.com/download/file/vnc.files/VNC-Server-6.3.2-Linux-x86-ANY.tar.gz

This downloads a TAR file. In the case of colibri the file is VNC-Server-6.3.2-Linux-x86-ANY.tar.gz.

3) Untar the file using tar command

In the case of colibri

tar -xvf VNC-Server-6.3.2-Linux-x86-ANY.tar.gz -C .

This creates a directory named after the TAR file with all the server installation inside. In the case of colibri the folder is called VNC-Server-6.3.2-Linux-x86.

Instead of . one can specify a directory where to install the VNC Server.

4) Run VNC Server to be visible for the VNC Viewer

  • Go inside the directory with all the server installation.
  • Run vncserver.

In the case of colibri

cd VNC-Server-6.3.2-Linux-x86 
vncserver 

And this will show in the terminal the next message

New 'colibri.ucdenver.pvt:x (username)' desktop is colibri.ucdenver.pvt:x


Starting applications specified in /export/share_home/username/.vnc/xstartup

Log file is /export/share_home/username/.vnc/colibri.ucdenver.pvt:x.log

This creates a background server desktop connection colibri.ucdenver.pvt:x where x is any number assigned. Normally starting by 1 and so on.

5) Now you are prepared to connect to the server.

Connect to a VNC Server using VNC Viewer

1) Download and install VNC Viewer in your local machine from

https://www.realvnc.com/en/connect/download/viewer

depending on your local Operating System.

2) Start a new connection and specify the VNC Server as the previous server desktop.

In the colibri case is

colibri.ucdenver.pvt:x

where x is the number of desktop.

3) Introduce your password in colibri or the remote machine.

4) Enjoy your interactive connection to colibri or the remote machine!

Connecting to a VNC server using VNC Viewer by SSH tunnel

In some cases, one may desire to establish a VNC session with a server outside of the UC Denver VPN. The following example will show how to create a desktop environment on the Cheyenne supercomputer owned by NCAR. Such computers often have VNC server available so that installation of the server software as shown above is not necessary. To determine if the remote computer already supports a VNC server, when logged in, one may type:

which vncserver

If no output is returned, then a VNC server will need to be installed by following the steps above, then one may continue with the following steps.

1) Determine on which node you wish to run the VNC server. Large computers often have many login nodes which are assigned randomly. By specifying which node to logon to, the process of using VNC will be simplified. If one has no preference of node, then letting the system decide which node to use can make sense. For Cheyenne, one could begin by logging into a random node with

ssh username@cheyenne.ucar.edu 

After supplying a password or other login credential one might see the command prompt

cheyenne1 home/username>

indicating username has been logged into the cheyenne1 node.

2) Test that VNC server sotware can run on this node. At the command prompt, type

vncserver

and observe the output.

New 'cheyenne1:2 (username)' desktop is cheyenne1:x
Starting applications specified in /glade/u/home/username/.vnc/
Log file is /glade/u/home/username/.vnc/cheyenne1:x.log

Here, x is an integer which is actually a shorthand for the port number being used by the connection. Thus x stands for 590x. This number will be important later on. With the ability run vncserver, established, one can terminate the vncserver with the command:

vncserver -kill :x

Log out of the session on the remote computer with exit

3) Establish an ssh tunnel to the server computer and start the VNC server.

We now want to establish an ssh connection to the chosen node (cheyenne1) on the remote server with the following

ssh -L 590x:127.0.0.1:590x username@cheyenne1.ucar.edu

Again, x is the number described above. The preceding command is length so it makes sense to put an alias for it in one's ~/.bashrc file.

With the ssh connection to remote computer established, the VNC can be started with

vncserver :x

4) Connect to the remote server with the VNC viewer

A connection to the remote server can be made as shown above, except that the VNC server to connect to will now have the address

127.0.0.1:590x

This desktop session will continue to run even if the current ssh session is interrupted somehow and can be resumed from step 3).

5) Maintenance, tips, troubleshooting, etc

a) If VNC sessions with many different servers are used, it makes sense to use a different port number x, even if the connections will never be used at the same time.

b) If something goes wrong, it is often necessary to terminate the vncserver application. Somtimes this must be done manually. To find the process to send the kill signal, type

pidof Xvnc





Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox