VS Code ( vscode ) should ONLY be run from computational nodes. Do not run VS Code on Biowulf or Helix. Please follow instructions on this page to run on compute node. Please contact staff@hpc.nih.gov if you run into issues while following the below steps.
Visual Studio Code is a code editor redefined and optimized for building and debugging modern web and cloud applications. It might be a good idea to install "Remote Development" extension pack which allows you to open any folder in a container, on a remote machine, or in the Windows Subsystem for Linux (WSL) and take advantage of VS Code's full feature set. It includes 'Remote SSH', 'Remote Containers' and 'Remote WSL' extensions.
Note
- Error: Connecting with SSH timed out; If this error appear frequently, please go to the setting of Remote-SSH extension of VS Code and modify the 'Remote.SSH: Connect Timeout' to 30 seconds.
Documentation
- Generate an ssh keypair with this command in windows powershell:
ssh-keygen -t rsa -b 4096
. The key should be passphrase protected. - Copy the public key from its present location to the authorized_keys file on Biowulf (replace xxx with your own user name):
scp /Users/xxx/.ssh/id_rsa.pub xxx@biowulf.nih.gov:~/tmp
- Log in to Biowulf:
biowulf $ cat tmp >> ~/.ssh/authorized_keys biowulf $ rm tmp biowulf $ chmod 0700 /home/$USER/.ssh biowulf $ chmod 0600 ~/.ssh/authorized_keys
- In an administrative powershell session(your institute IT department may need to be involved):
Is ssh-agent enabled?:Get-Service ssh-agent | Select StartType
If the StartType is Disabled, enable with:Get-Service -Name ssh-agent | Set-Service -StartupType Manual
- In an non-administrative powershell session:
Runssh-agent.exe
Add your keys usingssh-add
- In the 'search' box at the bottom left corner of windows desktop, type
notepad C:\Users\xxx\.ssh\config
and press enter. Replace xxx with your own user name. - Add the following to this file (replace xxx with your own user name):
Host cn* User xxx ProxyCommand C:\Windows\System32\OpenSSH\ssh.exe -o ForwardAgent=yes xxx@biowulf.nih.gov nc -w 120ms %h %p
- Save and close the file.
- Install the "Remote Development" VScode extension. In VS Code Remote-SSH extension add the following in the settings section to your "Remote.SSH: Config File" (replace XXX with your own user name):
C:\Users\XXX\.ssh\config
- Start an sinteractive session on Biowulf (using an alternate method such as putty or nomachine) and take note of the compute node number (cnXXXX).
- In VS Code, click the bottom left icon, select/type 'Remote-SSH: Connect to host'
- In the box, replace "XXXX" with the actual compute node number obtained in step 10, then click on the node name (not press enter). Select 'linux', 'continue', then the node number should appear at the bottom left.
- You should now be able to open a terminal in VS Code to cnXXXX and edit/run scripts directly on cnXXXX.
The instructions for Mac OSX is very similar to the Windows instructions
- Install the "Remote Development" VScode extension on your Mac.
- Generate an ssh keypair and copy (passphrase protected) public key to Biowulf. See Mac section on https://hpc.nih.gov/docs/sshkeys.html
- In your Mac terminal:
a) run "ssh-agent" to start the agent.
b) Add your keys using "ssh-add".
c) Add the following to .ssh\config in local computer (replace $username with your own username):
Host cn* User $username ProxyCommand /usr/bin/ssh -o ForwardAgent=yes $username@biowulf.nih.gov nc -w 120ms %h %p
- In VSCode Remote SSH add the following in the settings section to your "Remote.SSH: Config File"(replace $username with your user name):
/Users/$username/.ssh/config
- Start an sinteractive session on Biowulf (using an alternate method such as putty or nomachine) and take note of the compute node number (cnXXXX).
- Use VSCode "Remote-SSH Connect to Host" to connect to cnXXXX (replace "XXXX" with the actual compute node number obtained in step 5.
- You should now be able to open a terminal in VS Code to cnXXXX and edit/run scripts directly on cnXXXX.
- Download and install the VS Code Python extension.
- Setting up requirements.
- a. Download Python for windows from python.org (this is needed for the extension above to work)
- b. Create SSH key pair. See https://youtu.be/PFZz_xi8Hy0
- Select "Python interpreter" for Python extension (also needed for 1 to work). Open command palette, type 'python: select interpreter', choose version, it will appear at bottom left corner.
- Launch a jupyter notebook on a compute node. Note the ssh command in red.
- Create tunnel to biowulf using powershell in Windows with the same command in red from above step 4.
- Use the http address in blue obtained in step 4 to connect from VS code.
-
a. Open command palette in VS Code.
- b. Type/Select "Jupyter: Select interpreter to start Jupyter server".
-
c. Type/Select "Jupyter: Specify local or remote Jupyter server for connections" from the list of commands displayed.
If a popup requests reload, go ahead and do so. A new window will be opened for you to continue the following steps.
Type/Select "Jupyter: Create interactive windows" or "Jupyter: Create new blank Notebook"
-
a. Open command palette in VS Code.
You are now running Jupyter Notebook on a node. Notice that VSCode support is somewhat limited. For example, it is not possible to select a kernel other than the default kernel. That makes the centrally installed jupyter not very useful for this mode of usage. A user-installed jupyter in a more fully featured environment would be better.
Please see the Biowulf Jupyter page for more information about Jupyter on Biowulf.