using remote-ssh and vscode

This page explains how you can remotely access your CS lab files through vscode if you want to work from home.

You can use Visual Studio Code (“vscode”), installed on your computer, to edit files on the CS lab computers. Here’s the outline of how to do that:

That last step (closing the connection) is important as vscode sometimes leaves stray processes running if you don’t close everything when done, and some of these processes can consume large amounts of CPU and memory.

installing vscode

Starting at the vscode website you should be able to select the version most appropriate for your computer. For example, on a Mac, you should be presented with a button that allows you to “Download Mac Universal” and on Windows you should see “Download for Windows”.

installing the Remote-SSH extension

In order to edit files on the CS computers, you will need to install the Remote-SSH extension:

  1. start vscode if it is not already running
  2. click on the extensions icon (extensions icon) on the left side of the vscode window to open the Extensions panel
  3. at the top, in the Search bar, type in “remote ssh”
  4. check to make sure you have the correct “Remote - SSH” extension (created by Microsoft, over 16 million downloads)
  5. click the “Install” button

configuring the Remote-SSH extension

Now that you’ve installed the Remote-SSH extension, we need to configure it.

  1. click the “open a remote window” icon (remote ssh icon) at the bottom left of the vscode window
  2. choose “Connect to Host… Remote-SSH” in the dropdown
  3. select “+ Add New SSH Host…”
  4. type “ssh USERNAME@cslab.cs.swarthmore.edu” where USERNAME is your login ID at Swarthmore (e.g. csmajor1) and press return
  5. at the “Select SSH configuration file to update” prompt, just press return to select the default first option
  6. a popup should appear at the bottom right of the screen that says “Host added!”

Note: cslab.cs.swarthmore.edu is an alias that gets expanded to one of many computers. If you want to connect to a specific computer, such as coconut, then use that hostname when adding a new ssh host.

Using the Remote-SSH Extension

Every time you want to use the Remote-SSH extension, you will need to follow these steps:

  1. start by clicking the “open a remote window” icon (remote ssh icon) at the bottom left of the vscode window
  2. choose “Connect to Host… Remote-SSH”
  3. select the hostname you configured (e.g., cslab.cs.swarthmore.edu)
  4. if this is the first time you are connecting to a host, it will show the host ssh fingerprint and ask if you want to continue connecting (press “Continue”)
  5. type your CS password in the next box
  6. in the bottom right of the screen, it will say “Setting up SSH Host cslab…” This may take 30-60 seconds to complete.
  7. once connected, choose “Open Folder”, where you can pick a working directory
  8. you may get a window pop up that says “Do you trust the authors of the files in this folder?” Press the button that says “Yes, I trust the authors”.
  9. use the navigation pane on the left side to select the file you want to edit.

closing the connection

When you are done working, please remember to close the connection. Use the green button in the bottom left corner to Close Remote Connection.

vscode closing remote connection

See also:


Back to SwatCS Help Docs