student@ubuntu:~$
Guide All Platforms

VS Code Remote SSH

Edit and compile C code on the lab server from VS Code, with an SSH key and a short config alias so you stop retyping your password

You can edit, compile, and debug C on the lab server from inside VS Code. The Remote - SSH extension gives you the VS Code editor on your laptop with the files, compiler, and terminal running on the server. This guide walks you through it once, end to end.

You will:

  1. Install the Remote - SSH extension in VS Code
  2. Generate an SSH key so you stop retyping your EWU password
  3. Copy the public half of that key to the server
  4. Add a short alias (ssh lab-server) to your SSH config
  5. Connect VS Code to the server
  6. Install C tooling on the remote host

Before you start, make sure you can already SSH into the server from a plain terminal. If ssh YOUR_USERNAME@10.202.12.196 does not work yet, fix that first with the Mac, Windows, Linux, or Chromebook guide. The GlobalProtect VPN must be connected (portal vpn.ewu.edu) for anything in this guide to work from off campus.


What you are doing and why

Remote - SSH is a VS Code extension from Microsoft that runs the editor on your laptop but connects it to a remote shell, filesystem, and language server over SSH. Your laptop handles the UI. The server runs your code. That means you get real VS Code (syntax highlighting, Git integration, debugger) while working against the exact same gcc, make, and valgrind that the autograder uses.

An SSH key is a cryptographic pair (one file you keep private, one file you put on the server). Once the server has your public key, it recognizes your laptop by the math and stops asking for your password. That is both more secure (no password typed over the wire) and far less annoying.

An SSH config alias turns ssh jdoner02@10.202.12.196 -i ~/.ssh/id_ed25519 into ssh lab-server. Shorter, memorable, and VS Code picks it up automatically.


Step 1: Install the Remote - SSH extension

Open VS Code. If you do not have it yet, install it from code.visualstudio.com.

  1. Click the Extensions icon in the left sidebar. It looks like four squares with one detached. Keyboard shortcut: Cmd+Shift+X on Mac, Ctrl+Shift+X on Windows/Linux.
  2. In the search box at the top of the Extensions panel, type:

    Remote - SSH
    
  3. The first result should be Remote - SSH by Microsoft. Verify the publisher is “Microsoft” with the blue checkmark. There are lookalikes.
  4. Click the blue Install button.

When install finishes you will see a small monitor icon (><) appear in the bottom-left corner of the VS Code window. That is the Remote Indicator. Clicking it opens the Remote menu. We will use it in Step 5.

If you want the full set in one install (WSL, Dev Containers, and Remote - SSH), grab the Remote Development extension pack instead. For this course, plain Remote - SSH is enough.


Step 2: Generate an SSH key

You only do this once, ever. The key lives on your laptop and works for every server you add it to – GitHub, the lab server, any cloud VM you touch later.

Open a terminal on your laptop (not the server):

  • Mac: Cmd+Space, type Terminal, press Enter
  • Windows: Start menu, type PowerShell, press Enter
  • Linux: your usual terminal
  • Chromebook: the Linux (Crostini) terminal

Run:

ssh-keygen -t ed25519 -C "your_ewu_email@ewu.edu"

You will see three prompts.

1. “Enter file in which to save the key”: press Enter to accept the default. The key lands at ~/.ssh/id_ed25519 (Mac/Linux) or C:\Users\YOU\.ssh\id_ed25519 (Windows).

2. “Enter passphrase”: type a passphrase and press Enter. Type it again to confirm. A passphrase is a second factor – even if someone steals your laptop they cannot use the key without the passphrase. On Mac and Linux, ssh-agent can cache it so you only type it once per login session. An empty passphrase works but is not recommended.

3. Key saved. You now have two files:

  • ~/.ssh/id_ed25519 – the private key. Never share, never commit, never email this.
  • ~/.ssh/id_ed25519.pub – the public key. Safe to post publicly.

Ed25519 vs RSA

Modern OpenSSH defaults to Ed25519: shorter keys, faster, and cryptographically stronger than RSA-2048. Use Ed25519 unless a specific server refuses it (which the lab server does not).


Step 3: Copy your public key to the server

