Access from VSCode
How to access JASMIN from VSCode
Visual Studio Code is a richly-featured editor and Integrated Development Environment (IDE) which has remote access and other useful features that can be used with JASMIN.
This article is in response to requests from users about how use VSCode with JASMIN and is not a product endorsement. Other IDEs with similar features are also available, for example PyCharm .
The following demonstrates how to use VSCode to connect to JASMIN, and mentions some of its features for further reading.
Follow the “setup” link from the page linked above to obtain VSCode for your platform: this should be your local machine, not JASMIN.
There should be no need for you to install VSCode on JASMIN, and we ask you not to.
We don’t provide it centrally, because the multitude of different extensions and configurations would be too difficult to manage in a multi-user environment, so it makes more sense if you install your own local instance of it, which you can configure as you like: the remote capabilities of VSCode make a central installation unnecessary.
Read about the following extensions and decide which you think you need (you can always “upgrade” later)
You should read about those extensions first, at the links above, but actually install the one you choose by using the Extensions menu within VSCode once you’ve installed the application.
You will also almost certainly want the following for working with Python locally and on JASMIN.
There are many, many other extensions to add, but you now have the most relevant ones to get you started.
These extensions are best installed locally, before connecting to any remote hosts.
You will need to set up at least one SSH connection profile to a remote host on JASMIN: we’ll cover which host(s), shortly.
VSCode has a tool to help you set this up, and creates entries in your ~/.ssh/config
file for the SSH client that you’re using.
First consider your SSH client: VSCode will connect using the SSH client of your operating system: there isn’t one built into VSCode itself. See presenting your ssh key for details of the “agent” method: this is more convenient as this is persistent across sessions and you won’t be asked for your passphrase on each connection. If that doesn’t work for you, note the extra configuration below which can be added to specify the location of your key instead.
Next, consider which remote host(s) on JASMIN you want to connect to:
login
servers are available from any location, but don’t have any software or storage mounted other than your home directorysci
servers are probably where you want to work, but aren’t directly accessible from outside of the STFC network.xfer
servers might be a good choice if it’s just editing you’re likely to be doing, since they’re directly accessible from anywhere
and have all filesystems mounted (except scratch). But they’re not for doing processing.So the ideal setup might be 2 profiles as follows:
sci
server, accessed via a login serverxfer
server, accessed directlyIf we use the tool provided by VSCode to create these, we can customise them further.
The following video demonstrates these steps, and the initial setup of 2 connection profiles, on Windows. But the interface is almost identical on Mac and Linux.
Notes:
-A
option is only needed IF you will be making onward SSH connections from the remote host …this can be omitted if notssh -A username@sci-vm-01.jasmin.ac.uk -J username@login-01.jasmin.ac.uk
~/.ssh/config
(it’s recommended to choose that location)Host
is a “friendly name” which you can define, whereas HostName
is the actual full name of the host including domain, e.g. sci-vm-01.jasmin.ac.uk
xfer-vm-01
which, being an xfer
server, is directly accessible so does not need the ProxyJump
~/.ssh/config
and restart VSCodeAlternative method if you can’t get the “agent” method to work (but means that you may be prompted for the key passphrase each time you connect):
~/.ssh/config
and add the line with IdentityFile
as shown:Host sci-vm-01-via-login-01
Hostname sci-vm-01.jasmin.ac.uk
User username
ProxyJump username@login-01.jasmin.ac.uk
ForwardAgent yes
IdentityFile ~/.ssh/id_rsa_jasmin
For example:
git
installed locally(see
git
for Windows)and many other features beyond the scope of this article.
This makes an IDE such as VSCode a good choice to install locally, rather than using the (fairly basic) editors available on JASMIN.
If you get permission denied
when connecting, you should troubleshoot this as you would any other SSH connection.
Open a terminal within VSCode and check that your SSH key is being presented correctly. If it’s not listed when you do
ssh-add -l
then:
VSCode starts a small server process on the remote host when you connect. Occasionally this can get stuck. One method of fixing this is to:
.vscode-server
process running on that host, e.g.ps -ef | grep $USER | grep vscode
kill <PID>
~/.vscode-server
directory which VSCode created in your JASMIN home directoryrm -rf ~/.vscode-server