From time to time, it may be interesting to be able to connect to a compute node from outside.
Example use case: you are running a JupyterNotebook on a compute node and you need to connect to this instance using your desktop’s web browser.
In this case, the solutions are:
- create an ssh tunnel using the login node as “gateway”
- create a socks proxy and use it from your desktop’s browser
- other not described here
ssh tunnel
Example configuration to be added to your .ssh/config
(in your laptop/desktop, not the cluster) to connect directly to a compute node from outside the cluster:
Host baobab
HostName login2.baobab.hpc.unige.ch
User your_user_name
Host node001
HostName node001
User your_user_name
ProxyJump baobab
LocalForward 1234 localhost:1234
You can now connect to the host node001
using ssh.
ysagon@lyann-dell-portable:~$ ssh baobab-node
Last login: Wed Nov 17 15:08:22 2021 from login2.cluster
Installed: Fri Sep 10 09:05:36 CEST 2021
This will connect to the node through the baobab login node thanks to the ProxyJump
pragma. The pragma LocalForward
will forward the the port 1234 on the compute node to your pc where you instantiated the ssh connection.
From your browser, you should then open an url like this one: http://localhost:1234
.
This method is working fine and quite secure, but not very flexible as you’ll have to update your ssh tunnel configuration according to the compute node where you are running your JupyterNotebook instance.
socks proxy
Another option is to connect to the login node using ssh and use the DynamicForward
pragma.
Host baobab
HostName login2.baobab.hpc.unige.ch
User sagon
DynamicForward 5000
When you connect to this host using ssh, this creates a socks proxy.
You can then configure your browser to use this proxy. Example for firefox:
You can then enter directly in the url the final destination: http://node001:1234
. The advantage is that you don’t need to update the ssh configuration if you connect to another node.
ref: How to chain port forwarding to cluster node?
edit: correct ssh config.