Configuring VSCode to access GWDG’s HPC Cluster

VSCode is a popular lightweight IDE developed by Microsoft that supports many programming languages and scripts. There are many features and capabilities that can be added to VSCode by installing extensions from the marketplace, including the ability to develop on a remote machine and manage files intuitively using its GUI.

Screenshot of VSCode. Source: Ali Doost Hosseini

This document provides instructions for setting up VSCode to connect to GWDG’s HPC cluster.

Note: To acccess the cluster, you will need an activated, non-student account

Extensions

Install the following extensions from the VSCode marketplace:

SSH Configuration

Generate an SSH key

First, you will need an SSH key. On Linux, macOS and the latest Windows versions SSH is already built in. A key can be generated with the command ssh-keygen -t rsa -b 2048 -f <yourkey>. As soon as you enter the command you will be asked to secure the key with a passphrase. Please do not use keys without a passphrase to log in to our systems.

PS C:\Users\win10-virtual> ssh-keygen -t rsa -b 2048 -f .ssh/id-rsa
Generating public/private rsa key pair.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in .ssh/id-rsa.
Your public key has been saved in .ssh/id-rsa.pub.
The key fingerprint is:
SHA256:JIFSfI6/QBdnUaVsjKdHIfCqw1yjZyk96KDp07MlvbM win10-virtual@DESKTOP-N8DT68R
The key's randomart image is:
+---[RSA 2048]----+
|   o..o.ooo..    |
|  . o ooo= o     |
|   . +.++ B      |
|    o o+ =       |
|   . o+ S .      |
|   oo*.o .       |
|  o.O+*.         |
| + =o*o.         |
|+...+Eo          |
+----[SHA256]-----+ 

This creates both the private key file <yourkey> and a corresponding public key file <yourkey>.pub.

Note: Never give out your private key, but always upload only the public key!

Upload the SSH Key

To upload a key, please log into your account on the GWDG Website, go to My Account. Then scroll down to Other Settings and click edit. You can now add a public key.

Note: If you copy your public key from a text editor or a terminal, please make sure that your editor or your terminal does not insert any linebreaks, because this will make the copy of your public key invalid.

SSH Configuration File

Now you will need to setup an SSH configuration file. In VSCode, press Ctrl + Shift + P and select the entry Remote - SSH: Open SSH Configuration file, then select the desired location for this file.

You can add any number of host configurations as you like. Here is an example on a windows machine:

Host gwdg_mdc
  HostName login-mdc.hpc.gwdg.de
  User <username>
  IdentityFile <path_to_private_key>

Host gwdg_mdc_transfer
  HostName transfer-mdc.hpc.gwdg.de
  User <username>
  IdentityFile <path_to_private_key>

 

In this example, replace <username> with your GWDG HPC account username, and <path_to_private_key> with the path to the private key.

Connecting to the HPC Cluster

Now that the SSH configuration file is set up, you may use the Remote Explorer on the left sidebar in VSCode to find and select the host you wish to connect to.

Right-click on a host (e.g. gwdg_mdc in the previous example) and select Connect to Host in Current Window. VSCode should then ask for your SSH key’s passphrase and log you into one of the cluster’s login nodes.

Accessing a singularity container from within VSCode

It is also possible to Remote SSH directly into a singularity container. However, this method uses the login node and therefore should not be used for computationally intensive purposes.

You will need to change some VSCode settings. Press Ctrl + Shift + P and select the entry Preferences: Open User Settings (JSON). In the settings.json file, add the following entries, and save the file:

"remote.SSH.useLocalServer": true,
"remote.SSH.enableRemoteCommand": true,

Then, open the SSH configuration file: Ctrl + Shift + P Remote - SSH: Open SSH Configuration file and restructure the host as follows:

Host container~*
  RemoteCommand /opt/sw/rev/21.12/haswell/gcc-9.3.0/singularity-3.8.5-p6gj6x/bin/singularity shell <path_to_container>
  RequestTTY yes

Host gwdg_mdc container~gwdg_mdc
  HostName login-mdc.hpc.gwdg.de
  User <username>
  IdentityFile <path_to_private_key>

 

Note: If you can enter the login node but singularity doesn’t run, try removing the „remote.SSH.remotePlatform“ entry from settings.json.

Author

Ali Doost Hosseini

Kategorien

Archive

--