vnc.md 10.6 KB
Newer Older
Lukáš Krupčík's avatar
Lukáš Krupčík committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
VNC 
===



  

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 "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").^[<span>[</span>1<span>]</span>](http://en.wikipedia.org/wiki/Virtual_Network_Computing#cite_note-1)^

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).

Create VNC password
-------------------

Local VNC password should be set before the first login. Do use a strong
password.

``` 
[username@login2 ~]$ vncpasswd
Password:
Verify:
```

Start vncserver
---------------

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
add  
Lukáš Krupčík committed
45 46 47
[See
below](../../../get-started-with-it4innovations/accessing-the-clusters/graphical-user-interface/vnc/vnc.html#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
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166

You can find ports which are already occupied. Here you can see that
ports "<span class="pln">/usr/bin/Xvnc :79"</span> and "<span
class="pln">/usr/bin/Xvnc :60" are occupied.</span>

``` 
[username@login2 ~]$ ps aux | grep Xvnc
username    5971  0.0  0.0 201072 92564 ?        SN   Sep22   4:19 /usr/bin/Xvnc :79 -desktop login2:79 (username) -auth /home/gre196/.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/username/.Xauthority -geometry 1600x900 -depth 16 -rfbwait 30000 -rfbauth /home/jir13/.vnc/passwd -rfbport 5960 -fp catalogue:/etc/X11/fontpath.d -pn
.....
```

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

``` 
[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
```

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

``` 
[username@login2 .vnc]$ vncserver -list

TigerVNC server sessions:

X DISPLAY #     PROCESS ID
:61              18437
```

Another command:<span class="pln"></span>

``` 
[username@login2 .vnc]$  ps aux | grep Xvnc

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/jir13/.Xauthority -geometry 1600x900 -depth 16 -rfbwait 30000 -rfbauth /home/username/.vnc/passwd -rfbport 5961 -fp catalogue:/etc/X11/fontpath.d -pn
```

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).

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.

### []()[]()Linux/Mac OS example of creating a tunnel

At your machine, create the tunnel:

``` 
local $  ssh -TN -f username@login2.cluster-name.it4i.cz -L 5961:localhost:5961
```

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):

``` 
local $ netstat -natp | grep 5961
(Not all processes could be identified, non-owned process info
 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 
```

Or on Mac OS use this command:

``` 
local-mac $ lsof -n -i4TCP:5961 | grep LISTEN
ssh 75890 sta545 7u IPv4 0xfb062b5c15a56a3b 0t0 TCP 127.0.0.1:5961 (LISTEN)
```

Connect with the VNC client:

``` 
local $ vncviewer 127.0.0.1:5961
```

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.

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):

``` 
kill 2022
```

### Windows example of creating a tunnel

Use PuTTY to log in on cluster.

Start vncserver using command vncserver described above.

Search for the localhost and port number (in this case
127.0.0.1:5961).**
**

``` 
[username@login2 .vnc]$ netstat -tanp | grep Xvnc
(Not all processes could be identified, non-owned process info
 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
```

On the PuTTY Configuration screen go to Connection-&gt;SSH-&gt;Tunnels
to set up the tunnel.

Fill the Source port and Destination fields. **Do not forget to click
the Add button**.

