Skip to content

Vscode

This tutorial describes how to interface VSCode with an interactive SLURM job.

To successfully use VScode with interactive job, you will need to establish a two-stage tunnel - from your computer to the login node, and from the login node to the compute node - because you do not have direct access to the compute node itself without a job running.

Extent of Support! Please Read!

We do not support external services that connect to our systems, including Cursor. The only GUI IDE we support interacting with our servers is vanilla VSCode. Using anything else is fully outside the scope of our support; you're on your own.

Prerequisite Steps

  • You'll need to create a private ssh key on a login node on each cluster by running:

    ssh-keygen -b 521 -t ECDSA -C "$USER@$HOSTNAME"
    

  • Pick a number between 7000 and 8000 by running:

    echo $(( 7000 + RANDOM%1000 ))
    

Random Port Number

The command above will randomly generate a port number that you would need later. It should be unique for each individual on the cluster. If in the future you have issue with this port, just choose another and don't forget to change it in your configuration files.

  • On your computer, open up ~/.ssh/config and add the following lines, where $LOGIN is your username on the cluster and $PORTNUMBER is your VSCode port number that you have just generated:
Host galvani-login1 
  HostName 134.2.168.43 # login node 1
  User $LOGIN
  ForwardAgent yes

Host galvani-login2
  HostName 134.2.168.114 # login node 2 - default
  User $LOGIN
  ForwardAgent yes

Host mlc-galvani-vs
  User $LOGIN
  ProxyCommand ssh -o 'ForwardAgent yes' $LOGIN@galvani-login.mlcloud.uni-tuebingen.de "nc \$(squeue --me --name=vs --states=R -h -O NodeList) $PORTNUMBER"
  StrictHostKeyChecking no
  ForwardAgent yes

For Windows Users

If you are on Windows, use nc $(squeue --me --name=vs --states=R -h -O NodeList) $PORTNUMBER (without the backslash before $) and replace -o 'ForwardAgent=yes' with -A

This creates the quick commands needed to get VSCode to interface with the compute nodes.

  • On the Cluster Login nodes, create the following file as $WORK/vscode/allocate-galvani-vs.sh and replace $PORTNUMBER with your VSCode port number:
#!/bin/bash
#SBATCH --job-name="vs" # job-name will be used in ~/.ssh/config above
#SBATCH --partition=2080-galvani
#SBATCH --time=9:00:00 # walltime
#SBATCH --gpus=1 # for example request one default gpu
/usr/sbin/sshd -D -p $PORTNUMBER -f /dev/null -h ${HOME}/.ssh/id_ecdsa # uses the user key as the host key

Connect VSCode to the Compute Node Running the Job

To connect VSCode on your machine to the compute node, first, run the following commands:

  • Connect to the appropriate login node using ssh galvani-login1 or ssh galvani-login2

  • Request compute resources while logged into the login node by submitting:

sbatch --partition=2080-galvani -t 12:00:00  -c 4 --qos=vs --gres=gpu:1 $WORK/vscode/allocate-galvani-vs.sh
This should allocate the compute node accordingly and set up the first stage of the two-stage tunnel.

  • Now, in VSCode, click on the blue connection icon in the lower-left, select "Connect to Host", and then select "mlc-galvani-vs" from the dropdown. This should connect you directly to the compute job you created, and you can now work directly through VSCode.

Problems & Troubleshooting

If you run into problems with VSCode, don't panic. Due to its complexity, VSCode often has problems, some of which can be easily resolved. Try the following steps; if you have followed these steps and still have problems, please open a service ticket and provide as many details as you can about the problem, circumstances, and configurations you are using, as well as what steps you have taken to try to resolve the problem.

  • First, delete the .vscode-server folder in your $HOME directory. See if this works.
  • Second, run echo $(( 7000 + RANDOM%1000 )) on the login node to pick a new value for the $PORTNUMBER, and then manually update this value on your local machine's ~/.ssh/config file & the login node's $WORK/vscode/allocate-galvani-vs.sh file.

The following advice relates to older versions of VSCode; some users may find it helpful.

  • Now connect to the second stage of the tunnel by running, on your machine:

ssh mlc-galvani-vs
This will start the necessary two-stage tunnel.

Now, connect the VSCode program to the remote server via the two-stage tunnel you've established.


Last update: March 25, 2026
Created: June 21, 2024