Visual Studio Code (VS Code) is an open-source and lightweight text editor from Microsoft, and distinctly different from Visual Studio. In this short tutorial we aim to set up VS Code for remote interfacing and development on Apocrita, to edit, save, and manipulate our files and directories.
VS Code has a growing list of built-in features and third-party extensions. It packages its text editor with a built-in Git source control system, a file explorer, program debugging and running functionality, and IntelliSense for several programming languages. Along with its flexible extension list, it’s a solid alternative to other, more established editors.
Integrating VS Code with Apocrita is principally aimed to those of you that
already work with it locally, as it naturally extends its usability.
I have been exclusively using VS Code on Apocrita for 2 years to
view and edit my
qsub scripts, private modules, source code, and
log files. VS Code remembers which files are opened under any specific
directory, so my workflow is not interrupted if I move between entirely
different subjects. My local development environment is also being
replicated on Apocrita by integrating the extensions with the Apocrita
compilers, vetting source code for warnings and errors, or linting issues.
Other, more niche, applications are also possible.
The small list of prerequisites includes a new installation of VS Code and an SSH key setup on Apocrita.
VS Code has install binaries for Linux, Windows, and MacOS. They are available through the download page.
Following a successful installation, we need to couple our public Apocrita SSH key to VS Code. The public SSH key must be generated and uploaded to Apocrita beforehand. Our online documentation has detailed instructions on how to generate a public key, which you will then need to upload to Apocrita. An overview of the process can also be found on one of our recent blog posts.
Some differences exist between operating systems. In Linux and MacOS, the SSH
keys are assumed to be saved under
~/ is your home directory.
In Windows, the key is a public key file generated by PuTTY
- open PuTTYgen
- load the
- go to “Conversions” menu
- export “OpenSSH key”
- save as “key.openssh”
Setting up the SSH key
Connecting remotely to a server through VS Code is enabled by the extension
“Remote Development”, which can be installed
manually through the extension page.
Alternatively, launch VS Code, use Quick Open
(Ctrl+P), paste the
external install command
ext install ms-vscode-remote.vscode-remote-extensionpack and
press enter to confirm.
Once the package is installed, a new green UI element will appear at the bottom left, as seen on Figure 1.
Open the UI element,
and from the drop down menu choose “Remote SSH: Open Configuration File”.
If there are multiple options, choose the
configuration file located in the same directory as your SSH key
~/.ssh/config in my setup), open it and paste the following snippet:
Host apocrita HostName login.hpc.qmul.ac.uk User <USERNAME> IdentityFile ~/.ssh/id_rsa
Remember to replace
<USERNAME> with your Apocrita username and the
identity file directory with your own (if different). A more thorough guide
can be found on the remote development documentation.
Testing the connection
We are ready to connect to Apocrita for the first time. Open the UI element and choose “Connect to host” (Figure 2), and then choose “apocrita” (Figure 3). This will prompt you to enter your Apocrita password (Figure 4).
If everything has worked correctly, the UI element will read “Opening Remote..” and an information pop up will notify us that a VS Code Server is being initialised. Once a connection has been established, we will be able to open our home directory, through “Open Folder”, as seen on Figure 5.
VS Code, by default, is set to send telemetry data back to Microsoft. These processes reside on the login nodes as long as the user is connected. For performance and privacy considerations we strongly suggest you perform the following actions.
Online Services Settings.
Telemetry, disable the options “Enable Crash Reporter” and