Visual Studio Code
Visual Studio Code (VS Code) is a popular code-integrated development environment. The CHPC provides several ways to launch VS Code directly on our systems - these are listed below.
On this page
The table of contents requires JavaScript to load.
Remote Development with Visual Studio Code and the CHPC
Visual Studio Code (VS Code) can be used to connect remotely to CHPC resources by targetting compute nodes for your ssh sessions. Compute nodes can be targetted through the use of Slurm tunnel scripts, the details of which are below.
A common pitfall when connecting to the CHPC through VS Code is targetting login/interactive nodes for your remote ssh sessions. Doing so runs the VS Code remote server on these shared resources, which can degrade performance for other users and trigger automated abuse warnings from Arbiter, which will limit your access to the compute resources on login nodes.
Instead of connecting to the login nodes, you should configure VS Code to connect directly to a Slurm job running on a compute node. Follow the steps below to allocate and utilize resources for your code development environment.
1. Reserving Resources
On a Notchpeak interactive (login) node, create a Slurm script called tunnel.slr which acts as a 'placeholder job'. Its sole purpose is to reserve a specific amount
of compute resources (CPU and Memory) on a cluster node and keep that reservation
active for a set duration of time. Copy and paste the code below into the tunnel.slr script:
#!/bin/bash
#SBATCH --job-name="tunnel"
#SBATCH --time=4:00:00 # walltime
#SBATCH --cpus-per-task=2 # number of cores
#SBATCH --mem-per-cpu=8G # memory per CPU core
#SBATCH --partition=notchpeak-shared-short
#SBATCH --account=notchpeak-shared-short
# Set job comment to BatchHost
scontrol update JobId="$SLURM_JOB_ID" Comment="`hostname -s`"
# Sleep holds the job in running state, the user has to scancel their job if they are done early.
sleep 4h
NOTE: walltime and sleep can be changed for sessions longer than 4 hours. Account and partition may also be changed.
2. Allocating and locating compute node
Submit the tunnel.slr job to Slurm with:
sbatch tunnel.slr
After submitting the tunnel.slr script to Slurm, check on the status of your submitted job with the 'squeue ' command.
*Note: Your job status is indicated under the 'ST' (Status) column. Make sure the 'R' (Running) status is present for the next steps.
squeue -M all --me --name=tunnel
3. Setting up ssh configuration
Modify ~/.ssh/config file on your client to be able to ssh directly to your allocated compute node.
| Cluster | Replace !notchpeak* notch* with: | Replace uNID@notchpeak1.chpc.utah.edu with: | Replace notch### with: |
| Lonepeak | !lonepeak* lp* | uNID@lonepeak1.chpc.utah.edu | lp### |
| Kingspeak | !kingspeak* kp* | uNID@kingspeak1.chpc.utah.edu | kp### |
| Granite | !granite* grn* | uNID@granite1.chpc.utah.edu | grn### |
4. Connecting to the compute node
Once your tunnel.slr job is running and you have updated your ~/.ssh/config file, you can connect via VS Code:
-
Open the Remote Window: In the bottom-left corner of the VS Code window, click the Remote Status icon.
-
Initiate Connection: Select "Connect to Host..." from the menu that appears at the top.
-
Select Your Host:
-
Choose the compute node name (e.g.,
notch001) from the list. -
If the node isn't listed: Hover over the "SSH" header in the Remote Explorer sidebar and click the Refresh (reload) icon. Once the list updates, try selecting the node again.
-
-
Authenticate: Enter your password when prompted. You will likely be asked to authenticate twice: once for the login node and once for the compute node.
-
Initialization: If this is your first time connecting to this node, VS Code will take a moment to install its remote server components. Subsequent connections will be much faster.
-
End Your Session: When you are finished, return to your terminal and run
scancel <job_id>to terminate the job and release your reserved resources.
With the use of DUO 2-factor authentication, we recommend to add a few new options to the VS Code client settings, as follows:
- In VS Code open the Extensions tab and search 'Remote SSH'
- Click on the option titled 'Remote - SSH' that is published by Microsoft and install it if it isn't already installed
- With the Extensions tab open and with the Remote-SSH package installed, click on the gear icon in the Remote-SSH container located in the bottom right corner of the box, then click 'Settings'
- Adjust the Remote.SSH: Connect Timeout to 60 seconds
- This will increases the SSH connection timeout to allow more time to complete your DUO 2-factor authentication
- Find the Remote.SSH: Show Login Terminal and check the box to always reveal the SSH login terminal
- Doing this switches the password and DUO push entry to the VS Code terminal
Alternatively, another option is to edit the settings.json file and add the following:
"remote.SSH.connectTimeout": 60,
"remote.SSH.showLoginTerminal": true,
Alternative Ways to Access VS Code
While connecting via SSH is the standard method for many developers, CHPC provides two alternative approaches if you need a graphical interface or specialized authentication requirements.
1. VS Code Server (via Open OnDemand)
This method runs VS Code directly in your browser. It is launched as an interactive app through the Open OnDemand portal.
-
How to access: Navigate to the Interactive Apps menu in the Open OnDemand dashboard and select the VS Code Server application. The form can be filled out to request compute resources and connect to VS Code. Futher documentation can be found on the Open OnDemand interactive app instructions.
-
Limitation: It does not support third-party authentication (e.g., signing into GitHub for Copilot or specific IDE extensions).
2. VS Code Desktop (via FastX or Open OnDemand)
If you need full control over your IDE including signing into GitHub, using Copilot, or syncing settings use the VS Code Desktop application.
-
How to access:
-
Open OnDemand: Select the VS Code Desktop app under the Interactive Apps menu.
-
FastX: Launch a desktop session, load the
vscodemodule (module load vscode), and run code from the terminal.
-
- Limitation: You will need to reserve a session on a compute node through the salloc command.
UMail and VS Code Connection Conflicts
If you sign into your local workstation or laptop using your University of Utah (UMail) account, you may encounter the following error when attempting to use VS Code tunnels:
Device management could not be enabled
Error code: -2145910764
Why this happens:
This issue occurs because University Information Technology (UIT) manages identity through Microsoft Azures Mobile Device Management (MDM) policies. These security policies are designed to protect institutional data, but they can inadvertently block the specific authentication required by the VS Code tunnel feature.
The Workaround:
To bypass this conflict, you must separate your workstation's OS login from your institutional identity:
-
Use a Personal Account: Sign into your local workstation or laptop using a personal Microsoft account (or a local user account) rather than your UMail credentials.
Note: If you are unable to change your workstation login, we recommend using the VS Code Desktop workflow described in the previous section, as it avoids the tunnel authentication conflict entirely.