Skip to content
This repository was archived by the owner on Aug 14, 2024. It is now read-only.
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 69 additions & 12 deletions _episodes/01-connecting.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
---
title: "Connecting to the remote HPC system"
teaching: 20
teaching: 25
exercises: 10
questions:
- How do I open a terminal?
- How do I connect to a remote computer?
- What is an SSH key?
objectives:
- Connect to a remote HPC system.
keypoints:
- To connect to a remote HPC system using SSH,
- To connect to a remote HPC system using SSH and a password,
run `ssh [email protected]`.
- To connect to a remote HPC system using SSH and an SSH key,
run `ssh -i ~/.ssh/key_for_remote_computer [email protected]`.
---

## Opening a Terminal
Expand All @@ -34,10 +37,6 @@ then a quick search on the Internet for "how to open a terminal window in" with
your particular Linux flavour appended to the end should quickly give you the
directions you need.

A very popular version of Linux is Ubuntu. There are many ways to open a
terminal window in Ubuntu but a very fast way is to use the terminal shortcut
key sequence: Ctrl+Alt+T.

### Mac

Macs have had a terminal built in since the first version of OS X since it is
Expand Down Expand Up @@ -104,10 +103,10 @@ PuTTY is likely the oldest, most well-known, and widely used software solution
to take this approach.

PuTTY is available for free download from
[www.putty.org](http://www.putty.org/). Download the version that is correct
for your operating system and install it as you would other software on your
Windows system. Once installed it will be available through the start menu or
similar.
[https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html](https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html).
Download the version that is correct for your operating system and install it
as you would other software on your Windows system. Once installed it will be
available through the start menu or similar.

Running PuTTY will not initially produce a terminal but instead a window full
of connection options. Putting the address of the remote system in the "Host
Expand All @@ -129,6 +128,56 @@ For those logging in with PuTTY it would likely be best to cover the terminal
basics already mentioned above before moving on to navigating the remote
system.

## Creating an SSH key

SSH keys are an alternative method for authentication to obtain access to
remote computing systems. They can also be used for authentication when
transferring files or for accessing version control systems. In this section
you will create a pair of SSH keys, a private key which you keep on your
own computer and a public key which is placed on the remote HPC system
that you will log in to.

### Linux, Mac and Windows Subsystem for Linux

Once you have opened a terminal generate a public private SSH key pair by
using

```
ssh-keygen -o -a 100 -t rsa -b 4096 -f ~/.ssh/key_for_remote_computer
```
{: .language-bash}

where

- ssh-keygen is the command to generate the key pair
- -o specifies to use a strong format to save the key
- -a 100 increases the strength of encryption with your passphrase
- -t rsa specifies the encryption method used, in this case
[RSA or Rivest–Shamir–Adleman
encryption](https://en.wikipedia.org/wiki/RSA_(cryptosystem))
- -f filename specifies the name of the ssh key, by default these are
stored in the directory ~/.ssh

It is helpful to strengthen the security of your key by using a password.
Check the directory ~/.ssh which should contain two new files
~/.ssh/key_for_remote_computer.pub and
~/.ssh/key_for_remote_computer , the key with the .pub extension is the
public key. You should give this to the person managing access of the
remote system you want to log in to. The private key remains with you.
If someone obtains the private key and it does not have a password,
it can be used to log into systems where the public key has been placed,
so be careful with your ssh private keys. If you think they have been
compromised, ask people managing systems you have access to, to remove
compromised keys and replace them with new ones you have generated.

### Windows

On Windows you can use
- puttygen, see the Putty
[documentation](https://www.chiark.greenend.org.uk/~sgtatham/putty/docs.html)
- MobaKeyGen, see the MoabXterm
[documentation](https://mobaxterm.mobatek.net/documentation.html)

## Logging onto the system

With all of this in mind, let's connect to a remote HPC system. In this
Expand All @@ -140,14 +189,22 @@ example computer, we will use SSH (if you are using PuTTY, see above).

SSH allows us to connect to UNIX computers remotely, and use them as if they
were our own. The general syntax of the connection command follows the format
`ssh [email protected]` Let's attempt to connect to the HPC
system now:
`ssh [email protected]` and
`ssh -i ~/.ssh/key_for_remote_computer [email protected]`
when using SSH keys.Let's attempt to connect to the HPC system now:

```
ssh yourUsername@{{ site.workshop_host_login }}
```
{: .language-bash}

or

```
ssh -i ~/.ssh/key_for_remote_computer yourUsername@{{ site.workshop_host_login }}
```
{: .language-bash}

```
{% include /snippets/01/login_output.{{ site.workshop_host_id }} %}
```
Expand Down