|
1 | 1 | # Graphical applications with VNC |
2 | 2 |
|
3 | | -{% if site == gent %} |
4 | | -**VNC is still available at UGent site but we encourage our users to replace VNC by X2Go client**. |
5 | | -Please see [Graphical applications with X2Go](../x2go/#graphical-applications-with-x2go) for more information. |
6 | | -{% endif %} |
7 | | - |
8 | | -Virtual Network Computing is a graphical desktop sharing system that |
9 | | -enables you to interact with graphical software running on the HPC |
10 | | -infrastructure from your own computer. |
11 | | - |
12 | | -**Please carefully follow the instructions below, since the procedure to connect to a VNC server running on the HPC infrastructure is not trivial, due to security constraints.** |
13 | | - |
14 | | -## Starting a VNC server |
15 | | - |
16 | | -First login on the login node (see [First time connection to the HPC infrastructure](../connecting/#first-time-connection-to-the-hpc-infrastructure), then start `vncserver` with: |
17 | | - |
18 | | -``` |
19 | | -$ vncserver -geometry 1920x1080 -localhost |
20 | | -You will require a password to access your desktops. |
21 | | -
|
22 | | -Password: <enter a secure password> |
23 | | -Verify: <enter the same password> |
24 | | -Would you like to enter a view-only password (y/n)? n |
25 | | -A view-only password is not used |
26 | | -
|
27 | | -New '{{loginhost}}:6 ({{userid}})' desktop is {{loginhost}}:6 |
28 | | -
|
29 | | -Creating default startup script {{homedir}}.vnc/xstartup |
30 | | -Creating default config {{homedir}}.vnc/config |
31 | | -Starting applications specified in {{homedir}}.vnc/xstartup |
32 | | -Log file is {{homedir}}.vnc/{{loginhost}}:6.log |
33 | | -``` |
34 | | - |
35 | | -**When prompted for a password, make sure to enter a secure password: if someone can guess your password, they will be able to do anything with your account you can!** |
36 | | - |
37 | | -Note down the details in bold: the hostname (in the example: `{{loginhost}}`) and the |
38 | | -(partial) port number (in the example: `6`). |
39 | | - |
40 | | -It's important to remember that VNC sessions are permanent. They survive |
41 | | -network problems and (unintended) connection loss. This means you can |
42 | | -logout and go home without a problem (like the terminal equivalent |
43 | | -`screen` or `tmux`). This also means you don't have to start `vncserver` |
44 | | -each time you want to connect. |
45 | | - |
46 | | -## List running VNC servers |
47 | | - |
48 | | -You can get a list of running VNC servers on a node with |
49 | | - |
50 | | -``` |
51 | | -$ vncserver -list |
52 | | -TigerVNC server sessions: |
53 | | -
|
54 | | -X DISPLAY # PROCESS ID |
55 | | -:6 30713 |
56 | | -``` |
57 | | - |
58 | | -This only displays the running VNC servers on **the login node you run the command on**. |
59 | | - |
60 | | -To see what login nodes you are running a VNC server on, you can run the |
61 | | -`ls .vnc/*.pid` command in your home directory: the files shown have the |
62 | | -hostname of the login node in the filename: |
63 | | - |
64 | | -``` |
65 | | -$ cd $HOME |
66 | | -$ ls .vnc/*.pid |
67 | | -.vnc/{{loginhost}}:6.pid |
68 | | -.vnc/{{altloginhost}}:8.pid |
69 | | -``` |
70 | | - |
71 | | -This shows that there is a VNC server running on `{{loginhost}}` on port 5906 and |
72 | | -another one running `{{altloginhost}}` on port 5908 (see also [Determining the source/destination port](./#determining-the-sourcedestination-port)). |
73 | | - |
74 | | -## Connecting to a VNC server |
75 | | - |
76 | | -The VNC server runs on a (in the example above, on `{{loginhost}}`). |
77 | | - |
78 | | -In order to access your VNC server, you will need to set up an SSH |
79 | | -tunnel from your workstation to this login node (see [Setting up the SSH tunnel(s)](./#setting-up-the-ssh-tunnels)). |
80 | | - |
81 | | -Login nodes are rebooted from time to time. You can check that the VNC |
82 | | -server is still running in the same node by executing `vncserver -list` |
83 | | -(see also |
84 | | -[List running VNC servers](./#list-running-vnc-servers)). If you get an empty list, it means that there is no VNC |
85 | | -server running on the login node. |
86 | | - |
87 | | -**To set up the SSH tunnel required to connect to your VNC server, you will need to port forward the VNC port to your workstation.** |
88 | | - |
89 | | -The *host* is `localhost`, which means "your own computer": we set up an |
90 | | -SSH tunnel that connects the VNC port on the login node to the same port |
91 | | -on your local computer. |
92 | | - |
93 | | -### Determining the source/destination port |
94 | | - |
95 | | -The *destination port* is the port on which the VNC server is running |
96 | | -(on the login node), which is **the sum of `5900` and the partial port number** we noted down earlier (`6`); in the |
97 | | -running example, that is `5906`. |
98 | | - |
99 | | -The *source port* is the port you will be connecting to with your VNC |
100 | | -client on your workstation. Although you can use any (free) port for |
101 | | -this, we strongly recommend to use the **same value as the destination port**. |
102 | | - |
103 | | -So, in our running example, both the source and destination ports are |
104 | | -`5906`. |
105 | | - |
106 | | -### Picking an intermediate port to connect to the right login node |
107 | | - |
108 | | -In general, you have no control over which login node you will be on |
109 | | -when setting up the SSH tunnel from your workstation to `{{loginnode}}` (see [Setting up the SSH tunnel(s)](./#setting-up-the-ssh-tunnels)). |
110 | | - |
111 | | -If the login node you end up on is a different one than the one where |
112 | | -your VNC server is running (i.e., `{{altloginhost}}` rather than `{{loginhost}}` in our running |
113 | | -example), you need to create a ***second* SSH tunnel** on the login node you are connected to, |
114 | | -in order to "patch through" to the correct port on the login node |
115 | | -where your VNC server is running. |
116 | | - |
117 | | -In the remainder of these instructions, we will assume that we are |
118 | | -indeed connected to a different login node. Following these instructions |
119 | | -should always work, even if you happen to be connected to the correct |
120 | | -login node. |
121 | | - |
122 | | -To set up the second SSH tunnel, you need to **pick an (unused) port on the login node you are connected to**, which will be used as an |
123 | | -*intermediate* port. |
124 | | - |
125 | | -Now we have a chicken-egg situation: you need to pick a port before |
126 | | -setting up the SSH tunnel from your workstation to `{{loginhost}}`, but only after |
127 | | -starting the SSH tunnel will you be able to determine whether the port |
128 | | -you picked is actually free or not... |
129 | | - |
130 | | -In practice, if you **pick a *random* number between $10000$ and $30000$**, you have a good chance that the port will not be |
131 | | -used yet. |
132 | | - |
133 | | -We will proceed with $12345$ as intermediate port, but **you should pick another value that other people are not likely to pick**. If you need |
134 | | -some inspiration, run the following command on a Linux server (for |
135 | | -example on a login node): `echo $RANDOM` (but do not use a value lower |
136 | | -than $1025$). |
137 | | - |
138 | | -### Setting up the SSH tunnel(s) |
139 | | - |
140 | | -#### Setting up the first SSH tunnel from your workstation to {{loginnode}} |
141 | | - |
142 | | -First, we will set up the SSH tunnel from our workstation to . |
143 | | - |
144 | | -Use the settings specified in the sections above: |
145 | | - |
146 | | -- *source port*: the port on which the VNC server is running (see [Determining the source/destination port](./#determining-the-sourcedestination-port)); |
147 | | - |
148 | | -- *destination host*: `localhost`; |
149 | | - |
150 | | -- *destination port*: use the intermediate port you picked (see [Picking an intermediate port to connect to the right login node](./#picking-an-intermediate-port-to-connect-to-the-right-login-node)) |
151 | | - |
152 | | -{% if OS == windows %} |
153 | | -See for detailed information on how to configure PuTTY to set up the SSH |
154 | | -tunnel, by entering the settings in the and fields in [SSH tunnel](../running_interactive_jobs/#ssh-tunnel). |
155 | | - |
156 | | -{% else %} |
157 | | -Execute the following command to set up the SSH tunnel. |
158 | | - |
159 | | -``` |
160 | | -ssh -L 5906:localhost:12345 {{userid}}@{{loginnode}} |
161 | | -``` |
162 | | - |
163 | | -**Replace the source port `5906`, destination port `12345` and user ID {{userid}} with your own!** |
164 | | - |
165 | | -{% endif %} |
166 | | - |
167 | | -With this, we have forwarded port `5906` on our workstation to port |
168 | | -`12345` on the login node we are connected to. |
169 | | - |
170 | | -**Again, do *not* use `12345` as destination port, as this port will most likely be used by somebody else already; replace it with a port number you picked yourself, which is unlikely to be used already (see [Picking an intermediate port to connect to the right login node](./#picking-an-intermediate-port-to-connect-to-the-right-login-node)).** |
171 | | - |
172 | | -#### Checking whether the intermediate port is available |
173 | | - |
174 | | -Before continuing, it's good to check whether the intermediate port that |
175 | | -you have picked is actually still available (see [Picking an intermediate port to connect to the right login node](./#picking-an-intermediate-port-to-connect-to-the-right-login-node)). |
176 | | - |
177 | | -You can check using the following command (**do not forget to replace `12345` the value you picked for your intermediate port): |
178 | | - |
179 | | -``` |
180 | | -netstat -an | grep -i listen | grep tcp | grep 12345 |
181 | | -``` |
182 | | - |
183 | | -If you see no matching lines, then the port you picked is still |
184 | | -available, and you can continue. |
185 | | - |
186 | | -If you see one or more matching lines as shown below, |
187 | | -**you must disconnect the first SSH tunnel, pick a different intermediate port, and set up the first SSH tunnel again using the new value**. |
188 | | - |
189 | | -``` |
190 | | -$ netstat -an | grep -i listen | grep tcp | grep 12345 |
191 | | -tcp 0 0 0.0.0.0:12345 0.0.0.0:* LISTEN |
192 | | -tcp6 0 0 :::12345 :::* LISTEN |
193 | | -$ |
194 | | -``` |
195 | | - |
196 | | -#### Setting up the second SSH tunnel to the correct login node |
197 | | - |
198 | | -In the session on the login node you created by setting up an SSH tunnel |
199 | | -from your workstation to `{{loginnode}}`, you now need to set up the second SSH |
200 | | -tunnel to "patch through" to the login node where your VNC server is |
201 | | -running (`{{loginhost}}` in our running example, see [Starting a VNC server](./#starting-a-vnc-server)). |
202 | | - |
203 | | -To do this, run the following command: |
204 | | - |
205 | | -``` |
206 | | -$ ssh -L 12345:localhost:5906 {{loginhost}} |
207 | | -$ hostname |
208 | | -{{loginhost}} |
209 | | -``` |
210 | | - |
211 | | -With this, we are forwarding port `12345` on the login node we are |
212 | | -connected to (which is referred to as `localhost`) through to port |
213 | | -`5906` on our target login node (`{{loginhost}}`). |
214 | | - |
215 | | -Combined with the first SSH tunnel, port `5906` on our workstation is |
216 | | -now connected to port `5906` on the login node where our VNC server is |
217 | | -running (via the intermediate port `12345` on the login node we ended up |
218 | | -one with the first SSH tunnel). |
219 | | - |
220 | | -**Do not forget to change the intermediate port (`12345`), destination port (`5906`), |
221 | | -and hostname of the login node (`{{loginhost}}`) in the command shown above! |
222 | | - |
223 | | -As shown above, you can check again using the `hostname` command whether |
224 | | -you are indeed connected to the right login node. If so, you can go |
225 | | -ahead and connect to your VNC server (see [Connecting using a VNC client](./#connecting-using-a-vnc-client)). |
226 | | - |
227 | | -### Connecting using a VNC client |
228 | | - |
229 | | -{% if OS == windows %} |
230 | | -You can download a free VNC client from |
231 | | -<https://sourceforge.net/projects/turbovnc/files/>. You can download the |
232 | | -latest version by clicking the top-most folder that has a version number |
233 | | -in it that doesn't also have `beta` in the version. Then download a file |
234 | | -that looks like `TurboVNC64-2.1.2.exe` (the version number can be |
235 | | -different, but the `64` should be in the filename) and execute it. |
236 | | -{% endif %} |
237 | | -{% if OS == macos %} |
238 | | -You can download a free VNC client from |
239 | | -<https://sourceforge.net/projects/turbovnc/files/>. You can download the |
240 | | -latest version by clicking the top-most folder that has a version number |
241 | | -in it that doesn't also have `beta` in the version. Then download a file |
242 | | -ending in `TurboVNC64-2.1.2.dmg` (the version number can be different) |
243 | | -and execute it. |
244 | | -{% endif %} |
245 | | -{% if OS == linux %} |
246 | | -Download and setup a VNC client. A good choice is |
247 | | -`tigervnc`. You can start it with the `vncviewer` command. |
248 | | -{% endif %} |
249 | | - |
250 | | -Now start your VNC client and connect to `localhost:5906`. **Make sure you replace the port number `5906` with your own destination port (see [Determining the source/destination port](./#determining-the-sourcedestination-port)). |
251 | | - |
252 | | -When prompted for a password, use the password you used to setup the VNC |
253 | | -server. |
254 | | - |
255 | | -When prompted for default or empty panel, choose default. |
256 | | - |
257 | | -If you have an empty panel, you can reset your settings with the |
258 | | -following commands: |
259 | | - |
260 | | -``` |
261 | | -xfce4-panel --quit ; pkill xfconfd |
262 | | -mkdir ~/.oldxfcesettings |
263 | | -mv ~/.config/xfce4 ~/.oldxfcesettings |
264 | | -xfce4-panel |
265 | | -``` |
266 | | - |
267 | | -## Stopping the VNC server |
268 | | - |
269 | | -The VNC server can be killed by running |
270 | | - |
271 | | -``` |
272 | | -vncserver -kill :6 |
273 | | -``` |
274 | | - |
275 | | -where `6` is the port number we noted down earlier. If you forgot, you |
276 | | -can get it with `vncserver -list` (see [List running VNC servers](./#list-running-vnc-servers)). |
277 | | - |
278 | | -## I forgot the password, what now? |
279 | | - |
280 | | -You can reset the password by first stopping the VNC server (see ), then |
281 | | -removing the `.vnc/passwd` file (with `rm .vnc/passwd`) and then |
282 | | -starting the VNC server again (see [Starting a VNC server](./#starting-a-vnc-server)). |
| 3 | +We strongly encourage the use of the [web portal](web_portal.md) for graphical use cases. |
0 commit comments