Skip to content

Commit 42454f3

Browse files
Update keys.md
1 parent 786b9b3 commit 42454f3

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

recipes/shell/ssh/keys.md

+10-15
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ If the machine doesn't have an SSH key set, you'll have to _generate_ one - see
6060

6161
How to generate a new SSH key pair.
6262

63+
_Note that GitHub dropped support for RSA so here we use Ed25519 algorithm instead. See [GitHub doc](https://help.github.com/en/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent)._
64+
6365
First _navigate_ to the appropriate directory, to ensure the files get generated there.
6466

6567
```sh
@@ -72,42 +74,35 @@ Use the command below or see a bit further down for use with more flags.
7274
Create the key pair:
7375

7476
```sh
75-
$ ssh-keygen -t rsa
77+
$ ssh-keygen -t ed25519
7678
```
7779

7880
If this is your first SSH key on the current machine, you can leave the location as the default and press enter.
7981

8082
```
8183
Generating public/private rsa key pair.
82-
Enter file in which to save the key (~/.ssh/id_rsa):
84+
Enter file in which to save the key (~/.ssh/id_ed25519):
8385
```
8486

8587
That will use filenames as:
8688

8789
```
88-
~/.ssh/id_rsa
89-
~/.ssh/id_rsa.pub
90+
~/.ssh/id_ed25519
91+
~/.ssh/id_ed25519.pub
9092
```
9193

9294
Or, enter a custom name like `id_rsa_abc` and press enter.
9395

9496
You can press enter to skip through the rest of the options - unless you want to set a passphrase on the SSH key.
9597

96-
Alternate command, based on what is recommended by this [GitHub doc](https://help.github.com/en/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent).
97-
98-
```sh
99-
$ # New method
100-
$ ssh-keygen -t ed25519 -C "[email protected]"
101-
$ # Old method
102-
$ ssh-keygen -t rsa -b 4096
103-
```
104-
10598
Flags:
10699

107-
- `-t rsa`: Specifies the type of key to create. The possible values are “rsa1” for protocol version 1 and “dsa”, “ecdsa”, “ed25519”, or “rsa” for protocol version 2.
100+
- `-t ed25519`: Specifies the type of key to create. The possible values are “rsa1” for protocol version 1 and “dsa”, “ecdsa”, “ed25519”, or “rsa” for protocol version 2.
108101
- `-b 4096`: Specifies the number of bits in the key to create.
109102
- `-f ~/.ssh/foo.key`: Specifies the filename of the key file, if you don't want to set this in the REPL.
110-
- `-C COMMENT`: A comment added to the end to help identify. This could be `"[email protected]"` as recommended by GitHub docs. But I prefer `"$USER@$HOSTNAME"` e.g. `michael@dell`, as it is specific to your machine. If you omit this flag you'll get that anyway.
103+
- `-C COMMENT`: A comment added to the end to help identify it.
104+
- Set as `[email protected]` as recommended by GitHub docs.
105+
- If you omit the flag, you'll get the default value, which looks like `"$USER@$HOSTNAME"` e.g. `michael@dell`. This makes sense if you want to use that machine name in your key contents as well as the name on GitHUb. And if you have multiple machines and want to identify them (rather than a single email address across machines). For security, should avoid using the same SSH key on multiple machines (which might be the temptation if you use the email as the identifier).
111106

112107
See also this SSH Public Key [tutorial](https://git-scm.com/book/en/v2/Git-on-the-Server-Generating-Your-SSH-Public-Key) on Git's docs, but that doesn't add much to what is covered above.
113108

0 commit comments

Comments
 (0)