SSH tunnel to a certain node: Difference between revisions

From HPCwiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
SSH tunnel to a certain node
SSH tunnel to a certain node


#1) Submit a slurm job, or an interactive srun job on a node. Taking node201 as an example:
1) Submit a slurm job, or an interactive srun job on a node. Taking node201 as an example:
sinteractive --partition=main --nodelist=node201
sinteractive --partition=main --nodelist=node201


#2) In your local OS, set up a port tunnel connection (For example using port 2222):
2) In your local OS, set up a port tunnel connection (For example using port 2222):
ssh -L 2222:node201:22 your_id@login.anunna.wur.nl
ssh -L 2222:node201:22 your_id@login.anunna.wur.nl


#3) Config your local ssh config in ~/.ssh/config
3) Config your local ssh config in ~/.ssh/config
Host localhost
Host localhost
   HostName localhost
   HostName localhost
Line 13: Line 13:
   User your_id
   User your_id


#4) You could now use your local terminal connecting to node201 directly, by:
4) You could now use your local terminal connecting to node201 directly, by:
ssh your_id@localhost -p 2222
ssh your_id@localhost -p 2222


#5) VSCode connection: in the VSCode GUI -> Open a remote Window -> Connect to Host...,
5) VSCode connection: in the VSCode GUI -> Open a remote Window -> Connect to Host...,
choose "localhost". After a few seconds, the VSCode is connected to the node201.
choose "localhost". After a few seconds, the VSCode is connected to the node201.


Please be aware that once the slurm job finishes, the connection will be lost.
Please be aware that once the slurm job finishes, the connection will be lost.

Revision as of 15:22, 16 April 2024

SSH tunnel to a certain node

1) Submit a slurm job, or an interactive srun job on a node. Taking node201 as an example: sinteractive --partition=main --nodelist=node201

2) In your local OS, set up a port tunnel connection (For example using port 2222): ssh -L 2222:node201:22 your_id@login.anunna.wur.nl

3) Config your local ssh config in ~/.ssh/config Host localhost

 HostName localhost
 Port 2222
 User your_id

4) You could now use your local terminal connecting to node201 directly, by: ssh your_id@localhost -p 2222

5) VSCode connection: in the VSCode GUI -> Open a remote Window -> Connect to Host..., choose "localhost". After a few seconds, the VSCode is connected to the node201.

Please be aware that once the slurm job finishes, the connection will be lost.