Skip to content

Connect over SSH with VS Code

VS Code allows you to work on remote servers from your local machine.

Prerequistes

  • Install VS Code, click here
  • ~/.ssh/config

Connecting to HPPC with VS Code

Because we need to hop twice (your local machine -> gateway -> dev node), we need an ssh config file. The following is an example config which defines intel18 and k80 dev node. With this file, you can connect dev node from your local machine with 'ssh intel18' or 'ssh k80'.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
Host gateway
  HostName gateway.hpcc.msu.edu
  User your_net_id

Host intel18
  HostName dev-intel18
  User your_net_id
  ProxyJump gateway

Host k80
  HostName dev-intel16-k80
  User your_net_id
  ProxyJump gateway

Next, we need an extension program for VS Code, which can be obtained here

Screenshot 1

When the extension is installed, press F1, and select 'Remote-SSH: Connect to Host...' Screenshot 1

Then select intel18 or k80. Screenshot 1

A new VS Code window will pop up. When you are successfully connected, bottom left of the VS Code will show server information such as 'SSH: intel18'. Screenshot 1

Working on HPCC with VS Code

Now that you are connected, you can run commands and codes from VS Code. When you are connected to the HPC, all files created through VS Code will be saved to the HPC, not on your local machine.

To test the ability to run remote code, let's create a Python file 'hello.py' with VS Code. Click 'New file' and create a file with the following contest to the file: Screenshot 1

1
print('hello!')

Now, open a terminal from 'Terminal' menu from VS Code (or by pressing the key sequence CTRL+Shift+` and run the code.

1
$ python hello.py

Once you have connected the server, click the Remote Explorer to see the list of servers. Click the icon to connect to host in a new window. Right click the name to see the option.

Screenshot 1