6 Configure MetaCentrum remote development in VS Code
7 Note
This tutorial assumes that you successfully configured VSCode and have already created a Mamba environment on the HPC cluster. If VSCode is properly working, you can just open a terminal manually and click on the run button in every code cell, and the code will be sent to your currently active terminal. If VSCode is not configured yet, you can copy and paste the code snippets in this tutorial into a terminal. Probably you’ll need Ctrl+Shift+V to paste in the terminal.
8 Goal
This chapter explains the recommended MetaCentrum workflow where the VS Code server runs on a compute node and the UI runs on your personal computer.
9 Configure MetaCentrum for VS Code (recommended method)
The official recommendation is to run the VS Code server on a computing node (inside a job), not on a shared frontend.
9.1 Prerequisites
- VS Code extension: Remote - SSH (Microsoft)
- Your MetaCentrum account and SSH access to a frontend (for example
skirit.metacentrum.cz) - A free TCP port between
7000and30000(example below uses26759)
9.2 1. Create a local SSH key for this workflow
On your personal computer:
ssh-keygen -f ~/.ssh/metacentrum_vscodeThis creates:
- private key:
~/.ssh/metacentrum_vscode - public key:
~/.ssh/metacentrum_vscode.pub
9.3 2. Configure ~/.ssh/config on your personal computer
Pick your preferred frontend and chosen port, then add entries similar to:
Host skirit.metacentrum.cz
Port 22
PubkeyAuthentication no
Host *.cerit-sc.cz *.fav.zcu.cz *.fzu.cz *.grid.cesnet.cz *.hw.elixir-czech.cz *.ibot.cas.cz *.ics.muni.cz *.metacentrum.cz *.meta.zcu.cz *.natur.cuni.cz *.nti.tul.cz *.ueb.cas.cz
Port 26759
IdentityFile ~/.ssh/metacentrum_vscode
This tells VS Code to use your selected port and key when connecting to compute nodes.
9.4 3. Start an interactive job and launch SSH server on the compute node
First request an interactive job from a frontend:
qsub -I -N vscode_dev -l select=1:ncpus=4:mem=16gb -l walltime=04:00:00After the shell opens on the compute node, run:
mkdir -p "$SCRATCHDIR/.ssh"
chmod 700 "$SCRATCHDIR/.ssh"
rm -f "$SCRATCHDIR/.ssh/server_key" "$SCRATCHDIR/.ssh/server_key.pub"
ssh-keygen -f "$SCRATCHDIR/.ssh/server_key" -N "" -C "VSCode" -q -t ed25519
touch "$SCRATCHDIR/.ssh/authorized_keys"
chmod 600 "$SCRATCHDIR/.ssh/authorized_keys"Now append your local public key (from ~/.ssh/metacentrum_vscode.pub) into authorized_keys on the compute node:
cat >> "$SCRATCHDIR/.ssh/authorized_keys"
# paste one line from ~/.ssh/metacentrum_vscode.pub, then press Ctrl+DChoose/check port and start SSH daemon:
PORT=26759
netstat -tan | grep -q "0.0.0.0:$PORT " && { echo "Port $PORT is busy"; exit 1; }
/usr/sbin/sshd -D -p "$PORT" \
-o "HostKey $SCRATCHDIR/.ssh/server_key" \
-o "PermitRootLogin no" \
-o "PasswordAuthentication no" \
-o "ChallengeResponseAuthentication no" &
hostnameKeep this job running. The printed hostname is the compute node you will connect to from VS Code.
9.5 4. Connect from VS Code to the compute node
Use Ctrl+Shift+P:
Remote-SSH: Connect to Host...- Enter/select the compute-node hostname printed by
hostname
Because of your SSH config, VS Code will use port 26759 and key ~/.ssh/metacentrum_vscode.
9.6 5. Validate the connection in VS Code terminal
hostname
whoami
pwdYou should see your compute-node hostname, your username, and your working directory.
10 Notes for HPC Work
- Use frontends for login and job submission only.
- Run development workloads in compute-node jobs.
- When the job ends, the compute-node SSH server also ends.