VS Code Remote
Using VS Code Remote Development, you can edit files, run visual breakpoint debuggers, and execute terminals directly on the remote server—while keeping the smooth, graphical interface of your local laptop.
This page covers the two primary workflows for connecting VS Code to the department and university servers.
1. Department Servers (Remote - SSH)
For department servers without Slurm scheduling, you can use the official Remote - SSH plugin to connect directly to the machine. This effectively starts a VS Code server instance on the Leviathan or Ghidorah node and links it to your local application.
Step-by-Step Setup:
1. Install the Extension: Open your local VS Code. Go to the Extensions tab (Ctrl+Shift+X or Cmd+Shift+X) and search for Remote - SSH (published by Microsoft). Install it.
2. Open the Command Palette: Press F1 or Ctrl+Shift+P (Windows/Linux) / Cmd+Shift+P (Mac).
3. Initialize Connection: Type Remote-SSH: Connect to Host... and press Enter. Select + Add New SSH Host...
4. Enter SSH Command: Type your SSH connection string. For the department servers, this will look like:
ssh [userid]@leviathan1.stat.cmu.edu
5. Connect & Authenticate: Select your SSH configuration file to save the host. A new VS Code window will open. If prompted, select Linux as the target operating system. Enter your password when prompted.
6. Open Folder: Click the "Open Folder" button in the Explorer pane to open your specific research directory on the server.
🔗 Video Tutorial: Connect VS Code to Remote Servers via SSH
For a visual walkthrough of installing the extension, setting up the host, and navigating the Remote Explorer panel.
2. Slurm Clusters (Remote Tunnels)
For massive clusters like Wright or PSC, you cannot simply SSH and start coding. The login node (the machine you first connect to) is strictly for submitting jobs; running heavy VS Code server processes there will drain resources and likely get your account suspended.
Instead, you must request a compute node using Slurm, launch a VS Code Tunnel on that specific node, and connect to it locally. Note: This guide assumes the code CLI is already installed on the cluster.
Step-by-Step Setup:
1. SSH into the Login Node: Open your standard terminal and SSH into the cluster.
2. Request an Interactive Compute Node: Use srun to request an interactive session with the resources you need. For example, to request 4 CPUs and 16GB of RAM for 2 hours:
srun --job-name vscode --time=2:00:00 --mem-per-cpu=48GB --partition=statds --ntasks=1 --gres=gpu:1 --cpus-per-task=2 --pty code tunnel
3. Authenticate the Tunnel: The terminal will output a secure link and an authentication code (usually linking to a GitHub or Microsoft account). Open this link in your local web browser and enter the provided code to link the session.
4. Connect to the Node: The terminal will then provide a vscode.dev/tunnel/... URL. Open this URL in your local browser to access the full VS Code interface running directly on your allocated compute node.
5. Alternative (Local App): If you prefer the desktop app over the browser, you can install the Remote - Tunnels extension in your local VS Code, sign in with the same account, and connect to the active tunnel listed in your Remote Explorer panel.