The server needs to know about your public key before it will trust the private one. The server stores trusted keys in ~/.ssh/authorized_keys inside your home directory on the server.

Mac, Linux, Chromebook -- one command
ssh-copy-id YOUR_USERNAME@10.202.12.196

It prompts for your EWU password one last time, then installs the key and fixes the remote permissions for you. Replace YOUR_USERNAME with your EWU username.

Windows (PowerShell) -- no ssh-copy-id, so pipe it manually

Windows OpenSSH does not ship ssh-copy-id. Run this one-liner instead, replacing YOUR_USERNAME:

Get-Content $env:USERPROFILE\.ssh\id_ed25519.pub | ssh YOUR_USERNAME@10.202.12.196 "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys"

This reads your public key, opens an SSH connection, creates ~/.ssh/ if needed, appends your key to authorized_keys, and sets the permissions OpenSSH requires (700 on the directory, 600 on the file).

Verify it worked

Close that terminal, open a fresh one, and run:

ssh YOUR_USERNAME@10.202.12.196

If you get in without being asked for a password (it may still ask for your key passphrase once), the key is installed correctly. Type exit to disconnect.


Step 4: Create an SSH config alias

Your SSH config is a plain text file where you teach ssh shortcuts. After this step, typing ssh lab-server will be equivalent to ssh jdoner02@10.202.12.196 -i ~/.ssh/id_ed25519.

Find your username on the lab server

If you do not know your EDURange username, SSH in once (ssh YOUR_USERNAME@10.202.12.196) and run:

whoami

That prints the exact username you need for the next step.

Edit the config file

The file lives at ~/.ssh/config on Mac/Linux, or C:\Users\YOU\.ssh\config on Windows. It may not exist yet.

The easiest way to edit it: open VS Code, press Cmd+Shift+P (Mac) or Ctrl+Shift+P (Windows/Linux) to open the Command Palette, and type:

Remote-SSH: Open SSH Configuration File...

Pick your user config (the first option). VS Code creates the file if it does not exist.

Add this block, replacing YOUR_USERNAME with your EDURange username:

Host lab-server
    HostName 10.202.12.196
    User YOUR_USERNAME
    IdentityFile ~/.ssh/id_ed25519

Save the file.

What each line means

Line What it does
Host lab-server The short name you will type. Pick anything.
HostName 10.202.12.196 The real IP address SSH dials.
User YOUR_USERNAME Your login on the server.
IdentityFile ~/.ssh/id_ed25519 Which key to use. Optional if you only have one key, but good hygiene.

Fix permissions (Mac/Linux only)

OpenSSH refuses to read a config file that other users can see. Run:

chmod 700 ~/.ssh
chmod 600 ~/.ssh/config

Windows uses ACLs instead of Unix permissions and handles this automatically.

Test it

ssh lab-server

If that lands you on the server, your config is working. Type exit.


Step 5: Connect VS Code to the server

Back in VS Code:

  1. Open the Command Palette (Cmd+Shift+P / Ctrl+Shift+P)
  2. Type:

    Remote-SSH: Connect to Host...
    
  3. VS Code shows a list of hosts from your SSH config. Click lab-server (or whatever alias you picked).
  4. A new VS Code window opens. The first time, it asks you to pick the remote OS – choose Linux.
  5. If your key has a passphrase, VS Code prompts for it. Otherwise it connects silently.
  6. Watch the bottom-left corner. When it reads SSH: lab-server in green, you are in.

Open your work

