VS Code

Instructions for using VS Code with NowWhat.

This page describes how to start a Visual Studio Code Remote SSH session on NowWhat.

VS Code Remote SSH runs the VS Code user interface on your local machine while files, terminals, Python sessions, R sessions, and extensions run on the remote host reached through SSH.

On NowWhat, VS Code must run on a compute node allocated by SLURM. Do not start VS Code remote sessions, Python sessions, R sessions, or other interactive workloads on the login node.

Requirements

Before configuring VS Code, make sure that:

  • Visual Studio Code is installed on your local machine
  • the VS Code extension Remote - SSH is installed locally
  • you can reach the NowWhat login node from your network or VPN
  • you can log in from a terminal with SSH
  • your remote home directory has enough free space for the VS Code server files

The login node is:

nowwhat.stat.unipd.it

The compute nodes available for VS Code sessions are:

wn01
gn01

The login node is only the SSH entry point and jump host. The VS Code remote server should be started on wn01 or gn01 while you have an active SLURM allocation on that node.

Verify SSH from a Terminal

First confirm that a normal SSH connection to the login node works outside VS Code:

ssh your_username@nowwhat.stat.unipd.it

If this command fails, fix the SSH or network issue before opening VS Code.

After logging in, you can close the terminal session:

exit

Step 1: Add an SSH Host Alias

On your local machine, edit your SSH configuration file:

nano ~/.ssh/config

Add one alias for the login node and one alias for each compute node. The compute-node aliases must route the SSH connection through the login node. This is required because compute-node ports are not reachable directly from your local machine.

Host nowwhat-login
  HostName nowwhat.stat.unipd.it
  User your_username
  Port 22
 
Host nowwhat-wn01
  HostName wn01
  User your_username
  Port 22
  ProxyCommand ssh nowwhat-login -W %h:%p
 
Host nowwhat-gn01
  HostName gn01
  User your_username
  Port 22
  ProxyCommand ssh nowwhat-login -W %h:%p

Replace your_username with your NowWhat username.

If you use an SSH key, add the identity file to the login alias:

Host nowwhat-login
  HostName nowwhat.stat.unipd.it
  User your_username
  Port 22
  IdentityFile ~/.ssh/id_ed25519
 
Host nowwhat-wn01
  HostName wn01
  User your_username
  Port 22
  ProxyCommand ssh nowwhat-login -W %h:%p
 
Host nowwhat-gn01
  HostName gn01
  User your_username
  Port 22
  ProxyCommand ssh nowwhat-login -W %h:%p

If you use a ProxyJump (LISA):

Host lisa
  HostName lisa.stat.unipd.it
  User your_username
  ControlMaster auto
  ControlPersist 12h
  ControlPath ~/.ssh/cm-%r@%h:%p
 
Host nowwhat
  HostName nowwhat.stat.unipd.it
  User your_username
  Port 22
  ProxyCommand ssh -W %h:%p lisa
 
Host gn01
  HostName gn01
  User your_username
  Port 22
  ProxyCommand ssh nowwhat -W %h:%p
 
Host wn01
  HostName wn01
  User your_username
  Port 22
  ProxyCommand ssh nowwhat -W %h:%p

Test the login alias from your local terminal:

ssh nowwhat-login

Do not test nowwhat-wn01 or nowwhat-gn01 yet unless you already have an active SLURM allocation on that node.

ProxyCommand ssh nowwhat-login -W %h:%p means: connect to the login node first, then ask the login node to open the final SSH connection to wn01 or gn01.

Step 2: Configure VS Code Remote SSH Settings

Before connecting to a compute node, configure VS Code Remote SSH for the NowWhat topology. Compute-node ports are reachable only through the login node, so VS Code should use a socket-based remote server and avoid its local-server connection mode.

These settings go in VS Code's local User Settings on your computer. They do not go in Remote Settings and they do not go in ~/.ssh/config.

Open VS Code locally, before starting a Remote SSH session, then open the Command Palette:

Ctrl + Shift + P

Search for:

Preferences: Open User Settings (JSON)

Add:

{
  "remote.SSH.remoteServerListenOnSocket": true,
  "remote.SSH.useLocalServer": false
}

If your User Settings JSON already contains other settings, add only these properties inside the existing JSON object.

The two required settings are:

  • remote.SSH.remoteServerListenOnSocket: makes the VS Code server listen on a Unix socket instead of exposing a TCP port on the compute node
  • remote.SSH.useLocalServer: disables VS Code's local-server connection mode, which can fail when compute-node ports are reachable only through the login node

After changing these settings, close any open Remote SSH windows before reconnecting.

Step 3: Start a SLURM Allocation for VS Code

Before connecting VS Code to a compute node, start a SLURM job that keeps the node allocated. This job is only used to reserve the node for your remote IDE session.

Connect to the login node:

ssh nowwhat-login

Option A: Interactive srun

For a CPU session on wn01:

srun --partition=cpu --nodelist=wn01 --time=02:00:00 --ntasks=1 --cpus-per-task=4 --mem=8G sleep 2h

For a GPU session on gn01:

srun --partition=gpu --nodelist=gn01 --time=02:00:00 --ntasks=1 --cpus-per-task=4 --mem=16G --gres=gpu:nvidia_h200_nvl_1g.35gb:1 sleep 2h

Keep this terminal open. The allocation ends when the command exits, and VS Code will lose the remote backend.

Option B: Batch sbatch

If you prefer a detached allocation, submit a batch job that sleeps for the duration of your VS Code session.

For wn01, save a file named vscode-wn01.sbatch on the login node:

