Skip to content
This repository was archived by the owner on Aug 14, 2024. It is now read-only.

Commit 842c2c3

Browse files
authored
Update 01-connecting.md
Add ssh key information based on https://arc-lessons.github.io/security/04_sshkeys.html suggestions for improvements welcome. Remove Ubuntu shortcut, many flavours of Ubuntu and different types of desktop, so shortcut to open terminal may not be applicable to all.
1 parent 75ab95f commit 842c2c3

File tree

1 file changed

+61
-7
lines changed

1 file changed

+61
-7
lines changed

_episodes/01-connecting.md

+61-7
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@ exercises: 10
55
questions:
66
- How do I open a terminal?
77
- How do I connect to a remote computer?
8+
- What is an SSH key?
89
objectives:
910
- Connect to a remote HPC system.
1011
keypoints:
11-
- To connect to a remote HPC system using SSH,
12+
- To connect to a remote HPC system using SSH and a password,
1213
run `ssh yourUsername@remote.computer.address`.
14+
- To connect to a remote HPC system using SSH and an SSH key,
15+
run `ssh -i ~/.ssh/key_for_remote_computer yourUsername@remote.computer.address`.
1316
---
1417

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

37-
A very popular version of Linux is Ubuntu. There are many ways to open a
38-
terminal window in Ubuntu but a very fast way is to use the terminal shortcut
39-
key sequence: Ctrl+Alt+T.
40-
4140
### Mac
4241

4342
Macs have had a terminal built in since the first version of OS X since it is
@@ -129,6 +128,54 @@ For those logging in with PuTTY it would likely be best to cover the terminal
129128
basics already mentioned above before moving on to navigating the remote
130129
system.
131130

131+
## Creating an SSH key
132+
133+
SSH keys are an alternative method for authentication to obtain access to
134+
remote computing systems. They can also be used for authentication when
135+
transferring files or for accessing version control systems. In this section
136+
you will create a pair of SSH keys, a private key which you keep on your
137+
own computer and a public key which is placed on the remote HPC system
138+
that you will log in to.
139+
140+
### Linux, Mac and Windows Subsystem for Linux
141+
142+
Once you have opened a terminal generate a public private SSH keypair by
143+
using
144+
145+
```
146+
ssh-keygen -o -a 100 -t rsa -b 4096 -f ~/.ssh/key_for_remote_computer
147+
```
148+
where
149+
150+
- ssh-keygen is the command to generate the key pair
151+
- -o specifies to use a strong format to save the key
152+
- -a 100 increases the strength of encryption with your passphrase
153+
- -t rsa specifies the encryption method used, in this case
154+
[RSA or Rivest–Shamir–Adleman
155+
encryption](https://en.wikipedia.org/wiki/RSA_(cryptosystem))
156+
- -f filename specifies the name of the ssh key, by default these are
157+
stored in the directory ~/.ssh
158+
159+
It is helpful to strengthen the security of your key by using a password.
160+
Check the director ~/.ssh which should contain two new files
161+
~/.ssh/key_for_remote_computer.pub and
162+
~/.ssh/key_for_remote_computer , the key with the .pub extension is the
163+
public key. You should give this to the person managing access of the
164+
remote system you want to log in to. The private key remains with you.
165+
If someone obtains the private key and it does not have a password,
166+
it can be used to log into systems where the public key has been placed,
167+
so be careful with your ssh private keys. If you think they have been
168+
compromised, ask people managing systems you have access to, to remove
169+
compromised keys and replace them with new ones you have generated.
170+
171+
### Windows
172+
173+
On Windows you can use
174+
- puttygen, see the Putty
175+
[documentation](https://www.chiark.greenend.org.uk/~sgtatham/putty/docs.html)
176+
- MobaKeyGen, see the MoabXterm
177+
[documentation](https://mobaxterm.mobatek.net/documentation.html)
178+
132179
## Logging onto the system
133180

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

141188
SSH allows us to connect to UNIX computers remotely, and use them as if they
142189
were our own. The general syntax of the connection command follows the format
143-
`ssh yourUsername@some.computer.address` Let's attempt to connect to the HPC
144-
system now:
190+
`ssh yourUsername@some.computer.address` and
191+
`ssh -i ~/.ssh/key_for_remote_computer yourUsername@remote.computer.address`
192+
when using SSH keys.Let's attempt to connect to the HPC system now:
145193

146194
```
147195
ssh yourUsername@{{ site.workshop_host_login }}
148196
```
149197
{: .language-bash}
150198

199+
or
200+
```
201+
ssh -i ~/.ssh/key_for_remote_computer yourUsername@{{ site.workshop_host_login }}
202+
```
203+
{: .language-bash}
204+
151205
```
152206
{% include /snippets/01/login_output.{{ site.workshop_host_id }} %}
153207
```

0 commit comments

Comments
 (0)