Visual Studio Code

Provides access to a Visual Studio Code web interface. 

Activating a Python virtual environment

Currently supported distributions for using conda/virtual enviornments in VS Code are:

  • python3.[9,10,11]-anaconda
  • mamba/py3.[10,11,12]

Activating virtual environments created from standard python distributions ($ module load python) may work only If they are activated prior to launching VS Code. To achieve that, you may utilize the "source setup script" option.

Create the setup script file:

  • Open a terminal and run:

    vim setup.sh
  • Add the following lines (assuming your virtual environment is called venv):

    #!/bin/bash
    module load python
    source venv/bin/activate
  • Save and close, and set execute permissions (optional):

    chmod +x setup.sh
  • When launching your VS Code session, in the "Source this setup file" provide the absolute path to your setup script. For example:

    /home/<uniquename>/setup.sh

Installing extensions

Visual Studio code Open OnDemand application executes through a compute node which requires that a proxy be correctly configured in order to allow access to external networks, such as through the internet. When downloading VS Code extensions through the marketplace (marketplace.visualstudio.com) this requires setting up the following proxy variable (/etc/profile.d/http_proxy.sh)

To automate this setup, you can append the following line to your ~/.bashrc file, and then launch your VS Code application.

echo -e 'source /etc/profile.d/http_proxy.sh' >> ~/.bashrc

Alternatively, a setup script that sources the http_proxy.sh script may also be used, following the methods described above for Python.

Connecting to Great Lakes Compute Nodes via Local VS Code (SSH)

This guide explains how to connect your local VS Code installation directly to Great Lakes compute nodes using SSH with a jump host configuration. This allows you to work on compute nodes with the full power of your local VS Code setup.

Prerequisites:

  • An active Great Lakes account
  • VS Code installed on your local machine
  • Remote - SSH extension installed in VS Code
  • An active job running on a compute node

