# VS Code - Setup

To use VS Code on the server, you need to create an SSH key. If you have ever done this before on your current computer, you don't need to do it again, and you can skip to the [Connect to VS Code Remote]() section.

## First Time Setup

### Change VS Code's Connection Timeout Setting

The first time you connect to the server, it will install all of the Python and R packages you need. This process takes several minutes, however, and VS Code defaults to waiting only 15 s after login for any processes to end. Long story short, if you don't change this setting, VS Code will disconnect you before all the packages get installed.

Open `Settings`from the VS Code menu and in the search  bar type `remote timeout`. Change the value of `Remote.SSH: Connect Timeout` to `300.`&#x20;

### Configure Extensions to Auto-Install in VS Code Remote

You'll always need extensions when working in VS Code — at the very least, the Python and Jupyter extensions, GitHub Copilot, R, and probably some others. Below is a suggested list.&#x20;

Even if you installed these extensions in VS Code on your laptop, they won't automatically be installed in your server installation of VS Code. Do the following to define the extensions that you always want to be installed in a remote VS Code session (doing this will also ensure that all your extensions are re-installed if the server OS is reinstalled, which happens frequently).

In VS Code, go to `Settings`and in the search bar type `extensions`. In the left sidebar of results, click `Extensions`then select `Remote-SSH`. You'll see an `Add Item`button. Click that and then paste each of the extension names below in, clicking `OK`then `Add Item`_for each one_ (you can't paste in a list, unfortunately):

```
ms-python.python  
ms-toolsai.jupyter     
reditorsupport.r 
ms-python.vscode-pylance
GitHub.copilot
GitHub.copilot-chat 
ms-toolsai.datawrangler
yzhang.markdown-all-in-one
ms-azuretools.vscode-docker
ms-vscode-remote.remote-containers
tomoki1207.pdf
george-alisson.html-preview-vscode
mechatroner.rainbow-csv
```

### Connect to VS Code Remote

#### Install Python and R environments

{% hint style="info" %}
You'll need to do this before you can connect via VS Code for the first time, AND any time the server OS gets updated (Aaron will tell you).
{% endhint %}

Open a terminal application on your computer. On Macs, this is the Terminal app. On Windows, there are a number of options, but I recommend Git Bash.

Launch the terminal app, then run the command: `ssh github-username@ncil.psychology.dal.ca —`Except replace `github-username` with your actual GitHub username.&#x20;

As soon as you log in, a script should auto-run to install the Python and R environments. This will take about 5 min; you don't need to do anything.

When it's done, you can quit the terminal app.

#### Create SSH config (One Time only)

Open VS Code on your computer, and type `Cmd-Shift-p`(`Ctrl-Shift-p`on Windows).&#x20;

In the box that pops up, start typing `Remote-SSH: Connect Current Window to Host...`

Select this option when it pops up, then click `+ Add New SSH Host`&#x20;

In the box that pops up, enter: `ssh github-username@ncil.psychology.dal.ca —`Except replace `github-username` with your actual GitHub username. Save the configuration by clicking the first option in the list you see (it will end in `.ssh/config`).

#### After the First Time

In future sessions, you will still need to `Cmd-Shift-p`(`Ctrl-Shift-p` on Windows) `Remote-SSH: Connect Current Window to Host...` but you can just select your saved configuration rather than typing the whole ssh command every time.

Alternatively, you should install the Remove Development VS Code extension. Then you'll have an icon in your Activity Bar (left side of window) that looks like a screen with a little circle in the bottom right corner. Each different folder on the server that you've connected to via SSH in the past will show up here, and you can just click the -> arrow next to its name to connect again.