File > Open Folder... now browses the server’s filesystem, not your laptop. Navigate to where your labs live (typically ~/ on the server) and open that folder. From this point on, every file you edit is a file on the server. Every terminal you open (Ctrl+`) is a shell on the server.

The first connection takes 30 seconds or so. VS Code is downloading a small server component into ~/.vscode-server/ on the lab box. Subsequent connections are instant.


Step 6: Install C tools on the remote host

Here is the single most common trip-up with Remote - SSH: extensions install per-host. The C/C++ extension you installed on your laptop does nothing for remote code. You have to install it again into the remote session. VS Code makes this one click.

While connected to the server:

  1. Open Extensions (Cmd+Shift+X / Ctrl+Shift+X).
  2. Search for:

    C/C++
    
  3. The first result is C/C++ by Microsoft (extension ID ms-vscode.cpptools). Confirm the publisher.
  4. Click Install in SSH: lab-server. The button text explicitly says “Install in SSH” – that is how you know it is installing on the remote host, not your laptop.

What you get:

  • IntelliSense (autocomplete, go-to-definition) for C and C++
  • Inline error squiggles before you compile
  • A step-through debugger that wraps gdb on the server

Optional quality-of-life extensions

Install these the same way (each with “Install in SSH: lab-server”):

Extension Why you might want it
Error Lens (usernamehw.errorlens) Puts compiler warnings inline on the offending line instead of hiding them in the Problems panel. Great while you are still learning C’s error dialect.
GitLens (eamodio.gitlens) Shows who last touched each line (mostly you, but helpful when reviewing labs).
Makefile Tools (ms-vscode.makefile-tools) Parses your Makefile and adds a “build” button. Not required for CSCD 240, but handy.
Code Spell Checker (streetsidesoftware.code-spell-checker) Catches typos in comments and string literals.

Skip anything you do not need. The lab server is shared; fewer extensions means less load for everyone.


Step 7: Write and compile a C file

Confirm the whole chain works with a trivial program.

  1. In your opened remote folder, create hello.c:

    #include <stdio.h>
    
    int main(void) {
        printf("Hello from the lab server\n");
        return 0;
    }
    
  2. Open a terminal (Ctrl+`). Confirm the prompt shows your server username and hostname.
  3. Compile:

    gcc -Wall -Wextra -std=c99 hello.c -o hello
    
  4. Run:

    ./hello
    

If you see Hello from the lab server, you are fully set up.


If something goes wrong

What you see What it means Fix
VS Code spins forever on “Setting up SSH host” Either the VPN dropped, or the server’s first-connect download stalled Disconnect (GlobalProtect > Disconnect, then reconnect). In VS Code, Remote-SSH: Kill VS Code Server on Host... then reconnect.
Permission denied (publickey) Public key did not get to the server, or file permissions on the server are wrong Re-run Step 3. On the server, run ls -la ~/.sshauthorized_keys should be -rw------- and .ssh itself should be drwx------.
Could not establish connection to "lab-server" SSH config typo or wrong hostname Open the config file and re-check indentation. Then test from a plain terminal with ssh -v lab-server to see the verbose error.
LinuxPrereqs / “The remote host may not meet VS Code Server’s prerequisites for glibc and libstdc++” The server’s system libraries are older than VS Code’s minimum See the dedicated section below.
“The process tried to write to a nonexistent pipe” on Windows PowerShell OpenSSH hiccup, usually after sleep Close all VS Code windows, reopen. If it persists, Get-Service ssh-agent should report Running.
UNPROTECTED PRIVATE KEY FILE! Windows copied a key across machines and the ACLs are wrong Microsoft’s icacls fix – run the exact commands from the “Administrative user” section.
C/C++ IntelliSense shows “configurationProvider” warnings The extension cannot find your includes Cmd/Ctrl+Shift+P > C/C++: Edit Configurations (UI) > set Compiler path to /usr/bin/gcc and IntelliSense mode to linux-gcc-x64.
Red squiggles everywhere but code compiles fine C/C++ extension installed locally, not on the remote Go back to Step 6. Confirm the button said “Install in SSH: lab-server”.

If it is not on this table, drop into Discord with the exact error text.


The “LinuxPrereqs” / old-linux error

If you see a red-bordered panel in the VS Code terminal that says something like:

The remote host may not meet VS Code Server's prerequisites
for glibc and libstdc++ (The remote host does not meet the
prerequisites for running VS Code Server)

On the CSCD 240 lab server, this is a false positive. The server runs Ubuntu 24.04 with glibc 2.39, far above VS Code’s 2.28 floor. The error almost always means a previous connection left a corrupted or half-installed VS Code Server in your home directory, and VS Code is tripping over its own leftovers instead of over a real library problem. The fix is to wipe the leftovers and let VS Code reinstall cleanly.