1Generate SSH Keys (If You Don't Have One)

SSH keys allow you to authenticate securely without typing your password every time.

On macOS/Linux:

  1. Open Terminal
  2. Run the following command:

    ssh-keygen -t ed25519 -b 4096
  3. When prompted for a file location, press Enter to accept the default (~/.ssh/id_ed25519)
  4. Optionally, enter a passphrase for added security (or press Enter for no passphrase)
  5. Your keys will be generated:
    • Private key: ~/.ssh/id_ed25519
    • Public key: ~/.ssh/id_ed25519.pub

On Windows:

  1. Open PowerShell or Command Prompt
  2. Run the following command:

    ssh-keygen -t ed25519 -b 4096
  3. When prompted for a file location, press Enter to accept the default (C:\Users\<YourUsername>\.ssh\id_ed25519)
  4. Optionally, enter a passphrase for added security (or press Enter for no passphrase)
  5. Your keys will be generated:
    • Private key: C:\Users\<YourUsername>\.ssh\id_ed25519
    • Public key: C:\Users\<YourUsername>\.ssh\id_ed25519.pub

2Copy Your Public Key

You need to copy the contents of your public key file to add it to Great Lakes.

On macOS/Linux:

cat ~/.ssh/id_ed25519.pub

This will display your public key. Select and copy the entire output (starts with ssh-ed25519 ...).

On Windows (PowerShell):

type C:\Users\<YourUsername>\.ssh\id_ed25519.pub

Or using Command Prompt:

type %USERPROFILE%\.ssh\id_ed25519.pub

Select and copy the entire output (starts with ssh-ed25519 ...).

3Add Your Public Key to Great Lakes

  1. Login to Great Lakes from your terminal:

    ssh <umich-uniquename>@greatlakes.arc-ts.umich.edu
  2. Edit the authorized_keys file:

    nano ~/.ssh/authorized_keys

    Or if you prefer vi:

    vi ~/.ssh/authorized_keys
  3. Paste your public key (from Step 2) on a new line at the end of the file
  4. Save and exit:
    • In nano: Press Ctrl+O (to save), then Enter, then Ctrl+X (to exit)
    • In vi: Press Esc, type :wq, then press Enter
  5. Set correct permissions (important for security):

    chmod 700 ~/.ssh
    chmod 600 ~/.ssh/authorized_keys
  6. Logout from Great Lakes:

    exit

4Configure SSH Jump Host on Your Local Machine

Now you'll configure your local SSH to use the login node as a "jump host" to reach compute nodes.

On macOS/Linux:

  1. Open or create the SSH config file:

    nano ~/.ssh/config
  2. Add the following configuration:

    Host gl-login
        HostName greatlakes.arc-ts.umich.edu
        User <umich-uniquename>
    Host gl-compute
        HostName <YOUR_COMPUTE_NODE>
        User <umich-uniqname>
        ProxyJump gl-login
  3. Replace <YOUR_COMPUTE_NODE> with your actual compute node (e.g., gl3000, gl3001, etc.)
  4. Save and exit: Press Ctrl+O, Enter, then Ctrl+X

On Windows:

  1. Open PowerShell and create/edit the SSH config file:

    notepad C:\Users\<YourUsername>\.ssh\config

    If the file doesn't exist, Notepad will ask if you want to create it. Click Yes.

  2. Add the following configuration:

    Host gl-login
        HostName greatlakes.arc-ts.umich.edu
        User <umich-uniqname>
    Host gl-compute
        HostName <YOUR_COMPUTE_NODE>
        User <umich-uniqname>
        ProxyJump gl-login
  3. Replace <YOUR_COMPUTE_NODE> with your actual compute node (e.g., gl3000, gl3001, etc.)
  4. Save and close Notepad

5Start an Interactive Job on Great Lakes

Important: Compute nodes are only accessible when you have an active job running on them.
  1. Login to Great Lakes:

    ssh <umich-uniqname>@greatlakes.arc-ts.umich.edu
  2. Start an interactive job on a specific node:

    salloc --account=<your_account> --partition=standard --nodes=1 --ntasks-per-node=1 --mem=4GB --time=04:00:00
  3. Note the compute node name from the output (e.g., gl3000, gl3155, etc.)
  4. Update your SSH config (from Step 4) with this compute node name if you haven't already
  5. Keep this session active (don't close the terminal) while you use VS Code

6Connect VS Code to the Compute Node

  1. Open VS Code on your local machine
  2. Open the Command Palette: Press Ctrl+Shift+P (Windows/Linux) or Cmd+Shift+P (macOS)
  3. Select: Remote-SSH: Connect to Host...
  4. Choose: gl-compute (the host you configured in Step 4)
  5. VS Code will connect through the login node to your compute node
  6. Open your project folder on the compute node and start coding!

Troubleshooting SSH Connection

IssueSolution
Permission Denied• Ensure your public key is correctly added to ~/.ssh/authorized_keys on Great Lakes
• Check file permissions: chmod 600 ~/.ssh/authorized_keys
Connection Timeout• Ensure you have an active job running on the compute node
• Verify the compute node name in your SSH config matches your job's node
• In VS Code, search for remote.SSH.connectTimeout and increase timeout value to a larger integer
VS Code Can't Find Config• macOS/Linux: ~/.ssh/config
• Windows: C:\Users\<YourUsername>\.ssh\config
Proxy Jump Not Working• Test manually: ssh gl-compute
• If it works but VS Code doesn't, try reloading VS Code
Remote SSH 2FA - Unable to acces terminal to enter 2FA option

You can also modify your SSH connection settings to handle 2FA:

  1. Open VS Code Settings (Cmd+, or Ctrl+,)
  2. Search for: remote.SSH.showLoginTerminal
  3. Enable this setting - this forces VS Code to show an interactive terminal for the SSH login process

This way, all prompts (password, 2FA, etc.) will appear in a proper terminal window where you can type.