Visual Studio Code SSH: Difference between revisions

From Research Computing Center Wiki
Jump to navigation Jump to search
No edit summary
(11 intermediate revisions by the same user not shown)
Line 5: Line 5:
=Correct Usage of VS Code and other IDEs on the Sapelo2 Cluster=
=Correct Usage of VS Code and other IDEs on the Sapelo2 Cluster=


Please keep in mind that if you log in to the Sapelo2 Cluster via VS Code, you will be placed on a '''login node'''. This is acceptable only to edit code/files and other low-level tasks, but please do not run code there. It will likely overload our login nodes and cause disruptions to the performance of the login nodes. If you want to run tests in VS Code, please do one of the following first:
'''Running Code/Tests in VS Code on the Cluster'''
# Start an interactive job within VS Code after logging in to the Sapelo2 Cluster
# Use VS Code through On Demand ([[OnDemand|https://wiki.gacrc.uga.edu/wiki/OnDemand]])
''Note'': Some VS Code extensions run in the background even if you are only editing code when you log in via your own VS Code installation on your computer (not through OnDemand). This can still overload our login nodes and cause significant slowness for users logged in to the same login nodes. To remedy this, you can disable these extensions for remote hosts using the instructions below.
=Disabling Heavy-Hitting Extensions=
Disabling extensions using "Disable (remote)" is simple and re-enabling them is also very quick and easy and does not require re-installation. "'''Disable (remote)" disables your VS Code extensions when on a remote host (like the Sapelo2 Cluster), but still allows you to use them locally.'''
If you log in to the Sapelo2 Cluster via VS Code (not through OnDemand), your enabled extensions may run in the background even if you are only editing code, which will still contribute to the load on the login node. High load on login nodes causes major disruptions in the performance of those nodes for all users logged in to those nodes.
The following VS Code extensions are some that commonly run in the background even when you are not running code. Please consider disabling them for remote hosts with "Disable (remote)" if you plan to log in to the Sapelo2 Cluster via the VS Code IDE. You can easily and quickly enable the extension when you are ready to run your code on the Sapelo2 Cluster within an interactive job in your VS Code session.
Extensions:
*C/C++ (ms-vscode.cpptools)
*Python (ms-python.python)
*Pylance (ms-python.vscode-pylance)
*Jupyter (ms-toolsai.jupyter)
* GitHub Copilot (github.copilot)
* GitHub Copilot Chat (github.copilot-chat)
* Codeium (codeium.codeium)
* Claude-related extensions
* Docker (ms-azuretools.vscode-docker)
Steps to disable extensions for remote hosts using "Disable (remote)":
#In VS Code, click on the extension panel to view your extensions
#Click on the gear icon next to the extension that you want to disable
#Click on 'Disable (remote)'
* You can then re-enable your extensions if you need to run tests on the Sapelo2 Cluster by starting an interactive job in your VS Code session and clicking "Enable" on your desired extension


=Downloading VS Code=
=Downloading VS Code=

Revision as of 16:13, 25 March 2026

Introduction

Visual Studio Code, or "VS Code", is a popular code editor. It is very customizable and allows the user to install many extensions.

Correct Usage of VS Code and other IDEs on the Sapelo2 Cluster

Please keep in mind that if you log in to the Sapelo2 Cluster via VS Code, you will be placed on a login node. This is acceptable only to edit code/files and other low-level tasks, but please do not run code there. It will likely overload our login nodes and cause disruptions to the performance of the login nodes. If you want to run tests in VS Code, please do one of the following first:

Running Code/Tests in VS Code on the Cluster

  1. Start an interactive job within VS Code after logging in to the Sapelo2 Cluster
  2. Use VS Code through On Demand (https://wiki.gacrc.uga.edu/wiki/OnDemand)


Note: Some VS Code extensions run in the background even if you are only editing code when you log in via your own VS Code installation on your computer (not through OnDemand). This can still overload our login nodes and cause significant slowness for users logged in to the same login nodes. To remedy this, you can disable these extensions for remote hosts using the instructions below.

Disabling Heavy-Hitting Extensions

Disabling extensions using "Disable (remote)" is simple and re-enabling them is also very quick and easy and does not require re-installation. "Disable (remote)" disables your VS Code extensions when on a remote host (like the Sapelo2 Cluster), but still allows you to use them locally.

If you log in to the Sapelo2 Cluster via VS Code (not through OnDemand), your enabled extensions may run in the background even if you are only editing code, which will still contribute to the load on the login node. High load on login nodes causes major disruptions in the performance of those nodes for all users logged in to those nodes.


The following VS Code extensions are some that commonly run in the background even when you are not running code. Please consider disabling them for remote hosts with "Disable (remote)" if you plan to log in to the Sapelo2 Cluster via the VS Code IDE. You can easily and quickly enable the extension when you are ready to run your code on the Sapelo2 Cluster within an interactive job in your VS Code session.

Extensions:

  • C/C++ (ms-vscode.cpptools)
  • Python (ms-python.python)
  • Pylance (ms-python.vscode-pylance)
  • Jupyter (ms-toolsai.jupyter)
  • GitHub Copilot (github.copilot)
  • GitHub Copilot Chat (github.copilot-chat)
  • Codeium (codeium.codeium)
  • Claude-related extensions
  • Docker (ms-azuretools.vscode-docker)


Steps to disable extensions for remote hosts using "Disable (remote)":

  1. In VS Code, click on the extension panel to view your extensions
  2. Click on the gear icon next to the extension that you want to disable
  3. Click on 'Disable (remote)'
  • You can then re-enable your extensions if you need to run tests on the Sapelo2 Cluster by starting an interactive job in your VS Code session and clicking "Enable" on your desired extension

Downloading VS Code

If you haven't already, you can download VS Code here. If you're using Windows, you'll almost certainly want to download the 64 bit User Installer.

Installing the SSH extension

Here we will go over how to set up its SSH extension. This will allow you to have VS Code connect to Sapelo2 so that you can edit files on the cluster with your local instance of VS Code.

Open the Extensions Interface

When you open VS Code, you'll see on the left the Activity Bar, with several buttons displayed vertically.

Vscode activity bar.png


Search for the SSH Extension

Clicking the button with the four squares opens up the extensions interface in the sidebar. Below you can see some of extensions I already have installed. Some of these are just simply color theme packages, to change syntax highlighting colors. Others provide features relevant to a particular programming language, such as the Python extension providing IntelliSense for Python.

Vscode extensions.png


At the top of the extensions interface is a search bar, where you can search for official or community-provided extensions. This is where you could search for the SSH extension, for example. Typically you'll want to install extensions provided by a known source, such as Microsoft in this case (the first option), and/or an extension that has many downloads and a high rating, as shown in this search output.

Vscode ssh extension.png


Install the SSH Extension

Once you find the extension you want, all you have to do is click the small "Install" button in the search output, and a tab will open in your editor with more information and instructions on how to use the extension that you have installed.

Vscode installed.png


Using the SSH Extension

Click the SSH Button

You can hide the sidebar if you wish with cmd + b on Mac and ctrl + b on Windows. Once the SSH extension is installed you will see this small greater than & less than button in the bottom left corner of VS Code.

Vscode sshbutton.png


Add a new SSH Host Connection

Upon clicking that small SSH button in the bottom left, a prompt window will appear in the top middle of VS Code, asking how you want to connect to whatever it is you're going to SSH. Select the first option, "Connect Current Window to Host...".

Vscode connection options.png


Next, click the "Add New SSH Host..." option, and type your MyID@sapelo2.gacrc.uga.edu in the prompt, and then press enter.

Vscode add new ssh host.png Vscode connection.png


If it asks you what SSH config file to update, you can just choose the first option.

Vscode sshconfig.png


Connect to Sapelo2

The prompt will then disappear, but now you can click the small SSH button in the bottom left of VS Code and see that your connection has been saved, you don't have to type it every time. Click the Sapelo2 connection to then be presented with a password prompt. This just wants your MyID password, as if you were normally connecting to Sapelo2 via PuTTY or your terminal. Then you will get an ArchPass DUO prompt. You can respond to this with a 1 for a push notification to your phone, or however you normally authenticate with ArchPass DUO.

Vscode chooseconnection.png Vscode password.png Vscode duo.png


Open Directories on Sapelo2

Once you approve the connection request via DUO, you're connected to Sapelo2! To open up a particular directory on Sapelo2, click the button on the side part that looks like two pieces of paper, which will open the explorer interface within the sidebar.

Vscode explorer.png


Click the "Open Folder" button to then be presented with a prompt where you can enter any path on Sapelo2 to which you have permission to access.

Vscode opendir.png


In this example, I've opened my home directory in the side bar. It presents it as a file tree that I can navigate graphically. Directories can be expanded by clicking them. Files can be opened in VS Code by double clicking them, as you can see here, with this file.txt in my home directory.

Vscode homedir.png


You can open multiple directories on Sapelo2 in the sidebar of VS Code by clicking the "Add Folder to Workspace" option in the File menu.

Vscode add dir.png


Open the Terminal in VS Code

I highly recommend toggling the Terminal in VS Code, which will allow you to interact with Sapelo2 as you normally would from within VS Code. To do this, click "Terminal" under the View menu. This will open up a terminal in the bottom half of the editor. You can enter any command as you normally would on Sapelo2.

Vscode terminal.png