Using VS Code remote ssh settings¶
To reduce CPU usage and traffic on the log-in node shell-hpc
, we have set up a VM to handle
VS Code so that those processes are running on that machine.
We support the Remote - SSH extension for this purpose.
Extensions
If you have a local set of extensions, you'll have to re-install your extensions on the remote machine, so don't be dismayed if they are initially missing.
Quickstart guide¶
If you're familiar with editing your ssh config file as explained in the connecting guide, then getting your vs code connection will be relatively simple. It should look like this when you're done:
Host shell
HostName shell.cqls.oregonstate.edu
User ONIDUSER
Port NNN
ControlMaster auto
ControlPath ~/.ssh/sockets/%r@%h-%p
ControlPersist 600
TCPKeepAlive no
ServerAliveInterval 30
Host hpc
HostName hpc.cqls.oregonstate.edu
PubkeyAcceptedKeyTypes +ssh-rsa
ProxyJump shell
ControlPersist 600
TCPKeepAlive no
ServerAliveInterval 30
Host vscode
HostName vs-gateway.hpc.oregonstate.edu
PubkeyAcceptedKeyTypes +ssh-rsa
ProxyJump hpc
ControlPersist 600
TCPKeepAlive no
ServerAliveInterval 30
Tip
Make sure to run mkdir -p ~/.ssh/sockets
first so the directory that keeps the sockets open is present.
Also, replace the NNN
with the correct port number for the shell.cqls machine, and your onid username for
ONIDUSER
.
If you are hard-wired or on the VPN, you can instead use this configuration:
Host hpc-direct
HostName hpc.cqls.oregonstate.edu
PubkeyAcceptedKeyTypes +ssh-rsa
ControlPersist 600
TCPKeepAlive no
ServerAliveInterval 30
Host vscode-direct
HostName vs-gateway.hpc.oregonstate.edu
PubkeyAcceptedKeyTypes +ssh-rsa
ProxyJump hpc-direct
ControlPersist 600
TCPKeepAlive no
ServerAliveInterval 30
Tip
You can put both the direct connection config and the legacy off-campus config in the same file and use them
depending on your current connection type. From the commandline, you can ssh hpc
if you're off-campus, and then
ssh hpc-direct
if you're on the VPN.
If you're always on the VPN or hard-wired, you can simplify the Host
lines in your config, just make sure the
ProxyJump line in the for the vs-gateway
machine matches the appropriate jump host definition.
Step-by-step tutorial¶
- Install the Remote - SSH
- i.e. run
ext install ms-vscode-remote.remote-ssh
in the quick open panel (ctrl+p
)
- i.e. run
- Restart extensions
- i.e.
ctrl+shift+x
-> Click restart extensions - OR open command pane
ctrl+shift+p
-> Restart extension host;ctrl+shift+p
-> Extensions: Refresh
- i.e.
- Open the command pane
ctrl+shift+p
-> Open SSH Configuration File...- I had to choose
/home/$USERNAME/.ssh/config
- copy/paste the
~/.ssh/config
file contents from above into the file - Save the file
- I had to choose
- Test it out by connecting to host i.e.
ctrl+shift+p
->Connect to host
-> vscode- Alternatively, click on the Open a remote window button in the bottom left corner, then
Connect to host
orConnect Current Window to Host
, thenvscode
See this graphic for more info:
Submitting jobs from vscode machine¶
Slurm is enabled on the vs-gateway
machine so that you can submit jobs from the node. The terminal window should work
as expected. You can duplicate terminals and use salloc
to
run interactive jobs as well.
Feedback¶
Please let us know if you run into problems using this method so that we can help you troubleshoot your connection issues.