Skip to content

Commit ce52072

Browse files
committed
install SSH key
1 parent 3b41c30 commit ce52072

File tree

2 files changed

+75
-24
lines changed

2 files changed

+75
-24
lines changed

_episodes/12-cluster.md

+75-22
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impressive than the [Top-500](https://www.top500.org). Clusters are often
5151
maintained in computing centers that support several such systems, all sharing
5252
common networking and storage to support common compute intensive tasks.
5353

54-
## Logging In
54+
## Secure Connections
5555

5656
The first step in using a cluster is to establish a connection from our laptop
5757
to the cluster. When we are sitting at a computer (or standing, or holding it
@@ -101,18 +101,17 @@ through the use of SSH keys and an SSH agent to both strengthen your security
101101

102102
### Better Security With SSH Keys
103103

104-
The [Lesson Setup]({{ page.root }}/setup) provides instructions for
105-
installing a [shell application][setup-shell] with [SSH][setup-ssh].
106-
If you have not done so already, please open that shell application with a
107-
Unix-like command line interface to your system.
104+
The [Lesson Setup]({{ page.root }}/setup) provides instructions for installing
105+
a shell application with SSH. If you have not done so already, please open that
106+
shell application with a Unix-like command line interface to your system.
108107

109108
SSH keys are an alternative method for authentication to obtain access to
110109
remote computing systems. They can also be used for authentication when
111110
transferring files or for accessing version control systems. In this section
112111
you will create a pair of SSH keys:
113112

114113
* a private key which you keep on your own computer, and
115-
* a public key which is placed on any remote system you will access.
114+
* a public key which can be placed on any remote system you will access.
116115

117116
> ## Private keys are your secure digital passport
118117
>
@@ -180,7 +179,7 @@ Take a look in `~/.ssh` (use `ls ~/.ssh`). You should see two new files:
180179
> Nothing is *less* secure than a private key with no password. If you skipped
181180
> password entry by accident, go back and generate a new key pair *with* a
182181
> strong password.
183-
{: .error}
182+
{: .warning}
184183

185184
##### Use RSA for Older Systems
186185

@@ -251,7 +250,7 @@ Take a look in the folder you specified. You should see two new files:
251250
asks for a key, this is the one to send. It is also safe to upload to
252251
websites such as GitHub: it is meant to be seen.
253252

254-
## SSH Agent for Easier Key Handling
253+
### SSH Agent for Easier Key Handling
255254

256255
An SSH key is only as strong as the password used to unlock it, but on the
257256
other hand, typing out a complex password every time you connect to a machine
@@ -266,7 +265,7 @@ password safe, and removes the tedium of entering the password multiple times.
266265
Just remember your password, because once it expires in the Agent, you have to
267266
type it in again.
268267

269-
### SSH Agents on Linux, macOS, and Windows
268+
#### SSH Agents on Linux, macOS, and Windows
270269

271270
Open your terminal application and check if an agent is running:
272271

@@ -307,26 +306,38 @@ Lifetime set to 86400 seconds
307306
For the duration (8 hours), whenever you use that key, the SSH Agent will
308307
provide the key on your behalf without you having to type a single keystroke.
309308

310-
### SSH Agent on PuTTY
309+
#### SSH Agent on PuTTY
311310

312311
If you are using PuTTY on Windows, download and use `pageant` as the SSH agent.
313312
See the [PuTTY documentation][putty-agent].
314313

315-
### Log in
314+
### Transfer Your Public Key
315+
316+
{% if site.remote.portal %}
317+
Visit {{ site.remote.portal }} to upload your SSH public key.
318+
{% else %}
319+
Use the **s**ecure **c**o**p**y tool to send your public key to the cluster.
320+
321+
```
322+
{{ site.local.prompt }} scp ~/.ssh/id_ed25519.pub {{ site.remote.user }}@{{ site.remote.login }}:~/
323+
```
324+
{: .language-bash}
325+
{% endif %}
326+
327+
## Log In to the Cluster
316328

317329
Go ahead and open your terminal or graphical SSH client, then log in to the
318-
cluster using your username and the remote computer you can reach from the
319-
outside world, {{ site.remote.location }}.
330+
cluster. Replace `{{ site.remote.user }}` with your username or the one
331+
supplied by the instructors.
320332

321333
```
322334
{{ site.local.prompt }} ssh {{ site.remote.user }}@{{ site.remote.login }}
323335
```
324336
{: .language-bash}
325337

326-
Remember to replace `{{ site.remote.user }}` with your username or the one
327-
supplied by the instructors. You may be asked for your password. Watch out: the
328-
characters you type after the password prompt are not displayed on the screen.
329-
Normal output will resume once you press `Enter`.
338+
You may be asked for your password. Watch out: the characters you type after
339+
the password prompt are not displayed on the screen. Normal output will resume
340+
once you press `Enter`.
330341

331342
You may have noticed that the prompt changed when you logged into the remote
332343
system using the terminal (if you logged in using PuTTY this will not apply
@@ -345,7 +356,7 @@ following convention:
345356
terminal connected to the remote system
346357
- `$` when it really doesn't matter which system the terminal is connected to.
347358

348-
## Looking Around
359+
## Looking Around Your Remote Home
349360

350361
Very often, many users are tempted to think of a high-performance computing
351362
installation as one giant, magical machine. Sometimes, people will assume that
@@ -394,16 +405,56 @@ double-check, include hidden files in your directory listing:
394405
```
395406
{: .language-bash}
396407
```
397-
. .bashrc
408+
. .bashrc id_ed25519.pub
398409
.. .ssh
399410
```
400411
{: .output}
401412

402413
In the first column, `.` is a reference to the current directory and `..` a
403414
reference to its parent (`{{ site.remote.homedir }}`). You may or may not see
404-
the other two files, or files like them: `.bashrc` is a shell configuration
405-
file, which you can edit with your preferences; and `.ssh` is a directory
406-
storing SSH keys and a record of authorized connections.
415+
the other files, or files like them: `.bashrc` is a shell configuration file,
416+
which you can edit with your preferences; and `.ssh` is a directory storing SSH
417+
keys and a record of authorized connections.
418+
419+
### Install Your SSH Key
420+
421+
If you transferred your SSH public key with `scp`, you should see
422+
`id_ed25519.pub` in your home directory. To "install" this key, it must be
423+
listed in a file named `authorized_keys` under the `.ssh` folder.
424+
425+
If the `.ssh` folder was not listed above, then it does not yet exist: create it.
426+
427+
```
428+
{{ site.remote.prompt }} mkdir ~/.ssh
429+
```
430+
{: .language-bash}
431+
432+
Now, use `cat` to print your public key, but redirect the output, appending it
433+
to the `authorized_keys` file:
434+
435+
```
436+
{{ site.remote.prompt }} cat ~/id_ed25519.pub >> ~/.ssh/authorized_keys
437+
```
438+
{: .language-bash}
439+
440+
That's all! Disconnect, then try to log back into the remote: if your key and
441+
agent have been configured correctly, you should not be prompted for a password.
442+
443+
```
444+
{{ site.remote.prompt }} logout
445+
```
446+
{: .language-bash}
447+
448+
```
449+
{{ site.local.prompt }} ssh {{ site.remote.user }}@{{ site.remote.login }}
450+
```
451+
{: .language-bash}
452+
453+
454+
```
455+
{{ site.remote.prompt }} ls
456+
```
457+
{: .language-bash}
407458

408459
> ## What's different between your machine and the remote?
409460
>
@@ -429,6 +480,8 @@ storing SSH keys and a record of authorized connections.
429480
> {: .solution}
430481
{: .discussion}
431482
483+
## Look Around the Rest of the System
484+
432485
Most high-performance computing systems run the Linux operating system, which
433486
is built around the UNIX [Filesystem Hierarchy Standard][fshs]. Instead of
434487
having a separate root for each hard drive or storage medium, all files and

setup.md

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ recommend that these tools are installed (or at least downloaded) beforehand.
1111
1. [A terminal application or command-line interface](
1212
#where-to-type-commands-how-to-open-a-new-shell)
1313
2. [A Secure Shell application](#ssh-for-secure-connections)
14-
3. [A public-private key pair](#public-private-key-pair-for-ssh)
15-
4. [An SSH key agent](#ssh-agent-for-easier-key-handling)
1614

1715
> ## Bash and SSH
1816
>

0 commit comments

Comments
 (0)