@@ -5,11 +5,14 @@ exercises: 10
5
5
questions :
6
6
- How do I open a terminal?
7
7
- How do I connect to a remote computer?
8
+ - What is an SSH key?
8
9
objectives :
9
10
- Connect to a remote HPC system.
10
11
keypoints :
11
- - To connect to a remote HPC system using SSH,
12
+ - To connect to a remote HPC system using SSH and a password ,
12
13
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`.
13
16
---
14
17
15
18
## Opening a Terminal
@@ -34,10 +37,6 @@ then a quick search on the Internet for "how to open a terminal window in" with
34
37
your particular Linux flavour appended to the end should quickly give you the
35
38
directions you need.
36
39
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
-
41
40
### Mac
42
41
43
42
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
129
128
basics already mentioned above before moving on to navigating the remote
130
129
system.
131
130
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
+
132
179
## Logging onto the system
133
180
134
181
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).
140
187
141
188
SSH allows us to connect to UNIX computers remotely, and use them as if they
142
189
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:
145
193
146
194
```
147
195
ssh yourUsername@{{ site.workshop_host_login }}
148
196
```
149
197
{: .language-bash}
150
198
199
+ or
200
+ ```
201
+ ssh -i ~/.ssh/key_for_remote_computer yourUsername@{{ site.workshop_host_login }}
202
+ ```
203
+ {: .language-bash}
204
+
151
205
```
152
206
{% include /snippets/01/login_output.{{ site.workshop_host_id }} %}
153
207
```
0 commit comments