4 Working on the Farm
- Use different software tools to work on a remote server: terminal, text editor and file transfer software.
- Login to the farm and navigate its filesystems.
- Edit scripts on the HPC using Nano.
- Move files in and out of the farm using Filezilla or
rsync
/scp
.
4.1 Connecting to the HPC
All interactions with the farm happen via the terminal (or command line). To connect to the HPC we use the program ssh
. The syntax is:
ssh your-hpc-username@hpc-address
To log onto the Sanger farm, you’ll need to add “-login” to the name of the HPC, using this command:
ssh sanger-username@farm5-login
The Sanger service desk has set up your laptop to assume your Sanger ID, so you can use the simplified command to access the farm:
ssh farm5-login
The first time you connect to an HPC, you may receive a message about the ECDSA key fingerprint. By typing yes
you’ll add the ‘fingerprint’ of this HPC to your local computer’s saved list of approved hosts.
After running this ssh
command and approving any ECDSA key questions, you will be asked for your Sanger password and after typing it you will be logged in to the farm.
We will be using a test server called gen3 in this course. It is a small HPC, similar in structure to the larger farm5, run by the Sanger for scientists to learn about the farm and test LSF scripts. Everyone with a Sanger ID has access to gen3, but farm5, the main HPC, is only accessible once you complete the Farm Induction course.
4.1.1 Exercise
4.2 Editing Scripts Remotely
Most of the work you will be doing on a HPC is editing script files. These may be scripts that you are developing to do a particular analysis or simulation, for example (in Python, R, Julia, etc.). But also - and more relevant for this course - you will be writing shell scripts containing the commands that you want to be executed on the compute nodes.
There are several possibilities to edit text files on a remote server. A simple one is to use the program Nano directly from the terminal. This is a simple text editor available on most linux distributions, and what we will use in this course.
Although Nano is readily available and easy to use, it offers limited functionality and is not as user friendly as a full-featured text editor. You can use other more full-featured text editors from the command line such as vim
, but it does come with a steeper learning curve. Alternatively, we recommend Visual Studio Code, which is an open-source software with a wide range of functionality and several extensions, including an extension for working on remote servers.
4.2.1 Nano
To create a file with Nano you can run the command:
nano test.sh
This opens a text editor, where you can type the code that you want to save in the file. Once we’re happy with our code, we can press Ctrl+O to write our data to disk. We’ll be asked what file we want to save this to: press Enter to confirm the filename. Once our file is saved, we can use Ctrl+X to quit the editor and return to the shell.
We can check with ls
that our new file is there.
Note that because we saved our file with .sh
extension (the conventional extension used for shell scripts), Nano does some colouring of our commands (this is called syntax highlighting) to make it easier to read the code.
4.2.2 Exercise
4.3 Summary
- The terminal is used to connect and interact with the HPC.
- To connect to the HPC we use
ssh username@remote-hostname
.
- To connect to the HPC we use
- Nano is a text editor that is readily available on HPC systems.
- To create or edit an existing file we use the command
nano path/to/filename.sh
. - Keyboard shortcuts are used to save the file (Ctrl + O) and to exit (Ctrl + X).
- To create or edit an existing file we use the command