Visual Studio Code
Visual Studio Code (VSCode) is a popular code integrated development environment. CHPC provides several ways to launch it directly on our systems. We list these alternatives below.
Apart from that, many users install it on their local machines and set it up to remotely access CHPC machines. Below we describe how to do that while avoiding getting the interactive node abuse e-mails.
On this page
The table of contents requires JavaScript to load.
Remote Development with VS Code and CHPC
You can use Visual Studio Code to connect remotely to CHPC resources, however, a common pitfall is connecting directly to the login/interactive nodes. 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 our Arbiter interactive node monitoring system.
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 node create a SLURM script called tunnel.slr which is essentially 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, even if you aren't running a scientific simulation yet.
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 but it is recommended that the shared equivalent of the partition is used unless you plan to run a heavy computational program in VS Code you will likely not need the whole node.
2. Allocating and locating compute node
Submit the tunnel.slr job in an interactive node terminal with:
sbatch tunnel.slr
Run the squeue command on the same cluster where you submitted the job.
Note: Your job status is indicated under the 'ST' column with an 'R' for running. Make sure the 'R' is present for the next steps.
squeue --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.,
notchpeak-c123) 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 introduction of the 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
- 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 for the DUO 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
Another option is to edit the settings.json file and add the following:
"remote.SSH.connectTimeout": 60,
"remote.SSH.showLoginTerminal": true,
GitHub Copilot is an extension that can be installed into the remote development workspace. It can be helpful for adding Git integration to your projects, generating test suites, and optimizing workflows depending on the extension installed.
Here are the steps:
- In VS Code open the Extensions tab and search 'GitHub Copliot'
- Choose which GitHub Copliot extension best suits your needs
- Click the 'Install in SSH: XXX node' button
- Follow instructions for signing in to your GitHub Account
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. Follow the intuitive Open OnDemand interactive app instructions to configure the resources for your job.
-
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.
-
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.