Fix: wipe the stale VS Code Server directory

The fastest path, entirely from VS Code:

  1. Open the Command Palette (Cmd+Shift+P on Mac, Ctrl+Shift+P on Windows/Linux).
  2. Run Remote-SSH: Kill VS Code Server on Host... and pick lab-server.
  3. Run Remote-SSH: Connect to Host... again and pick lab-server.

That clears VS Code’s memory of the broken install and starts a fresh one. About 80% of the time this alone resolves it.

If the error comes back, wipe the directory manually from a plain SSH terminal:

ssh lab-server
rm -rf ~/.vscode-server ~/.vscode-server-insiders
exit

Then reopen VS Code and Remote-SSH: Connect to Host... again. This is the nuclear option and always works on a server that actually meets the prerequisites.

Verify the server actually meets the prerequisites

You should not need to check on the CSCD 240 lab server, but if you want to confirm, from a plain SSH session:

ldd --version | head -1
cat /etc/os-release | grep -E "PRETTY_NAME|VERSION_ID"

On the lab server you will see something like:

ldd (Ubuntu GLIBC 2.39-0ubuntu8.7) 2.39
PRETTY_NAME="Ubuntu 24.04.4 LTS"
VERSION_ID="24.04"

2.39 is well past the 2.28 minimum. If you ever see 2.27 or lower on some other server, that would be a real mismatch and you would need one of the workarounds in the aside below.

What to do if you hit this error on a different server that really does have old libraries

Current VS Code Server binaries need glibc 2.28+ and libstdc++ 3.4.25+. Those ship with Ubuntu 20.04+, Debian 10+, and RHEL/CentOS 8+. Older systems (Ubuntu 18.04, CentOS 7, Debian 9) physically cannot load the current server binary, and no amount of wiping ~/.vscode-server/ fixes that. Three workarounds, in order of simplicity:

Plain SSH + nano or vim. Every assignment in this class can be done from a plain terminal. Edit with nano (easy) or vim (steeper curve, already installed), compile with gcc, run, repeat. You lose the VS Code editor but the workflow still works.

Remote Tunnels (different connection mode, lower library requirements):

# On the server, one time
curl -Lk "https://code.visualstudio.com/sha/download?build=stable&os=cli-linux-x64" -o vscode-cli.tar.gz
tar -xf vscode-cli.tar.gz && rm vscode-cli.tar.gz
./code tunnel --accept-server-license-terms --name lab-server

Then on your laptop, install the Remote - Tunnels extension (ms-vscode.remote-server) and use Remote-Tunnels: Connect to Tunnel... in the Command Palette. Run the ./code tunnel process inside tmux or screen so it survives if your SSH drops.

Pin an older VS Code client. VS Code 1.85.2 (January 2024) was the last client whose bundled server supports glibc 2.17+. Download it from the VS Code update history page, install over your current VS Code, then Settings > Update Mode > none so it does not auto-upgrade back.


Tips & tricks

  • Remote-SSH: Reopen Folder in SSH lets you reopen a remote folder in one click from a fresh VS Code window.
  • Port forwarding: if you run a program on the server that serves HTTP on port 8080, VS Code’s “Ports” tab will forward it to localhost:8080 on your laptop so you can browse it. Useful for later labs that run small servers.
  • Settings sync: if you sign in with GitHub or Microsoft, VS Code syncs your settings, keybindings, and extension list across machines. Handy when you use both lab workstations and your laptop.
  • Keep a second SSH key for GitHub. When you start pushing labs, generate a separate key (ssh-keygen -t ed25519 -f ~/.ssh/id_github) and add an entry in ~/.ssh/config for Host github.com. Mixing server and GitHub keys on one identity is fine but separate keys are cleaner if one gets compromised.
  • If the VPN drops mid-edit, VS Code will show “SSH: disconnected” in the bottom-left. Reconnect GlobalProtect, then click the indicator and choose “Reconnect.” Your unsaved edits are held in memory and will flush to the server when the link returns.
  • Do not edit lab files on your laptop and copy them up. That is a recipe for line-ending drama and autograder failures. Edit in place on the server via Remote - SSH; compile on the server; submit from the server.

Sources