-
Notifications
You must be signed in to change notification settings - Fork 42
Set up VS Code on OpenMind compute node (Method 02)
H Gazula edited this page Feb 12, 2024
·
9 revisions
This page describes an alternative method to connect to the compute node on Openmind without having to note down the node name every time as described here. Using this method, you don't even have to log on to Openmind first. Everything can be done from your local machine.
a. https://github.mit.edu/MGHPCC/OpenMind/wiki/Configuring-password-less-SSH-login
- On your local machine create a script named
tunnel.sh(or whatever name you prefer) with the following contents (please feel free to change resources according to your requirements).
#!/bin/bash
#SBATCH --job-name="tunnel"
#SBATCH --time=8:00:00 # walltime
#SBATCH --output="tunnel.out"
#SBATCH --error="tunnel.err"
#SBATCH [email protected]
#SBATCH --mail-type=BEGIN
/usr/sbin/sshd -D -p 2222 -f /dev/null -h ${HOME}/.ssh/id_rsa # uses the user key as the host key
NOTE: The private key file id_rsa could be whatever you named it to in your machine.
- Create another script named
submit.sh(or whatever name you prefer) with the following line.
sbatch tunnel.sh
- Open the
${HOME}/.ssh/configfile on your local machine and add the following lines
Host openmind-node # name it whatever you want
ProxyCommand ssh openmind "nc \$(squeue --me --name=tunnel --states=R -h -O NodeList) 2222" # see note below
StrictHostKeyChecking no
User hgazula # of course, please change this to your user name
IdentitiesOnly=yes
PreferredAuthentications publickey
PasswordAuthentication no
IdentityFile ~/.ssh/id_rsa # id_rsa should be replaced with your private key file name is
NOTE (Important):
- The first part of
ProxyCommandshould be the same command you use to connect to openmind. For some of you, it may bessh {username}@openmind.mit.eduor however you configured it in yourconfigfile. In my case, it isssh openmind. - Notice the
--name=tunnelis the job name specified in thetunnel.shfile.
- Open a terminal (vscode or wherever) and run
cat submit.sh | ssh openmind "bash -s"(Once again,ssh openmindis how I connect to openmind and should be replaced with how you connect) - Now go to VSCode and connect to the
openmind-nodeand you should be on the compute node.
- Note that you may not have access to the compute node as soon as you run the
cat submit.sh | ...command. Hence, I added the following lines intunnel.shto notify me when the job began (i.e. when the node is available) so step 2 doesn't fail. Of course, please use your own e-mail ID so I don't get your notifications.
#SBATCH [email protected]
#SBATCH --mail-type=BEGIN