Using VS Code remote ssh settings¶
Using the Remote - Tunnel extension¶
The Remote - Tunnels extension allows you to connect to HPC compute nodes such that higher processing power can be available while still respecting the queuing system resource allocations.
Prerequisites¶
- Allocate a compute node with
salloc
to obtain an interactive session. - Ensure the
code
CLI is available on the compute node.code
has been installed in/local/cqls/opt/bin
to facilitate this. You can skip this step if runningcode --version
produces a result.code
is not supported onppc64le
at this time.
Install the VS Code CLI on the compute node¶
Run the following command on the allocated node to download and extract the VS Code binary:
This will create a code
executable in the current directory.
Start a tunnel¶
After the download finishes, start a tunnel to your local machine:
Follow the prompts to authenticate with your Microsoft account (use your ONID credentials).
Once the tunnel is established, install the Remotes - Tunnels extension if you haven't already, and then authenticate with your ONID credentials in VS Code on your local machine - choose the Microsoft account option - (or the web vscode interface) to connect to the compute node, allowing you to edit files, run terminals, and submit jobs.
Submitting jobs from the tunnel¶
You can use salloc
or hqsub
as usual within the tunnel session. The VS Code terminal runs on the compute node, so
any commands you execute (including salloc
, sbatch
) will operate on the HPC resources.
Tips¶
- Keep the tunnel session active; closing the terminal will terminate the connection.
- Restarting a
code tunnel
command on a machine will automatically make it available again in your local VS code or web interface. - After you authenticate interactively the first time using
salloc
, you can then submit a batch job withcode tunnel
to the same machine to open the tunnel in a non-interactive session. - Remember to kill the job with
scancel
when you no longer need the tunnel open. - Use
code tunnel --help
for additional options such as using a different workspace folder.
Using the Remote - SSH extension¶
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 as well, but if you need to use R (including installing the R extension on the vscode remote vm), or any other extensions/processes with CPU/Memory reqirements, please use the Remote - Tunnels extension as described above.
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:
Warning
Windows users seem to have issues using the ControlMaster ControlPath and ControlPersist settings. Please remove them if you are having issues.
For others, make sure to run mkdir -p ~/.ssh/sockets
first so the directory that keeps the sockets open is
present. Also, replace your onid username for ONIDUSER
.
Host shell
HostName shell.hpc.oregonstate.edu
User ONIDUSER
ControlMaster auto
ControlPath ~/.ssh/sockets/%r@%h-%p
ControlPersist 600
TCPKeepAlive no
ServerAliveInterval 30
Host vscode
HostName vs-gateway.hpc.oregonstate.edu
User ONIDUSER
PubkeyAcceptedKeyTypes +ssh-rsa
ProxyJump shell
TCPKeepAlive no
ServerAliveInterval 30
Tip
Retry up to three times when you connect to vscode to resolve connection issues, especially after getting disconnected.
Please send a message on the BUG Slack channel if you cannot get the connection working.
Note
We previously maintained separate instructions for connecting through the VPN or on campus, but those instructions are no longer necessary.
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.