diff options
Diffstat (limited to 'ssh-keygen.0')
-rw-r--r-- | ssh-keygen.0 | 694 |
1 files changed, 694 insertions, 0 deletions
diff --git a/ssh-keygen.0 b/ssh-keygen.0 new file mode 100644 index 000000000..b68736c11 --- /dev/null +++ b/ssh-keygen.0 | |||
@@ -0,0 +1,694 @@ | |||
1 | SSH-KEYGEN(1) General Commands Manual SSH-KEYGEN(1) | ||
2 | |||
3 | NAME | ||
4 | ssh-keygen M-bM-^@M-^S authentication key generation, management and conversion | ||
5 | |||
6 | SYNOPSIS | ||
7 | ssh-keygen [-q] [-b bits] [-C comment] [-f output_keyfile] [-m format] | ||
8 | [-N new_passphrase] [-t dsa | ecdsa | ed25519 | rsa] | ||
9 | ssh-keygen -p [-f keyfile] [-m format] [-N new_passphrase] | ||
10 | [-P old_passphrase] | ||
11 | ssh-keygen -i [-f input_keyfile] [-m key_format] | ||
12 | ssh-keygen -e [-f input_keyfile] [-m key_format] | ||
13 | ssh-keygen -y [-f input_keyfile] | ||
14 | ssh-keygen -c [-C comment] [-f keyfile] [-P passphrase] | ||
15 | ssh-keygen -l [-v] [-E fingerprint_hash] [-f input_keyfile] | ||
16 | ssh-keygen -B [-f input_keyfile] | ||
17 | ssh-keygen -D pkcs11 | ||
18 | ssh-keygen -F hostname [-lv] [-f known_hosts_file] | ||
19 | ssh-keygen -H [-f known_hosts_file] | ||
20 | ssh-keygen -R hostname [-f known_hosts_file] | ||
21 | ssh-keygen -r hostname [-g] [-f input_keyfile] | ||
22 | ssh-keygen -G output_file [-v] [-b bits] [-M memory] [-S start_point] | ||
23 | ssh-keygen -f input_file -T output_file [-v] [-a rounds] [-J num_lines] | ||
24 | [-j start_line] [-K checkpt] [-W generator] | ||
25 | ssh-keygen -I certificate_identity -s ca_key [-hU] [-D pkcs11_provider] | ||
26 | [-n principals] [-O option] [-V validity_interval] | ||
27 | [-z serial_number] file ... | ||
28 | ssh-keygen -L [-f input_keyfile] | ||
29 | ssh-keygen -A [-f prefix_path] | ||
30 | ssh-keygen -k -f krl_file [-u] [-s ca_public] [-z version_number] | ||
31 | file ... | ||
32 | ssh-keygen -Q -f krl_file file ... | ||
33 | ssh-keygen -Y check-novalidate -n namespace -s signature_file | ||
34 | ssh-keygen -Y sign -f key_file -n namespace file ... | ||
35 | ssh-keygen -Y verify -f allowed_signers_file -I signer_identity | ||
36 | -n namespace -s signature_file [-r revocation_file] | ||
37 | |||
38 | DESCRIPTION | ||
39 | ssh-keygen generates, manages and converts authentication keys for | ||
40 | ssh(1). ssh-keygen can create keys for use by SSH protocol version 2. | ||
41 | |||
42 | The type of key to be generated is specified with the -t option. If | ||
43 | invoked without any arguments, ssh-keygen will generate an RSA key. | ||
44 | |||
45 | ssh-keygen is also used to generate groups for use in Diffie-Hellman | ||
46 | group exchange (DH-GEX). See the MODULI GENERATION section for details. | ||
47 | |||
48 | Finally, ssh-keygen can be used to generate and update Key Revocation | ||
49 | Lists, and to test whether given keys have been revoked by one. See the | ||
50 | KEY REVOCATION LISTS section for details. | ||
51 | |||
52 | Normally each user wishing to use SSH with public key authentication runs | ||
53 | this once to create the authentication key in ~/.ssh/id_dsa, | ||
54 | ~/.ssh/id_ecdsa, ~/.ssh/id_ed25519 or ~/.ssh/id_rsa. Additionally, the | ||
55 | system administrator may use this to generate host keys, as seen in | ||
56 | /etc/rc. | ||
57 | |||
58 | Normally this program generates the key and asks for a file in which to | ||
59 | store the private key. The public key is stored in a file with the same | ||
60 | name but M-bM-^@M-^\.pubM-bM-^@M-^] appended. The program also asks for a passphrase. The | ||
61 | passphrase may be empty to indicate no passphrase (host keys must have an | ||
62 | empty passphrase), or it may be a string of arbitrary length. A | ||
63 | passphrase is similar to a password, except it can be a phrase with a | ||
64 | series of words, punctuation, numbers, whitespace, or any string of | ||
65 | characters you want. Good passphrases are 10-30 characters long, are not | ||
66 | simple sentences or otherwise easily guessable (English prose has only | ||
67 | 1-2 bits of entropy per character, and provides very bad passphrases), | ||
68 | and contain a mix of upper and lowercase letters, numbers, and non- | ||
69 | alphanumeric characters. The passphrase can be changed later by using | ||
70 | the -p option. | ||
71 | |||
72 | There is no way to recover a lost passphrase. If the passphrase is lost | ||
73 | or forgotten, a new key must be generated and the corresponding public | ||
74 | key copied to other machines. | ||
75 | |||
76 | ssh-keygen will by default write keys in an OpenSSH-specific format. | ||
77 | This format is preferred as it offers better protection for keys at rest | ||
78 | as well as allowing storage of key comments within the private key file | ||
79 | itself. The key comment may be useful to help identify the key. The | ||
80 | comment is initialized to M-bM-^@M-^\user@hostM-bM-^@M-^] when the key is created, but can be | ||
81 | changed using the -c option. | ||
82 | |||
83 | It is still possible for ssh-keygen to write the previously-used PEM | ||
84 | format private keys using the -m flag. This may be used when generating | ||
85 | new keys, and existing new-format keys may be converted using this option | ||
86 | in conjunction with the -p (change passphrase) flag. | ||
87 | |||
88 | After a key is generated, instructions below detail where the keys should | ||
89 | be placed to be activated. | ||
90 | |||
91 | The options are as follows: | ||
92 | |||
93 | -A For each of the key types (rsa, dsa, ecdsa and ed25519) for which | ||
94 | host keys do not exist, generate the host keys with the default | ||
95 | key file path, an empty passphrase, default bits for the key | ||
96 | type, and default comment. If -f has also been specified, its | ||
97 | argument is used as a prefix to the default path for the | ||
98 | resulting host key files. This is used by /etc/rc to generate | ||
99 | new host keys. | ||
100 | |||
101 | -a rounds | ||
102 | When saving a private key, this option specifies the number of | ||
103 | KDF (key derivation function) rounds used. Higher numbers result | ||
104 | in slower passphrase verification and increased resistance to | ||
105 | brute-force password cracking (should the keys be stolen). | ||
106 | |||
107 | When screening DH-GEX candidates (using the -T command), this | ||
108 | option specifies the number of primality tests to perform. | ||
109 | |||
110 | -B Show the bubblebabble digest of specified private or public key | ||
111 | file. | ||
112 | |||
113 | -b bits | ||
114 | Specifies the number of bits in the key to create. For RSA keys, | ||
115 | the minimum size is 1024 bits and the default is 3072 bits. | ||
116 | Generally, 3072 bits is considered sufficient. DSA keys must be | ||
117 | exactly 1024 bits as specified by FIPS 186-2. For ECDSA keys, | ||
118 | the -b flag determines the key length by selecting from one of | ||
119 | three elliptic curve sizes: 256, 384 or 521 bits. Attempting to | ||
120 | use bit lengths other than these three values for ECDSA keys will | ||
121 | fail. Ed25519 keys have a fixed length and the -b flag will be | ||
122 | ignored. | ||
123 | |||
124 | -C comment | ||
125 | Provides a new comment. | ||
126 | |||
127 | -c Requests changing the comment in the private and public key | ||
128 | files. The program will prompt for the file containing the | ||
129 | private keys, for the passphrase if the key has one, and for the | ||
130 | new comment. | ||
131 | |||
132 | -D pkcs11 | ||
133 | Download the public keys provided by the PKCS#11 shared library | ||
134 | pkcs11. When used in combination with -s, this option indicates | ||
135 | that a CA key resides in a PKCS#11 token (see the CERTIFICATES | ||
136 | section for details). | ||
137 | |||
138 | -E fingerprint_hash | ||
139 | Specifies the hash algorithm used when displaying key | ||
140 | fingerprints. Valid options are: M-bM-^@M-^\md5M-bM-^@M-^] and M-bM-^@M-^\sha256M-bM-^@M-^]. The | ||
141 | default is M-bM-^@M-^\sha256M-bM-^@M-^]. | ||
142 | |||
143 | -e This option will read a private or public OpenSSH key file and | ||
144 | print to stdout a public key in one of the formats specified by | ||
145 | the -m option. The default export format is M-bM-^@M-^\RFC4716M-bM-^@M-^]. This | ||
146 | option allows exporting OpenSSH keys for use by other programs, | ||
147 | including several commercial SSH implementations. | ||
148 | |||
149 | -F hostname | [hostname]:port | ||
150 | Search for the specified hostname (with optional port number) in | ||
151 | a known_hosts file, listing any occurrences found. This option | ||
152 | is useful to find hashed host names or addresses and may also be | ||
153 | used in conjunction with the -H option to print found keys in a | ||
154 | hashed format. | ||
155 | |||
156 | -f filename | ||
157 | Specifies the filename of the key file. | ||
158 | |||
159 | -G output_file | ||
160 | Generate candidate primes for DH-GEX. These primes must be | ||
161 | screened for safety (using the -T option) before use. | ||
162 | |||
163 | -g Use generic DNS format when printing fingerprint resource records | ||
164 | using the -r command. | ||
165 | |||
166 | -H Hash a known_hosts file. This replaces all hostnames and | ||
167 | addresses with hashed representations within the specified file; | ||
168 | the original content is moved to a file with a .old suffix. | ||
169 | These hashes may be used normally by ssh and sshd, but they do | ||
170 | not reveal identifying information should the file's contents be | ||
171 | disclosed. This option will not modify existing hashed hostnames | ||
172 | and is therefore safe to use on files that mix hashed and non- | ||
173 | hashed names. | ||
174 | |||
175 | -h When signing a key, create a host certificate instead of a user | ||
176 | certificate. Please see the CERTIFICATES section for details. | ||
177 | |||
178 | -I certificate_identity | ||
179 | Specify the key identity when signing a public key. Please see | ||
180 | the CERTIFICATES section for details. | ||
181 | |||
182 | -i This option will read an unencrypted private (or public) key file | ||
183 | in the format specified by the -m option and print an OpenSSH | ||
184 | compatible private (or public) key to stdout. This option allows | ||
185 | importing keys from other software, including several commercial | ||
186 | SSH implementations. The default import format is M-bM-^@M-^\RFC4716M-bM-^@M-^]. | ||
187 | |||
188 | -J num_lines | ||
189 | Exit after screening the specified number of lines while | ||
190 | performing DH candidate screening using the -T option. | ||
191 | |||
192 | -j start_line | ||
193 | Start screening at the specified line number while performing DH | ||
194 | candidate screening using the -T option. | ||
195 | |||
196 | -K checkpt | ||
197 | Write the last line processed to the file checkpt while | ||
198 | performing DH candidate screening using the -T option. This will | ||
199 | be used to skip lines in the input file that have already been | ||
200 | processed if the job is restarted. | ||
201 | |||
202 | -k Generate a KRL file. In this mode, ssh-keygen will generate a | ||
203 | KRL file at the location specified via the -f flag that revokes | ||
204 | every key or certificate presented on the command line. | ||
205 | Keys/certificates to be revoked may be specified by public key | ||
206 | file or using the format described in the KEY REVOCATION LISTS | ||
207 | section. | ||
208 | |||
209 | -L Prints the contents of one or more certificates. | ||
210 | |||
211 | -l Show fingerprint of specified public key file. For RSA and DSA | ||
212 | keys ssh-keygen tries to find the matching public key file and | ||
213 | prints its fingerprint. If combined with -v, a visual ASCII art | ||
214 | representation of the key is supplied with the fingerprint. | ||
215 | |||
216 | -M memory | ||
217 | Specify the amount of memory to use (in megabytes) when | ||
218 | generating candidate moduli for DH-GEX. | ||
219 | |||
220 | -m key_format | ||
221 | Specify a key format for key generation, the -i (import), -e | ||
222 | (export) conversion options, and the -p change passphrase | ||
223 | operation. The latter may be used to convert between OpenSSH | ||
224 | private key and PEM private key formats. The supported key | ||
225 | formats are: M-bM-^@M-^\RFC4716M-bM-^@M-^] (RFC 4716/SSH2 public or private key), | ||
226 | M-bM-^@M-^\PKCS8M-bM-^@M-^] (PKCS8 public or private key) or M-bM-^@M-^\PEMM-bM-^@M-^] (PEM public key). | ||
227 | By default OpenSSH will write newly-generated private keys in its | ||
228 | own format, but when converting public keys for export the | ||
229 | default format is M-bM-^@M-^\RFC4716M-bM-^@M-^]. Setting a format of M-bM-^@M-^\PEMM-bM-^@M-^] when | ||
230 | generating or updating a supported private key type will cause | ||
231 | the key to be stored in the legacy PEM private key format. | ||
232 | |||
233 | -N new_passphrase | ||
234 | Provides the new passphrase. | ||
235 | |||
236 | -n principals | ||
237 | Specify one or more principals (user or host names) to be | ||
238 | included in a certificate when signing a key. Multiple | ||
239 | principals may be specified, separated by commas. Please see the | ||
240 | CERTIFICATES section for details. | ||
241 | |||
242 | -O option | ||
243 | Specify a certificate option when signing a key. This option may | ||
244 | be specified multiple times. See also the CERTIFICATES section | ||
245 | for further details. | ||
246 | |||
247 | At present, no standard options are valid for host keys. The | ||
248 | options that are valid for user certificates are: | ||
249 | |||
250 | clear Clear all enabled permissions. This is useful for | ||
251 | clearing the default set of permissions so permissions | ||
252 | may be added individually. | ||
253 | |||
254 | critical:name[=contents] | ||
255 | extension:name[=contents] | ||
256 | Includes an arbitrary certificate critical option or | ||
257 | extension. The specified name should include a domain | ||
258 | suffix, e.g. M-bM-^@M-^\name@example.comM-bM-^@M-^]. If contents is | ||
259 | specified then it is included as the contents of the | ||
260 | extension/option encoded as a string, otherwise the | ||
261 | extension/option is created with no contents (usually | ||
262 | indicating a flag). Extensions may be ignored by a | ||
263 | client or server that does not recognise them, whereas | ||
264 | unknown critical options will cause the certificate to be | ||
265 | refused. | ||
266 | |||
267 | force-command=command | ||
268 | Forces the execution of command instead of any shell or | ||
269 | command specified by the user when the certificate is | ||
270 | used for authentication. | ||
271 | |||
272 | no-agent-forwarding | ||
273 | Disable ssh-agent(1) forwarding (permitted by default). | ||
274 | |||
275 | no-port-forwarding | ||
276 | Disable port forwarding (permitted by default). | ||
277 | |||
278 | no-pty Disable PTY allocation (permitted by default). | ||
279 | |||
280 | no-user-rc | ||
281 | Disable execution of ~/.ssh/rc by sshd(8) (permitted by | ||
282 | default). | ||
283 | |||
284 | no-x11-forwarding | ||
285 | Disable X11 forwarding (permitted by default). | ||
286 | |||
287 | permit-agent-forwarding | ||
288 | Allows ssh-agent(1) forwarding. | ||
289 | |||
290 | permit-port-forwarding | ||
291 | Allows port forwarding. | ||
292 | |||
293 | permit-pty | ||
294 | Allows PTY allocation. | ||
295 | |||
296 | permit-user-rc | ||
297 | Allows execution of ~/.ssh/rc by sshd(8). | ||
298 | |||
299 | permit-X11-forwarding | ||
300 | Allows X11 forwarding. | ||
301 | |||
302 | source-address=address_list | ||
303 | Restrict the source addresses from which the certificate | ||
304 | is considered valid. The address_list is a comma- | ||
305 | separated list of one or more address/netmask pairs in | ||
306 | CIDR format. | ||
307 | |||
308 | -P passphrase | ||
309 | Provides the (old) passphrase. | ||
310 | |||
311 | -p Requests changing the passphrase of a private key file instead of | ||
312 | creating a new private key. The program will prompt for the file | ||
313 | containing the private key, for the old passphrase, and twice for | ||
314 | the new passphrase. | ||
315 | |||
316 | -Q Test whether keys have been revoked in a KRL. | ||
317 | |||
318 | -q Silence ssh-keygen. | ||
319 | |||
320 | -R hostname | [hostname]:port | ||
321 | Removes all keys belonging to the specified hostname (with | ||
322 | optional port number) from a known_hosts file. This option is | ||
323 | useful to delete hashed hosts (see the -H option above). | ||
324 | |||
325 | -r hostname | ||
326 | Print the SSHFP fingerprint resource record named hostname for | ||
327 | the specified public key file. | ||
328 | |||
329 | -S start | ||
330 | Specify start point (in hex) when generating candidate moduli for | ||
331 | DH-GEX. | ||
332 | |||
333 | -s ca_key | ||
334 | Certify (sign) a public key using the specified CA key. Please | ||
335 | see the CERTIFICATES section for details. | ||
336 | |||
337 | When generating a KRL, -s specifies a path to a CA public key | ||
338 | file used to revoke certificates directly by key ID or serial | ||
339 | number. See the KEY REVOCATION LISTS section for details. | ||
340 | |||
341 | -T output_file | ||
342 | Test DH group exchange candidate primes (generated using the -G | ||
343 | option) for safety. | ||
344 | |||
345 | -t dsa | ecdsa | ed25519 | rsa | ||
346 | Specifies the type of key to create. The possible values are | ||
347 | M-bM-^@M-^\dsaM-bM-^@M-^], M-bM-^@M-^\ecdsaM-bM-^@M-^], M-bM-^@M-^\ed25519M-bM-^@M-^], or M-bM-^@M-^\rsaM-bM-^@M-^]. | ||
348 | |||
349 | This flag may also be used to specify the desired signature type | ||
350 | when signing certificates using an RSA CA key. The available RSA | ||
351 | signature variants are M-bM-^@M-^\ssh-rsaM-bM-^@M-^] (SHA1 signatures, not | ||
352 | recommended), M-bM-^@M-^\rsa-sha2-256M-bM-^@M-^], and M-bM-^@M-^\rsa-sha2-512M-bM-^@M-^] (the default). | ||
353 | |||
354 | -U When used in combination with -s, this option indicates that a CA | ||
355 | key resides in a ssh-agent(1). See the CERTIFICATES section for | ||
356 | more information. | ||
357 | |||
358 | -u Update a KRL. When specified with -k, keys listed via the | ||
359 | command line are added to the existing KRL rather than a new KRL | ||
360 | being created. | ||
361 | |||
362 | -V validity_interval | ||
363 | Specify a validity interval when signing a certificate. A | ||
364 | validity interval may consist of a single time, indicating that | ||
365 | the certificate is valid beginning now and expiring at that time, | ||
366 | or may consist of two times separated by a colon to indicate an | ||
367 | explicit time interval. | ||
368 | |||
369 | The start time may be specified as the string M-bM-^@M-^\alwaysM-bM-^@M-^] to | ||
370 | indicate the certificate has no specified start time, a date in | ||
371 | YYYYMMDD format, a time in YYYYMMDDHHMM[SS] format, a relative | ||
372 | time (to the current time) consisting of a minus sign followed by | ||
373 | an interval in the format described in the TIME FORMATS section | ||
374 | of sshd_config(5). | ||
375 | |||
376 | The end time may be specified as a YYYYMMDD date, a | ||
377 | YYYYMMDDHHMM[SS] time, a relative time starting with a plus | ||
378 | character or the string M-bM-^@M-^\foreverM-bM-^@M-^] to indicate that the | ||
379 | certificate has no expirty date. | ||
380 | |||
381 | For example: M-bM-^@M-^\+52w1dM-bM-^@M-^] (valid from now to 52 weeks and one day | ||
382 | from now), M-bM-^@M-^\-4w:+4wM-bM-^@M-^] (valid from four weeks ago to four weeks | ||
383 | from now), M-bM-^@M-^\20100101123000:20110101123000M-bM-^@M-^] (valid from 12:30 PM, | ||
384 | January 1st, 2010 to 12:30 PM, January 1st, 2011), M-bM-^@M-^\-1d:20110101M-bM-^@M-^] | ||
385 | (valid from yesterday to midnight, January 1st, 2011). | ||
386 | M-bM-^@M-^\-1m:foreverM-bM-^@M-^] (valid from one minute ago and never expiring). | ||
387 | |||
388 | -v Verbose mode. Causes ssh-keygen to print debugging messages | ||
389 | about its progress. This is helpful for debugging moduli | ||
390 | generation. Multiple -v options increase the verbosity. The | ||
391 | maximum is 3. | ||
392 | |||
393 | -W generator | ||
394 | Specify desired generator when testing candidate moduli for DH- | ||
395 | GEX. | ||
396 | |||
397 | -y This option will read a private OpenSSH format file and print an | ||
398 | OpenSSH public key to stdout. | ||
399 | |||
400 | -Y sign | ||
401 | Cryptographically sign a file or some data using a SSH key. When | ||
402 | signing, ssh-keygen accepts zero or more files to sign on the | ||
403 | command-line - if no files are specified then ssh-keygen will | ||
404 | sign data presented on standard input. Signatures are written to | ||
405 | the path of the input file with M-bM-^@M-^\.sigM-bM-^@M-^] appended, or to standard | ||
406 | output if the message to be signed was read from standard input. | ||
407 | |||
408 | The key used for signing is specified using the -f option and may | ||
409 | refer to either a private key, or a public key with the private | ||
410 | half available via ssh-agent(1). An additional signature | ||
411 | namespace, used to prevent signature confusion across different | ||
412 | domains of use (e.g. file signing vs email signing) must be | ||
413 | provided via the -n flag. Namespaces are arbitrary strings, and | ||
414 | may include: M-bM-^@M-^\fileM-bM-^@M-^] for file signing, M-bM-^@M-^\emailM-bM-^@M-^] for email signing. | ||
415 | For custom uses, it is recommended to use names following a | ||
416 | NAMESPACE@YOUR.DOMAIN pattern to generate unambiguous namespaces. | ||
417 | |||
418 | -Y verify | ||
419 | Request to verify a signature generated using ssh-keygen -Y sign | ||
420 | as described above. When verifying a signature, ssh-keygen | ||
421 | accepts a message on standard input and a signature namespace | ||
422 | using -n. A file containing the corresponding signature must | ||
423 | also be supplied using the -s flag, along with the identity of | ||
424 | the signer using -I and a list of allowed signers via the -f | ||
425 | flag. The format of the allowed signers file is documented in | ||
426 | the ALLOWED SIGNERS section below. A file containing revoked | ||
427 | keys can be passed using the -r flag. The revocation file may be | ||
428 | a KRL or a one-per-line list of public keys. Successful | ||
429 | verification by an authorized signer is signalled by ssh-keygen | ||
430 | |||
431 | -Y check-novalidate | ||
432 | Checks that a signature generated using ssh-keygen -Y sign has a | ||
433 | valid structure. This does not validate if a signature comes | ||
434 | from an authorized signer. When testing a signature, ssh-keygen | ||
435 | accepts a message on standard input and a signature namespace | ||
436 | using -n. A file containing the corresponding signature must | ||
437 | also be supplied using the -s flag. Successful testing of the | ||
438 | signature is signalled by ssh-keygen returning a zero exit | ||
439 | status. | ||
440 | |||
441 | -z serial_number | ||
442 | Specifies a serial number to be embedded in the certificate to | ||
443 | distinguish this certificate from others from the same CA. If | ||
444 | the serial_number is prefixed with a M-bM-^@M-^X+M-bM-^@M-^Y character, then the | ||
445 | serial number will be incremented for each certificate signed on | ||
446 | a single command-line. The default serial number is zero. | ||
447 | |||
448 | When generating a KRL, the -z flag is used to specify a KRL | ||
449 | version number. | ||
450 | |||
451 | MODULI GENERATION | ||
452 | ssh-keygen may be used to generate groups for the Diffie-Hellman Group | ||
453 | Exchange (DH-GEX) protocol. Generating these groups is a two-step | ||
454 | process: first, candidate primes are generated using a fast, but memory | ||
455 | intensive process. These candidate primes are then tested for | ||
456 | suitability (a CPU-intensive process). | ||
457 | |||
458 | Generation of primes is performed using the -G option. The desired | ||
459 | length of the primes may be specified by the -b option. For example: | ||
460 | |||
461 | # ssh-keygen -G moduli-2048.candidates -b 2048 | ||
462 | |||
463 | By default, the search for primes begins at a random point in the desired | ||
464 | length range. This may be overridden using the -S option, which | ||
465 | specifies a different start point (in hex). | ||
466 | |||
467 | Once a set of candidates have been generated, they must be screened for | ||
468 | suitability. This may be performed using the -T option. In this mode | ||
469 | ssh-keygen will read candidates from standard input (or a file specified | ||
470 | using the -f option). For example: | ||
471 | |||
472 | # ssh-keygen -T moduli-2048 -f moduli-2048.candidates | ||
473 | |||
474 | By default, each candidate will be subjected to 100 primality tests. | ||
475 | This may be overridden using the -a option. The DH generator value will | ||
476 | be chosen automatically for the prime under consideration. If a specific | ||
477 | generator is desired, it may be requested using the -W option. Valid | ||
478 | generator values are 2, 3, and 5. | ||
479 | |||
480 | Screened DH groups may be installed in /etc/moduli. It is important that | ||
481 | this file contains moduli of a range of bit lengths and that both ends of | ||
482 | a connection share common moduli. | ||
483 | |||
484 | CERTIFICATES | ||
485 | ssh-keygen supports signing of keys to produce certificates that may be | ||
486 | used for user or host authentication. Certificates consist of a public | ||
487 | key, some identity information, zero or more principal (user or host) | ||
488 | names and a set of options that are signed by a Certification Authority | ||
489 | (CA) key. Clients or servers may then trust only the CA key and verify | ||
490 | its signature on a certificate rather than trusting many user/host keys. | ||
491 | Note that OpenSSH certificates are a different, and much simpler, format | ||
492 | to the X.509 certificates used in ssl(8). | ||
493 | |||
494 | ssh-keygen supports two types of certificates: user and host. User | ||
495 | certificates authenticate users to servers, whereas host certificates | ||
496 | authenticate server hosts to users. To generate a user certificate: | ||
497 | |||
498 | $ ssh-keygen -s /path/to/ca_key -I key_id /path/to/user_key.pub | ||
499 | |||
500 | The resultant certificate will be placed in /path/to/user_key-cert.pub. | ||
501 | A host certificate requires the -h option: | ||
502 | |||
503 | $ ssh-keygen -s /path/to/ca_key -I key_id -h /path/to/host_key.pub | ||
504 | |||
505 | The host certificate will be output to /path/to/host_key-cert.pub. | ||
506 | |||
507 | It is possible to sign using a CA key stored in a PKCS#11 token by | ||
508 | providing the token library using -D and identifying the CA key by | ||
509 | providing its public half as an argument to -s: | ||
510 | |||
511 | $ ssh-keygen -s ca_key.pub -D libpkcs11.so -I key_id user_key.pub | ||
512 | |||
513 | Similarly, it is possible for the CA key to be hosted in a ssh-agent(1). | ||
514 | This is indicated by the -U flag and, again, the CA key must be | ||
515 | identified by its public half. | ||
516 | |||
517 | $ ssh-keygen -Us ca_key.pub -I key_id user_key.pub | ||
518 | |||
519 | In all cases, key_id is a "key identifier" that is logged by the server | ||
520 | when the certificate is used for authentication. | ||
521 | |||
522 | Certificates may be limited to be valid for a set of principal | ||
523 | (user/host) names. By default, generated certificates are valid for all | ||
524 | users or hosts. To generate a certificate for a specified set of | ||
525 | principals: | ||
526 | |||
527 | $ ssh-keygen -s ca_key -I key_id -n user1,user2 user_key.pub | ||
528 | $ ssh-keygen -s ca_key -I key_id -h -n host.domain host_key.pub | ||
529 | |||
530 | Additional limitations on the validity and use of user certificates may | ||
531 | be specified through certificate options. A certificate option may | ||
532 | disable features of the SSH session, may be valid only when presented | ||
533 | from particular source addresses or may force the use of a specific | ||
534 | command. For a list of valid certificate options, see the documentation | ||
535 | for the -O option above. | ||
536 | |||
537 | Finally, certificates may be defined with a validity lifetime. The -V | ||
538 | option allows specification of certificate start and end times. A | ||
539 | certificate that is presented at a time outside this range will not be | ||
540 | considered valid. By default, certificates are valid from UNIX Epoch to | ||
541 | the distant future. | ||
542 | |||
543 | For certificates to be used for user or host authentication, the CA | ||
544 | public key must be trusted by sshd(8) or ssh(1). Please refer to those | ||
545 | manual pages for details. | ||
546 | |||
547 | KEY REVOCATION LISTS | ||
548 | ssh-keygen is able to manage OpenSSH format Key Revocation Lists (KRLs). | ||
549 | These binary files specify keys or certificates to be revoked using a | ||
550 | compact format, taking as little as one bit per certificate if they are | ||
551 | being revoked by serial number. | ||
552 | |||
553 | KRLs may be generated using the -k flag. This option reads one or more | ||
554 | files from the command line and generates a new KRL. The files may | ||
555 | either contain a KRL specification (see below) or public keys, listed one | ||
556 | per line. Plain public keys are revoked by listing their hash or | ||
557 | contents in the KRL and certificates revoked by serial number or key ID | ||
558 | (if the serial is zero or not available). | ||
559 | |||
560 | Revoking keys using a KRL specification offers explicit control over the | ||
561 | types of record used to revoke keys and may be used to directly revoke | ||
562 | certificates by serial number or key ID without having the complete | ||
563 | original certificate on hand. A KRL specification consists of lines | ||
564 | containing one of the following directives followed by a colon and some | ||
565 | directive-specific information. | ||
566 | |||
567 | serial: serial_number[-serial_number] | ||
568 | Revokes a certificate with the specified serial number. Serial | ||
569 | numbers are 64-bit values, not including zero and may be | ||
570 | expressed in decimal, hex or octal. If two serial numbers are | ||
571 | specified separated by a hyphen, then the range of serial numbers | ||
572 | including and between each is revoked. The CA key must have been | ||
573 | specified on the ssh-keygen command line using the -s option. | ||
574 | |||
575 | id: key_id | ||
576 | Revokes a certificate with the specified key ID string. The CA | ||
577 | key must have been specified on the ssh-keygen command line using | ||
578 | the -s option. | ||
579 | |||
580 | key: public_key | ||
581 | Revokes the specified key. If a certificate is listed, then it | ||
582 | is revoked as a plain public key. | ||
583 | |||
584 | sha1: public_key | ||
585 | Revokes the specified key by including its SHA1 hash in the KRL. | ||
586 | |||
587 | sha256: public_key | ||
588 | Revokes the specified key by including its SHA256 hash in the | ||
589 | KRL. KRLs that revoke keys by SHA256 hash are not supported by | ||
590 | OpenSSH versions prior to 7.9. | ||
591 | |||
592 | hash: fingerprint | ||
593 | Revokes a key using a fingerprint hash, as obtained from a | ||
594 | sshd(8) authentication log message or the ssh-keygen -l flag. | ||
595 | Only SHA256 fingerprints are supported here and resultant KRLs | ||
596 | are not supported by OpenSSH versions prior to 7.9. | ||
597 | |||
598 | KRLs may be updated using the -u flag in addition to -k. When this | ||
599 | option is specified, keys listed via the command line are merged into the | ||
600 | KRL, adding to those already there. | ||
601 | |||
602 | It is also possible, given a KRL, to test whether it revokes a particular | ||
603 | key (or keys). The -Q flag will query an existing KRL, testing each key | ||
604 | specified on the command line. If any key listed on the command line has | ||
605 | been revoked (or an error encountered) then ssh-keygen will exit with a | ||
606 | non-zero exit status. A zero exit status will only be returned if no key | ||
607 | was revoked. | ||
608 | |||
609 | ALLOWED SIGNERS | ||
610 | When verifying signatures, ssh-keygen uses a simple list of identities | ||
611 | and keys to determine whether a signature comes from an authorized | ||
612 | source. This "allowed signers" file uses a format patterned after the | ||
613 | AUTHORIZED_KEYS FILE FORMAT described in sshd(8). Each line of the file | ||
614 | contains the following space-separated fields: principals, options, | ||
615 | keytype, base64-encoded key. Empty lines and lines starting with a M-bM-^@M-^X#M-bM-^@M-^Y | ||
616 | are ignored as comments. | ||
617 | |||
618 | The principals field is a pattern-list (See PATTERNS in ssh_config(5)) | ||
619 | consisting of one or more comma-separated USER@DOMAIN identity patterns | ||
620 | that are accepted for signing. When verifying, the identity presented | ||
621 | via the -I -option must match a principals pattern in order for the | ||
622 | corresponding key to be considered acceptable for verification. | ||
623 | |||
624 | The options (if present) consist of comma-separated option | ||
625 | specifications. No spaces are permitted, except within double quotes. | ||
626 | The following option specifications are supported (note that option | ||
627 | keywords are case-insensitive): | ||
628 | |||
629 | cert-authority | ||
630 | Indicates that this key is accepted as a certificate authority | ||
631 | (CA) and that certificates signed by this CA may be accepted for | ||
632 | verification. | ||
633 | |||
634 | namespaces="namespace-list" | ||
635 | Specifies a pattern-list of namespaces that are accepted for this | ||
636 | key. If this option is present, the signature namespace embedded | ||
637 | in the signature object and presented on the verification | ||
638 | command-line must match the specified list before the key will be | ||
639 | considered acceptable. | ||
640 | |||
641 | When verifying signatures made by certificates, the expected principal | ||
642 | name must match both the principals pattern in the allowed signers file | ||
643 | and the principals embedded in the certificate itself. | ||
644 | |||
645 | An example allowed signers file: | ||
646 | |||
647 | # Comments allowed at start of line | ||
648 | user1@example.com,user2@example.com ssh-rsa AAAAX1... | ||
649 | # A certificate authority, trusted for all principals in a domain. | ||
650 | *@example.com cert-authority ssh-ed25519 AAAB4... | ||
651 | # A key that is accepted only for file signing. | ||
652 | user2@example.com namespaces="file" ssh-ed25519 AAA41... | ||
653 | |||
654 | FILES | ||
655 | ~/.ssh/id_dsa | ||
656 | ~/.ssh/id_ecdsa | ||
657 | ~/.ssh/id_ed25519 | ||
658 | ~/.ssh/id_rsa | ||
659 | Contains the DSA, ECDSA, Ed25519 or RSA authentication identity | ||
660 | of the user. This file should not be readable by anyone but the | ||
661 | user. It is possible to specify a passphrase when generating the | ||
662 | key; that passphrase will be used to encrypt the private part of | ||
663 | this file using 128-bit AES. This file is not automatically | ||
664 | accessed by ssh-keygen but it is offered as the default file for | ||
665 | the private key. ssh(1) will read this file when a login attempt | ||
666 | is made. | ||
667 | |||
668 | ~/.ssh/id_dsa.pub | ||
669 | ~/.ssh/id_ecdsa.pub | ||
670 | ~/.ssh/id_ed25519.pub | ||
671 | ~/.ssh/id_rsa.pub | ||
672 | Contains the DSA, ECDSA, Ed25519 or RSA public key for | ||
673 | authentication. The contents of this file should be added to | ||
674 | ~/.ssh/authorized_keys on all machines where the user wishes to | ||
675 | log in using public key authentication. There is no need to keep | ||
676 | the contents of this file secret. | ||
677 | |||
678 | /etc/moduli | ||
679 | Contains Diffie-Hellman groups used for DH-GEX. The file format | ||
680 | is described in moduli(5). | ||
681 | |||
682 | SEE ALSO | ||
683 | ssh(1), ssh-add(1), ssh-agent(1), moduli(5), sshd(8) | ||
684 | |||
685 | The Secure Shell (SSH) Public Key File Format, RFC 4716, 2006. | ||
686 | |||
687 | AUTHORS | ||
688 | OpenSSH is a derivative of the original and free ssh 1.2.12 release by | ||
689 | Tatu Ylonen. Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos, Theo | ||
690 | de Raadt and Dug Song removed many bugs, re-added newer features and | ||
691 | created OpenSSH. Markus Friedl contributed the support for SSH protocol | ||
692 | versions 1.5 and 2.0. | ||
693 | |||
694 | OpenBSD 6.6 October 3, 2019 OpenBSD 6.6 | ||