Skip to content

Set up VS Code on Engaging compute node (Method 01)

Yibei Chen edited this page Dec 7, 2025 · 1 revision

First, have your VS Code ready on your local laptop.

Set up on Engaging

Connect to Engaging

For example:

ssh <your-username>@orcd-login001.mit.edu

More information about the login nodes

orcd-login001 (Rocky 8), orcd-vlogin001 (CentOS 7)
orcd-login002 (Rocky 8), orcd-vlogin002 (CentOS 7)
orcd-login003 (Rocky 8), orcd-vlogin003 (CentOS 7)
orcd-login004 (Rocky 8), orcd-vlogin004 (CentOS 7)

These login nodes can be found in the documentation on the SSH Login page. You will want to use a login node whose operating system matches the compute nodes you regularly use. Launching jobs to nodes with a different operating system is not expected to work.

Request a compute node through SLURM

For example:

srun -n 8 -p ou_bcs_normal --mem=24GB -t 240 --pty bash

Change n_cpu (8 in this case), memory (24GB), partition (ou_bcs_normal), and time (240min) settings as needed. Don't require more resources than you need :)

Get the compute node number (e.g., 1803)

More information on job scheduling on Engaging: here

Set up on your local laptop/desktop

Modify config file

Go to your VS Code View->Command Palette -> Remote-SSH: Open SSH Configuration File... -> open your config file (e.g., Users/yibeichen/.ssh/config (this path is based on MacOS/Linux, Windows will be different), add the following:

Host eofe-login
  HostName orcd-login003.mit.edu
  User <your-username>
  IdentityFile ~/.ssh/id_rsa

Host eofe-compute
  HostName node1083
  ProxyJump eofe-login
  User <your-username>

Auto-update node number (e.g., 1083) in your config file

Since you get a new compute node for each session, updating the SSH config file manually can become repetitive. The Python script below automates this process.

  1. Save the following script as update_ssh_config.py in a memorable location on your local machine.
#!/usr/bin/env python3

import sys
import os
import re

def backup_config_file(config_path):
    """Create a backup of the config file."""
    backup_path = config_path + ".backup"
    with open(config_path, "r") as src, open(backup_path, "w") as dst:
        dst.writelines(src.readlines())
    print(f"Backup created at: {backup_path}")

if __name__ == '__main__':

    if len(sys.argv) != 2:
        print("Usage: eofe-compute <4-digit-code>")
        sys.exit(1)

    new_code = sys.argv[1]
    if not (len(new_code) in [3, 4]) or not new_code.isdigit():
        print("Usage: eofe-compute <3-digit-code or 4-digit-code>")
        sys.exit(1)

    config_path = os.path.join(os.path.expanduser('~'), ".ssh", "config")
    try:
        # Create a backup before making changes
        backup_config_file(config_path)

        # Read in the file
        with open(config_path, "r") as f:
            lines = f.readlines()

        # Update the relevant line
        updated = False
        for i, line in enumerate(lines):
            if "Host eofe-compute" in line:
                for j in range(i+1, len(lines)):
                    if re.search(r"HostName node\d{3,4}", lines[j]):  # Changed to match 3 or 4 digits
                        lines[j] = re.sub(r"node\d{3,4}", "node" + new_code, lines[j])
                        updated = True
                        break
            if updated:
                break
        # Write the file out again
        with open(config_path, "w") as f:
            f.writelines(lines)

    except FileNotFoundError:
        print(f"Error: File {config_path} not found.")
    except PermissionError:
        print(f"Error: No permission to read or write to {config_path}.")
    except Exception as e:
        print(f"Unexpected error: {e}")
  1. To run the script, open a new terminal on your local machine and execute it with your new node number. For example, if your node is node1803, you would run:
python update_ssh_config.py 4-digits # for example python update_ssh_config.py 1803

This will automatically find your .ssh/config file and update the HostName for eofe-compute.

Connect with VS Code

  • In VS Code, open the Command Palette (Cmd+Shift+P / Ctrl+Shift+P).
  • Type and select Remote-SSH: Connect to Host....
  • Choose eofe-compute from the list.

Open Your Project Folder

Once connected, you are "inside" the compute node.

  1. Click the "Open Folder" button in the Explorer sidebar (or go to File > Open Folder...).
  2. Enter the path to your project directory on the cluster (e.g., /home/<your-username>/my-project).
  3. Click "OK".

You're all set! You can now edit files and use the integrated terminal as if you were working directly on the compute node.

Go to your VS Code View->Command Palette -> Remote-SSH: Connect to Host... -> Choose eofe-compute

Suppose there are no error messages, DONE! you've successfully connected to the engaging compute node!