#!/bin/bash
#SBATCH --job-name=vscode-wn01
#SBATCH --partition=cpu
#SBATCH --nodelist=wn01
#SBATCH --time=02:00:00
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=4
#SBATCH --mem=8G
#SBATCH --output=vscode-%j.out
#SBATCH --error=vscode-%j.err
 
echo "VS Code allocation running on $(hostname)"
sleep 2h

Submit it:

sbatch vscode-wn01.sbatch

For gn01, use:

#!/bin/bash
#SBATCH --job-name=vscode-gn01
#SBATCH --partition=gpu
#SBATCH --nodelist=gn01
#SBATCH --gres=gpu:nvidia_h200_nvl_1g.35gb:1
#SBATCH --time=02:00:00
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=4
#SBATCH --mem=16G
#SBATCH --output=vscode-%j.out
#SBATCH --error=vscode-%j.err
 
echo "VS Code allocation running on $(hostname)"
sleep 2h

Check that the job is running before connecting VS Code:

squeue -u your_username

The job must be in the RUNNING state on the node you want to use.

Test SSH to the Allocated Compute Node

After the SLURM allocation is running, open a new terminal on your local machine and test the compute-node SSH alias.

For wn01:

ssh nowwhat-wn01

For gn01:

ssh nowwhat-gn01

Then check the hostname:

hostname

It should print wn01 or gn01. If SSH fails, check that the SLURM allocation is still running on that node and that your SSH config uses ProxyCommand ssh nowwhat-login -W %h:%p.

Step 4: Connect from VS Code

Open VS Code on your local machine.

Open the Command Palette and run:

Remote-SSH: Connect to Host...

Select the compute-node host from your SSH configuration:

nowwhat-wn01

or:

nowwhat-gn01

Do not select nowwhat-login for a VS Code working session. The login-node host is useful for basic SSH testing only.

During the first connection, VS Code installs a matching VS Code server in your remote home directory. Wait until the remote window opens. The bottom-left status indicator should show that VS Code is connected to the remote SSH host.

The remote host shown by VS Code should be wn01 or gn01, not the login node.

Step 5: Open a Remote Folder

Once connected, open a folder from the remote filesystem.

Open the Command Palette and run:

File: Open Folder...

For example:

/home/your_username

or a project directory:

/home/your_username/projects/my-project

The Explorer, integrated terminal, Python sessions, R sessions, and installed remote extensions now refer to the remote NowWhat environment, not to files on your laptop.

The VS Code session remains valid only while the SLURM allocation is active. When the srun command exits or the sbatch sleep job finishes, the compute allocation ends and the VS Code remote backend should be considered invalid.

Step 6: Install Remote Extensions

VS Code extensions that need to inspect files, run interpreters, or start language servers must be installed on the remote SSH host.

In a VS Code window already connected to NowWhat through SSH, open the Command Palette and run:

Extensions: Install Extensions

Install the extensions you need in the remote environment. Common choices are:

  • Python
  • R

In the Extensions view, VS Code should show these extensions under the remote SSH target, such as SSH: nowwhat-wn01 or SSH: nowwhat-gn01.

Step 7: Configure Python

VS Code can discover some Python interpreters automatically, but NowWhat also provides Python installations under shared paths such as /software/spack/linux-zen4 and /software/envs/micromamba/envs.

Run this command on the remote server, inside the VS Code terminal:

find /software/spack/linux-zen4 /software/envs/micromamba/envs \
  \( -path "*/bin/python" -o -path "*/bin/python3" \) \
  -type f -executable 2>/dev/null | sort

Then open the Command Palette and run:

Python: Select Interpreter

If the interpreter you need is not listed, choose:

Enter interpreter path...

Then paste one of the /software/.../bin/python paths returned by the find command.

To pin a Python interpreter for the current remote workspace, open the Command Palette and run:

Preferences: Open Workspace Settings (JSON)

Add:

{
  "python.defaultInterpreterPath": "/software/envs/micromamba/envs/nw-rpy-sc/bin/python"
}

Use the path returned by the find command.

Check the selected Python environment from the VS Code terminal:

python -c "import sys; print(sys.executable); print(sys.version)"

The printed path should match the /software/... interpreter you selected.

Step 8: Configure R

VS Code can use NowWhat R installations through the R extension. NowWhat provides R installations under shared paths such as /software/spack/linux-zen4 and /software/envs/micromamba/envs.

Run this command on the remote server, inside the VS Code terminal:

find /software/spack/linux-zen4 /software/envs/micromamba/envs \
  -path "*/bin/R" -type f -executable 2>/dev/null | sort

To pin an R binary for the current remote workspace, open the Command Palette and run:

Preferences: Open Workspace Settings (JSON)

Add:

{
  "r.rpath.linux": "/software/envs/micromamba/envs/nw-rpy-sc/bin/R",
  "r.rterm.linux": "/software/envs/micromamba/envs/nw-rpy-sc/bin/R"
}

Use one of the /software/.../bin/R paths returned by the find command.

The settings are:

  • r.rpath.linux: R executable used by the R extension and language services
  • r.rterm.linux: R executable used when VS Code starts an interactive R terminal

After saving the settings, open the Command Palette and run:

Developer: Reload Window

Then run:

R: Create R Terminal

Check the selected R environment:

Sys.which("R")
R.home()
version$version.string

The printed path should match the /software/... R binary you added to the workspace settings.

When Environments Change

NowWhat environments can change over time. Modules, Spack installations, micromamba environments, or versioned paths may be added, removed, renamed, or rebuilt.

If one or more expected environments no longer appear or stop working in VS Code:

  1. rerun the find commands above on the remote server
  2. update python.defaultInterpreterPath, r.rpath.linux, or r.rterm.linux in Workspace Settings
  3. save the JSON file
  4. reload the VS Code remote window
  5. run Python: Select Interpreter or R: Create R Terminal again