[![PuTTY - Create
Lukáš Krupčík's avatar
add  
Lukáš Krupčík committed
167
tunnel](https://docs.it4i.cz/get-started-with-it4innovations/accessing-the-clusters/graphical-user-interface/vnc/putty-tunnel.png/@@images/4c66cd51-c858-473b-98c2-8d901aea7118.png "PuTTY Tunnel")](../../../get-started-with-it4innovations/accessing-the-clusters/graphical-user-interface/vnc/putty-tunnel.png)
Lukáš Krupčík's avatar
Lukáš Krupčík committed
168 169 170 171 172 173 174

Run the VNC client of your choice, select VNC server 127.0.0.1, port
5961 and connect using VNC password.

### Example of starting TigerVNC viewer

![TigerVNC
Lukáš Krupčík's avatar
add  
Lukáš Krupčík committed
175
vncviewer](../../../anselm-cluster-documentation/vncviewer.png/@@images/bb4cedff-4cb6-402b-ac79-039186fe5df3.png "Vncviewer")
Lukáš Krupčík's avatar
Lukáš Krupčík committed
176 177 178 179 180 181 182 183 184 185 186

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.

### Example of starting TightVNC Viewer

Use your VNC password to log using TightVNC Viewer and start a Gnome
Session on the login node.

Lukáš Krupčík's avatar
add  
Lukáš Krupčík committed
187
[**![](https://docs.it4i.cz/get-started-with-it4innovations/accessing-the-clusters/graphical-user-interface/vnc/TightVNC_login.png/@@images/e53354d8-a2e8-4947-92b3-dd107d498408.png)**](../../../get-started-with-it4innovations/accessing-the-clusters/graphical-user-interface/vnc/TightVNC_login.png)
Lukáš Krupčík's avatar
Lukáš Krupčík committed
188 189 190 191 192 193 194

Gnome session
-------------

You should see after the successful login.

[![Default Gnome
Lukáš Krupčík's avatar
add  
Lukáš Krupčík committed
195
session](../../gnome_screen.jpg/@@images/7758b792-24eb-48dc-bf72-618cda100fda.png "Default Gnome session")](https://docs.it4i.cz/get-started-with-it4innovations/gnome_screen.jpg)
Lukáš Krupčík's avatar
Lukáš Krupčík committed
196 197 198 199 200 201 202

### **Disable your Gnome session screensaver
**

Open Screensaver preferences dialog:

[![Screensaver
Lukáš Krupčík's avatar
Lukáš Krupčík committed
203
Preferences](../../../get-started-with-it4innovations/accessing-the-clusters/graphical-user-interface/vnc/gdmscreensaver.png/@@images/44048cfa-e854-4cb4-902b-c173821c2db1.png "Screensaver Preferences")](../../gnome_screen.jpg.1)
Lukáš Krupčík's avatar
Lukáš Krupčík committed
204 205 206 207

Uncheck both options below the slider:

[![Disable lock screen and
Lukáš Krupčík's avatar
Lukáš Krupčík committed
208
screensaver](https://docs.it4i.cz/get-started-with-it4innovations/accessing-the-clusters/graphical-user-interface/vnc/gdmdisablescreensaver.png/@@images/0259b284-18eb-402c-a55c-584562e26b47.png "Disable lock screen and screensaver")](../../../get-started-with-it4innovations/accessing-the-clusters/graphical-user-interface/vnc/gdmdisablescreensaver.png)
Lukáš Krupčík's avatar
Lukáš Krupčík committed
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249

### Kill screensaver if locked screen

If the screen gets locked you have to kill the screensaver. Do not to
forget to disable the screensaver then.

``` 
[username@login2 .vnc]$ ps aux | grep screen
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

[username@login2 .vnc]$ kill 24316
```

### Kill vncserver after finished work

You should kill your VNC server using command:

``` 
[username@login2 .vnc]$  vncserver  -kill :61
Killing Xvnc process ID 7074
Xvnc process ID 7074 already killed
```

Or this way:

``` 
[username@login2 .vnc]$  pkill vnc
```

GUI applications on compute nodes over VNC
------------------------------------------

The very [same methods as described
above](https://docs.it4i.cz/get-started-with-it4innovations/accessing-the-clusters/graphical-user-interface/x-window-and-vnc#gui-applications-on-compute-nodes),
may be used to run the GUI applications on compute nodes. However, for
**maximum performance**, proceed following these steps:

Open a Terminal (Applications -&gt; System Tools -&gt; Terminal). Run
all the next commands in the terminal.

Lukáš Krupčík's avatar
add  
Lukáš Krupčík committed
250
[![gnome-terminal.png](https://docs.it4i.cz/get-started-with-it4innovations/accessing-the-clusters/graphical-user-interface/vnc/gnome-terminal.png/@@images/b44f5d8c-156d-4041-9bb0-973996413834.png "gnome-terminal.png")](../../../get-started-with-it4innovations/accessing-the-clusters/graphical-user-interface/vnc/gnome-terminal.png)
Lukáš Krupčík's avatar
Lukáš Krupčík committed
251 252 253 254 255 256 257 258 259

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

``` 
$ xhost +
```

Get an interactive session on a compute node (for more detailed info
[look
Lukáš Krupčík's avatar
add  
Lukáš Krupčík committed
260
here](../../../anselm-cluster-documentation/resource-allocation-and-job-execution/job-submission-and-execution.html)).
Lukáš Krupčík's avatar
Lukáš Krupčík committed
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277
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:

``` 
$ qsub -I -v DISPLAY=$(uname -n):$(echo $DISPLAY | cut -d ':' -f 2) -A PROJECT_ID -q qprod -l select=1:ncpus=24
```

Test that the DISPLAY redirection into your VNC session works, by
running a X11 application (e. g. XTerm) on the assigned compute node:

``` 
$ xterm
```

Example described above:

Lukáš Krupčík's avatar
add  
Lukáš Krupčík committed
278
[![gnome-compute-nodes-over-vnc.png](https://docs.it4i.cz/get-started-with-it4innovations/accessing-the-clusters/graphical-user-interface/vnc/gnome-compute-nodes-over-vnc.png/@@images/90ca3609-a3ff-4867-9019-954c74224961.png "gnome-compute-nodes-over-vnc.png")](../../../get-started-with-it4innovations/accessing-the-clusters/graphical-user-interface/vnc/gnome-compute-nodes-over-vnc.png)