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