Overview

The Visual Studio Code editor is able to connect to a Linux server using SSH, to remotely edit, run, and debug code.  VS Code can also upload/download files, and open a shell command session on the Linux server.

To make a secure and more convenient connection to the server we will use SSH keys, which enables a remote session without repeatedly typing in your password.

Initial Configuration

  1. Ensure that the OpenSSH Client is installed on your Windows laptop.  It is probably already there, but if not you can install it in your Windows Settings at Apps > Apps and Features > Manage Optional Features
  2. The server is not publicly accessible, so if you are off-campus or on wireless, connect to the Carleton VPN.
  3. In VS Code, install the Remote – SSH extension
  4. In VS Code, connect to the server by pressing the Remote Window button in the bottom left:

    select Connect to host…

    For your username and IP address, type ssh username@134.117.214.XX
    A new Code window will open, and it will ask you for your password.  Type in the provided password.  You might be asked for your password again until you have installed the ssh key on your server!
  5. Create an SSH Key on your Windows laptop by running this in a Command Prompt:
    ssh-keygen -t ed25519
  6. In a VS Code remote server session, press CTRL-` to start a remote shell terminal, and run these commands:
    mkdir -p ~/.ssh
    chmod 700 ~/.ssh
    touch ~/.ssh/authorized_keys
    chmod 600 ~/.ssh/authorized_keys
  7. In VS Code, open the .ssh/authorized_keys file on the server, and paste the contents of the following file from  your local Windows laptop: %USERPROFILE%\.ssh\id_ed25519.pub

After these steps have been successfully completed, you should be able to use develop code on the server.  To reconnect later, you will need to ensure the VPN is running, and then connect to the server again.

Running code while disconnected

A common purpose for the Linux server is to provide you with a place that you can run code which takes a long time to complete.  For this, you will need to use special Linux commands to start your code.

One suggested command is Task Spooler.  In your remote session in VS Code, press CTRL-` to open a shell and then use the commands described here:

Background queue of jobs