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