Skip to content
Snippets Groups Projects
vnc.md 8.08 KiB
Newer Older
Lukáš Krupčík's avatar
Lukáš Krupčík committed
# VNC
Lukáš Krupčík's avatar
Lukáš Krupčík committed

The **Virtual Network Computing** (**VNC**) is a graphical [desktop sharing](http://en.wikipedia.org/wiki/Desktop_sharing "Desktop sharing") system that uses the [Remote Frame Buffer protocol (RFB)](http://en.wikipedia.org/wiki/RFB_protocol "RFB protocol") to remotely control another [computer](http://en.wikipedia.org/wiki/Computer "Computer"). It transmits the [keyboard](http://en.wikipedia.org/wiki/Computer_keyboard "Computer keyboard") and [mouse](http://en.wikipedia.org/wiki/Computer_mouse") events from one computer to another, relaying the graphical [screen](http://en.wikipedia.org/wiki/Computer_screen "Computer screen") updates back in the other direction, over a [network](http://en.wikipedia.org/wiki/Computer_network "Computer network").
Lukáš Krupčík's avatar
Lukáš Krupčík committed

Pavel Jirásek's avatar
Pavel Jirásek committed
Vnc-based connections are faster (require less network bandwidth) then [X11](x-window-system) applications forwarded directly through ssh.

Lukáš Krupčík's avatar
Lukáš Krupčík committed
The recommended clients are [TightVNC](http://www.tightvnc.com) or [TigerVNC](http://sourceforge.net/apps/mediawiki/tigervnc/index.php?title=Main_Page) (free, open source, available for almost any platform).
Lukáš Krupčík's avatar
Lukáš Krupčík committed

David Hrbáč's avatar
David Hrbáč committed
## Create VNC Password
Lukáš Krupčík's avatar
Lukáš Krupčík committed

David Hrbáč's avatar
David Hrbáč committed
!!! note
Lukáš Krupčík's avatar
Lukáš Krupčík committed
    Local VNC password should be set before the first login. Do use a strong password.
Lukáš Krupčík's avatar
Lukáš Krupčík committed

Lukáš Krupčík's avatar
Lukáš Krupčík committed
```console
Lukáš Krupčík's avatar
Lukáš Krupčík committed
[username@login2 ~]$ vncpasswd
Password:
Verify:
Lukáš Krupčík's avatar
Lukáš Krupčík committed
```
Lukáš Krupčík's avatar
Lukáš Krupčík committed

David Hrbáč's avatar
David Hrbáč committed
## Start Vncserver
Pavel Jirásek's avatar
Pavel Jirásek committed

David Hrbáč's avatar
David Hrbáč committed
!!! note
Lukáš Krupčík's avatar
Lukáš Krupčík committed
    To access VNC a local vncserver must be started first and also a tunnel using SSH port forwarding must be established.
Lukáš Krupčík's avatar
Lukáš Krupčík committed

Lukáš Krupčík's avatar
Lukáš Krupčík committed
[See below](vnc.md#linux-example-of-creating-a-tunnel) for the details on SSH tunnels. In this example we use port 61.
Lukáš Krupčík's avatar
Lukáš Krupčík committed

Lukáš Krupčík's avatar
Lukáš Krupčík committed
You can find ports which are already occupied. Here you can see that ports " /usr/bin/Xvnc :79" and " /usr/bin/Xvnc :60" are occupied.
Lukáš Krupčík's avatar
Lukáš Krupčík committed

Lukáš Krupčík's avatar
Lukáš Krupčík committed
```console
Lukáš Krupčík's avatar
Lukáš Krupčík committed
[username@login2 ~]$ ps aux | grep Xvnc
Lukáš Krupčík's avatar
Lukáš Krupčík committed
username    5971 0.0 0.0 201072 92564 ?        SN   Sep22   4:19 /usr/bin/Xvnc :79 -desktop login2:79 (username) -auth /home/vop999/.Xauthority -geometry 1024x768 -rfbwait 30000 -rfbauth /home/username/.vnc/passwd -rfbport 5979 -fp catalogue:/etc/X11/fontpath.d -pn
username    10296 0.0 0.0 131772 21076 pts/29   SN   13:01   0:01 /usr/bin/Xvnc :60 -desktop login2:61 (username) -auth /home/vop999/.Xauthority -geometry 1600x900 -depth 16 -rfbwait 30000 -rfbauth /home/vop999/.vnc/passwd -rfbport 5960 -fp catalogue:/etc/X11/fontpath.d -pn
Lukáš Krupčík's avatar
Lukáš Krupčík committed
.....
Lukáš Krupčík's avatar
Lukáš Krupčík committed
```
Lukáš Krupčík's avatar
Lukáš Krupčík committed

Choose free port e.g. 61 and start your VNC server:

Lukáš Krupčík's avatar
Lukáš Krupčík committed
```console
Lukáš Krupčík's avatar
Lukáš Krupčík committed
[username@login2 ~]$ vncserver :61 -geometry 1600x900 -depth 16

New 'login2:1 (username)' desktop is login2:1

Starting applications specified in /home/username/.vnc/xstartup
Log file is /home/username/.vnc/login2:1.log
Lukáš Krupčík's avatar
Lukáš Krupčík committed
```
Lukáš Krupčík's avatar
Lukáš Krupčík committed

Check if VNC server is started on the port (in this example 61):

Lukáš Krupčík's avatar
Lukáš Krupčík committed
```console
Lukáš Krupčík's avatar
Lukáš Krupčík committed
[username@login2 .vnc]$ vncserver -list

TigerVNC server sessions:

David Hrbáč's avatar
David Hrbáč committed
X DISPLAY #     PROCESS ID
:61              18437
Lukáš Krupčík's avatar
Lukáš Krupčík committed
```
Lukáš Krupčík's avatar
Lukáš Krupčík committed

Lukáš Krupčík's avatar
Lukáš Krupčík committed
Another command:
Lukáš Krupčík's avatar
Lukáš Krupčík committed

Lukáš Krupčík's avatar
Lukáš Krupčík committed
```console
David Hrbáč's avatar
David Hrbáč committed
[username@login2 .vnc]$  ps aux | grep Xvnc
Lukáš Krupčík's avatar
Lukáš Krupčík committed

Lukáš Krupčík's avatar
Lukáš Krupčík committed
username    10296 0.0 0.0 131772 21076 pts/29   SN   13:01   0:01 /usr/bin/Xvnc :61 -desktop login2:61 (username) -auth /home/vop999/.Xauthority -geometry 1600x900 -depth 16 -rfbwait 30000 -rfbauth /home/username/.vnc/passwd -rfbport 5961 -fp catalogue:/etc/X11/fontpath.d -pn
Lukáš Krupčík's avatar
Lukáš Krupčík committed
```
Lukáš Krupčík's avatar
Lukáš Krupčík committed

Lukáš Krupčík's avatar
Lukáš Krupčík committed
To access the VNC server you have to create a tunnel between the login node using TCP **port 5961** and your machine using a free TCP port (for simplicity the very same, in this case).
Lukáš Krupčík's avatar
Lukáš Krupčík committed

David Hrbáč's avatar
David Hrbáč committed
!!! note
Lukáš Krupčík's avatar
Lukáš Krupčík committed
    The tunnel must point to the same login node where you launched the VNC server, eg. login2. If you use just cluster-name.it4i.cz, the tunnel might point to a different node due to DNS round robin.
Lukáš Krupčík's avatar
Lukáš Krupčík committed

David Hrbáč's avatar
David Hrbáč committed
## Linux/Mac OS Example of Creating a Tunnel
Lukáš Krupčík's avatar
Lukáš Krupčík committed

At your machine, create the tunnel:

Lukáš Krupčík's avatar
Lukáš Krupčík committed
```console
David Hrbáč's avatar
David Hrbáč committed
local $  ssh -TN -f username@login2.cluster-name.it4i.cz -L 5961:localhost:5961
Lukáš Krupčík's avatar
Lukáš Krupčík committed
```
Lukáš Krupčík's avatar
Lukáš Krupčík committed

Lukáš Krupčík's avatar
Lukáš Krupčík committed
Issue the following command to check the tunnel is established (please note the PID 2022 in the last column, you'll need it for closing the tunnel):
Lukáš Krupčík's avatar
Lukáš Krupčík committed

Lukáš Krupčík's avatar
Lukáš Krupčík committed
```console
Lukáš Krupčík's avatar
Lukáš Krupčík committed
local $ netstat -natp | grep 5961
(Not all processes could be identified, non-owned process info
David Hrbáč's avatar
David Hrbáč committed
 will not be shown, you would have to be root to see it all.)
tcp        0      0 127.0.0.1:5961          0.0.0.0:*               LISTEN      2022/ssh
tcp6       0      0 ::1:5961                :::*                    LISTEN      2022/ssh
Lukáš Krupčík's avatar
Lukáš Krupčík committed
```
Lukáš Krupčík's avatar
Lukáš Krupčík committed

Or on Mac OS use this command:

Lukáš Krupčík's avatar
Lukáš Krupčík committed
```console
Lukáš Krupčík's avatar
Lukáš Krupčík committed
local-mac $ lsof -n -i4TCP:5961 | grep LISTEN
ssh 75890 sta545 7u IPv4 0xfb062b5c15a56a3b 0t0 TCP 127.0.0.1:5961 (LISTEN)
Lukáš Krupčík's avatar
Lukáš Krupčík committed
```
Lukáš Krupčík's avatar
Lukáš Krupčík committed

Connect with the VNC client:

Lukáš Krupčík's avatar
Lukáš Krupčík committed
```console
Lukáš Krupčík's avatar
Lukáš Krupčík committed
local $ vncviewer 127.0.0.1:5961
Lukáš Krupčík's avatar
Lukáš Krupčík committed
```
Lukáš Krupčík's avatar
Lukáš Krupčík committed

Lukáš Krupčík's avatar
Lukáš Krupčík committed
In this example, we connect to VNC server on port 5961, via the ssh tunnel. The connection is encrypted and secured. The VNC server listening on port 5961 provides screen of 1600x900 pixels.
Lukáš Krupčík's avatar
Lukáš Krupčík committed

Lukáš Krupčík's avatar
Lukáš Krupčík committed
You have to destroy the SSH tunnel which is still running at the background after you finish the work. Use the following command (PID 2022 in this case, see the netstat command above):
Lukáš Krupčík's avatar
Lukáš Krupčík committed

Lukáš Krupčík's avatar
Lukáš Krupčík committed
```console
Lukáš Krupčík's avatar
Lukáš Krupčík committed
kill 2022
Lukáš Krupčík's avatar
Lukáš Krupčík committed
```
Lukáš Krupčík's avatar
Lukáš Krupčík committed

David Hrbáč's avatar
David Hrbáč committed
## Windows Example of Creating a Tunnel
Lukáš Krupčík's avatar
Lukáš Krupčík committed

Use PuTTY to log in on cluster.

Start vncserver using command vncserver described above.

Lukáš Krupčík's avatar
Lukáš Krupčík committed
Search for the localhost and port number (in this case 127.0.0.1:5961).
Lukáš Krupčík's avatar
Lukáš Krupčík committed

Lukáš Krupčík's avatar
Lukáš Krupčík committed
```console
Lukáš Krupčík's avatar
Lukáš Krupčík committed
[username@login2 .vnc]$ netstat -tanp | grep Xvnc
(Not all processes could be identified, non-owned process info
David Hrbáč's avatar
David Hrbáč committed
 will not be shown, you would have to be root to see it all.)
tcp        0      0 127.0.0.1:5961              0.0.0.0:*                   LISTEN      24031/Xvnc
Lukáš Krupčík's avatar
Lukáš Krupčík committed
```
Lukáš Krupčík's avatar
Lukáš Krupčík committed

David Hrbáč's avatar
David Hrbáč committed
On the PuTTY Configuration screen go to Connection->SSH->Tunnels to set up the tunnel.
Lukáš Krupčík's avatar
Lukáš Krupčík committed

Lukáš Krupčík's avatar
Lukáš Krupčík committed
Fill the Source port and Destination fields. **Do not forget to click the Add button**.
Lukáš Krupčík's avatar
Lukáš Krupčík committed

Lukáš Krupčík's avatar
Lukáš Krupčík committed
![](../../../img/putty-tunnel.png)
Lukáš Krupčík's avatar
Lukáš Krupčík committed

Lukáš Krupčík's avatar
Lukáš Krupčík committed
Run the VNC client of your choice, select VNC server 127.0.0.1, port 5961 and connect using VNC password.
Lukáš Krupčík's avatar
Lukáš Krupčík committed

David Hrbáč's avatar
David Hrbáč committed
## Example of Starting TigerVNC Viewer
Lukáš Krupčík's avatar
Lukáš Krupčík committed

Lukáš Krupčík's avatar
Lukáš Krupčík committed
![](../../../img/vncviewer.png)
Lukáš Krupčík's avatar
Lukáš Krupčík committed

Lukáš Krupčík's avatar
Lukáš Krupčík committed
In this example, we connect to VNC server on port 5961, via the ssh tunnel, using TigerVNC viewer. The connection is encrypted and secured. The VNC server listening on port 5961 provides screen of 1600x900 pixels.
Lukáš Krupčík's avatar
Lukáš Krupčík committed

David Hrbáč's avatar
David Hrbáč committed
## Example of Starting TightVNC Viewer
Lukáš Krupčík's avatar
Lukáš Krupčík committed

Lukáš Krupčík's avatar
Lukáš Krupčík committed
Use your VNC password to log using TightVNC Viewer and start a Gnome Session on the login node.
Lukáš Krupčík's avatar
Lukáš Krupčík committed

Lukáš Krupčík's avatar
Lukáš Krupčík committed
![](../../../img/TightVNC_login.png)
Lukáš Krupčík's avatar
Lukáš Krupčík committed

David Hrbáč's avatar
David Hrbáč committed
## Gnome Session
Lukáš Krupčík's avatar
Lukáš Krupčík committed

You should see after the successful login.

Lukáš Krupčík's avatar
Lukáš Krupčík committed
![](../../../img/gnome_screen.png)
Lukáš Krupčík's avatar
Lukáš Krupčík committed

David Hrbáč's avatar
David Hrbáč committed
## Disable Your Gnome Session Screensaver
Lukáš Krupčík's avatar
Lukáš Krupčík committed

Open Screensaver preferences dialog:

Lukáš Krupčík's avatar
Lukáš Krupčík committed
![](../../../img/gdmscreensaver.png)
Lukáš Krupčík's avatar
Lukáš Krupčík committed

Uncheck both options below the slider:

Lukáš Krupčík's avatar
Lukáš Krupčík committed
![](../../../img/gdmdisablescreensaver.png)
Lukáš Krupčík's avatar
Lukáš Krupčík committed

David Hrbáč's avatar
David Hrbáč committed
## Kill Screensaver if Locked Screen
Lukáš Krupčík's avatar
Lukáš Krupčík committed

Lukáš Krupčík's avatar
Lukáš Krupčík committed
If the screen gets locked you have to kill the screensaver. Do not to forget to disable the screensaver then.
Lukáš Krupčík's avatar
Lukáš Krupčík committed

Lukáš Krupčík's avatar
Lukáš Krupčík committed
```console
Lukáš Krupčík's avatar
Lukáš Krupčík committed
[username@login2 .vnc]$ ps aux | grep screen
Lukáš Krupčík's avatar
Lukáš Krupčík committed
username     1503 0.0 0.0 103244   892 pts/4    S+   14:37   0:00 grep screen
username     24316 0.0 0.0 270564 3528 ?        Ss   14:12   0:00 gnome-screensaver
Lukáš Krupčík's avatar
Lukáš Krupčík committed

[username@login2 .vnc]$ kill 24316
Lukáš Krupčík's avatar
Lukáš Krupčík committed
```
Lukáš Krupčík's avatar
Lukáš Krupčík committed

David Hrbáč's avatar
David Hrbáč committed
## Kill Vncserver After Finished Work
Lukáš Krupčík's avatar
Lukáš Krupčík committed

You should kill your VNC server using command:

Lukáš Krupčík's avatar
Lukáš Krupčík committed
```console
David Hrbáč's avatar
David Hrbáč committed
[username@login2 .vnc]$  vncserver  -kill :61
Lukáš Krupčík's avatar
Lukáš Krupčík committed
Killing Xvnc process ID 7074
Xvnc process ID 7074 already killed
Lukáš Krupčík's avatar
Lukáš Krupčík committed
```
Lukáš Krupčík's avatar
Lukáš Krupčík committed

Or this way:

Lukáš Krupčík's avatar
Lukáš Krupčík committed
```console
David Hrbáč's avatar
David Hrbáč committed
[username@login2 .vnc]$  pkill vnc
Lukáš Krupčík's avatar
Lukáš Krupčík committed
```
Lukáš Krupčík's avatar
Lukáš Krupčík committed

David Hrbáč's avatar
David Hrbáč committed
## GUI Applications on Compute Nodes Over VNC
Lukáš Krupčík's avatar
Lukáš Krupčík committed

The very same methods as described above, may be used to run the GUI applications on compute nodes. However, for maximum performance, proceed following these steps:
Lukáš Krupčík's avatar
Lukáš Krupčík committed

David Hrbáč's avatar
David Hrbáč committed
Open a Terminal (Applications -> System Tools -> Terminal). Run all the next commands in the terminal.
Lukáš Krupčík's avatar
Lukáš Krupčík committed

Lukáš Krupčík's avatar
Lukáš Krupčík committed
![](../../../img/gnome-terminal.png)
Lukáš Krupčík's avatar
Lukáš Krupčík committed

Allow incoming X11 graphics from the compute nodes at the login node:

Lukáš Krupčík's avatar
Lukáš Krupčík committed
```console
Lukáš Krupčík's avatar
Lukáš Krupčík committed
$ xhost +
Lukáš Krupčík's avatar
Lukáš Krupčík committed
```
Lukáš Krupčík's avatar
Lukáš Krupčík committed

Get an interactive session on a compute node (for more detailed info [look here](../../../anselm/job-submission-and-execution/)). Use the **-v DISPLAY** option to propagate the DISPLAY on the compute node. In this example, we want a complete node (24 cores in this example) from the production queue:
Lukáš Krupčík's avatar
Lukáš Krupčík committed

Lukáš Krupčík's avatar
Lukáš Krupčík committed
```console
Lukáš Krupčík's avatar
Lukáš Krupčík committed
$ qsub -I -v DISPLAY=$(uname -n):$(echo $DISPLAY | cut -d ':' -f 2) -A PROJECT_ID -q qprod -l select=1:ncpus=24
Lukáš Krupčík's avatar
Lukáš Krupčík committed
```
Lukáš Krupčík's avatar
Lukáš Krupčík committed

Lukáš Krupčík's avatar
Lukáš Krupčík committed
Test that the DISPLAY redirection into your VNC session works, by running a X11 application (e. g. XTerm) on the assigned compute node:
Lukáš Krupčík's avatar
Lukáš Krupčík committed

Lukáš Krupčík's avatar
Lukáš Krupčík committed
```console
Lukáš Krupčík's avatar
Lukáš Krupčík committed
$ xterm
Lukáš Krupčík's avatar
Lukáš Krupčík committed
```
Lukáš Krupčík's avatar
Lukáš Krupčík committed

Example described above:

![](../../../img/gnome-compute-nodes-over-vnc.png)