Annotation of src/usr.bin/ssh/ssh-keygen.1, Revision 1.170
1.170 ! jmc 1: .\" $OpenBSD: ssh-keygen.1,v 1.169 2019/09/27 20:03:24 jmc Exp $
1.1 deraadt 2: .\"
3: .\" Author: Tatu Ylonen <ylo@cs.hut.fi>
4: .\" Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
5: .\" All rights reserved
6: .\"
1.22 deraadt 7: .\" As far as I am concerned, the code I have written for this software
8: .\" can be used freely for any purpose. Any derived versions of this
9: .\" software must be clearly marked as such, and if the derived work is
10: .\" incompatible with the protocol description in the RFC file, it must be
11: .\" called by a name other than "ssh" or "Secure Shell".
12: .\"
13: .\"
1.33 deraadt 14: .\" Copyright (c) 1999,2000 Markus Friedl. All rights reserved.
15: .\" Copyright (c) 1999 Aaron Campbell. All rights reserved.
16: .\" Copyright (c) 1999 Theo de Raadt. All rights reserved.
1.22 deraadt 17: .\"
18: .\" Redistribution and use in source and binary forms, with or without
19: .\" modification, are permitted provided that the following conditions
20: .\" are met:
21: .\" 1. Redistributions of source code must retain the above copyright
22: .\" notice, this list of conditions and the following disclaimer.
23: .\" 2. Redistributions in binary form must reproduce the above copyright
24: .\" notice, this list of conditions and the following disclaimer in the
25: .\" documentation and/or other materials provided with the distribution.
1.1 deraadt 26: .\"
1.22 deraadt 27: .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
28: .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
29: .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
30: .\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
31: .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
32: .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33: .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34: .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35: .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
36: .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1.1 deraadt 37: .\"
1.170 ! jmc 38: .Dd $Mdocdate: September 27 2019 $
1.2 deraadt 39: .Dt SSH-KEYGEN 1
40: .Os
41: .Sh NAME
42: .Nm ssh-keygen
1.37 markus 43: .Nd authentication key generation, management and conversion
1.2 deraadt 44: .Sh SYNOPSIS
1.97 schwarze 45: .Bk -words
1.2 deraadt 46: .Nm ssh-keygen
1.25 markus 47: .Op Fl q
1.2 deraadt 48: .Op Fl b Ar bits
1.139 jmc 49: .Op Fl t Cm dsa | ecdsa | ed25519 | rsa
1.2 deraadt 50: .Op Fl N Ar new_passphrase
51: .Op Fl C Ar comment
1.20 markus 52: .Op Fl f Ar output_keyfile
1.155 djm 53: .Op Fl m Ar format
1.2 deraadt 54: .Nm ssh-keygen
55: .Fl p
56: .Op Fl P Ar old_passphrase
57: .Op Fl N Ar new_passphrase
1.9 markus 58: .Op Fl f Ar keyfile
1.155 djm 59: .Op Fl m Ar format
1.2 deraadt 60: .Nm ssh-keygen
1.37 markus 61: .Fl i
1.95 djm 62: .Op Fl m Ar key_format
1.20 markus 63: .Op Fl f Ar input_keyfile
1.16 deraadt 64: .Nm ssh-keygen
1.37 markus 65: .Fl e
1.95 djm 66: .Op Fl m Ar key_format
1.20 markus 67: .Op Fl f Ar input_keyfile
1.16 deraadt 68: .Nm ssh-keygen
1.17 markus 69: .Fl y
1.20 markus 70: .Op Fl f Ar input_keyfile
1.17 markus 71: .Nm ssh-keygen
1.2 deraadt 72: .Fl c
73: .Op Fl P Ar passphrase
74: .Op Fl C Ar comment
1.9 markus 75: .Op Fl f Ar keyfile
76: .Nm ssh-keygen
77: .Fl l
1.125 naddy 78: .Op Fl v
1.124 djm 79: .Op Fl E Ar fingerprint_hash
1.35 markus 80: .Op Fl f Ar input_keyfile
81: .Nm ssh-keygen
82: .Fl B
1.20 markus 83: .Op Fl f Ar input_keyfile
1.48 jakob 84: .Nm ssh-keygen
1.82 jmc 85: .Fl D Ar pkcs11
1.48 jakob 86: .Nm ssh-keygen
1.64 djm 87: .Fl F Ar hostname
1.170 ! jmc 88: .Op Fl lv
1.64 djm 89: .Op Fl f Ar known_hosts_file
90: .Nm ssh-keygen
91: .Fl H
92: .Op Fl f Ar known_hosts_file
93: .Nm ssh-keygen
94: .Fl R Ar hostname
95: .Op Fl f Ar known_hosts_file
1.57 jakob 96: .Nm ssh-keygen
97: .Fl r Ar hostname
1.170 ! jmc 98: .Op Fl g
1.57 jakob 99: .Op Fl f Ar input_keyfile
1.60 djm 100: .Nm ssh-keygen
101: .Fl G Ar output_file
1.61 djm 102: .Op Fl v
1.60 djm 103: .Op Fl b Ar bits
104: .Op Fl M Ar memory
105: .Op Fl S Ar start_point
106: .Nm ssh-keygen
107: .Fl T Ar output_file
108: .Fl f Ar input_file
1.61 djm 109: .Op Fl v
1.117 djm 110: .Op Fl a Ar rounds
1.109 dtucker 111: .Op Fl J Ar num_lines
112: .Op Fl j Ar start_line
1.108 dtucker 113: .Op Fl K Ar checkpt
1.60 djm 114: .Op Fl W Ar generator
1.84 djm 115: .Nm ssh-keygen
116: .Fl s Ar ca_key
117: .Fl I Ar certificate_identity
1.170 ! jmc 118: .Op Fl hU
1.142 djm 119: .Op Fl D Ar pkcs11_provider
1.84 djm 120: .Op Fl n Ar principals
1.93 djm 121: .Op Fl O Ar option
1.84 djm 122: .Op Fl V Ar validity_interval
1.93 djm 123: .Op Fl z Ar serial_number
1.84 djm 124: .Ar
1.86 djm 125: .Nm ssh-keygen
126: .Fl L
127: .Op Fl f Ar input_keyfile
1.102 stevesk 128: .Nm ssh-keygen
129: .Fl A
1.143 djm 130: .Op Fl f Ar prefix_path
1.111 djm 131: .Nm ssh-keygen
132: .Fl k
133: .Fl f Ar krl_file
134: .Op Fl u
1.112 jmc 135: .Op Fl s Ar ca_public
136: .Op Fl z Ar version_number
1.111 djm 137: .Ar
138: .Nm ssh-keygen
139: .Fl Q
140: .Fl f Ar krl_file
141: .Ar
1.163 djm 142: .Nm ssh-keygen
143: .Fl Y Cm sign
144: .Fl f Ar key_file
145: .Fl n Ar namespace
146: .Ar
147: .Nm ssh-keygen
148: .Fl Y Cm verify
149: .Fl I Ar signer_identity
1.167 djm 150: .Fl f Ar allowed_signers_file
1.163 djm 151: .Fl n Ar namespace
152: .Fl s Ar signature_file
153: .Op Fl r Ar revocation_file
1.167 djm 154: .Nm ssh-keygen
155: .Fl Y Cm check-novalidate
156: .Fl s Ar signature_file
157: .Fl n Ar namespace
1.85 jmc 158: .Ek
1.13 aaron 159: .Sh DESCRIPTION
1.2 deraadt 160: .Nm
1.37 markus 161: generates, manages and converts authentication keys for
1.2 deraadt 162: .Xr ssh 1 .
1.15 deraadt 163: .Nm
1.140 jmc 164: can create keys for use by SSH protocol version 2.
1.130 jmc 165: .Pp
1.58 jmc 166: The type of key to be generated is specified with the
1.25 markus 167: .Fl t
1.52 djm 168: option.
1.70 djm 169: If invoked without any arguments,
170: .Nm
1.141 naddy 171: will generate an RSA key.
1.15 deraadt 172: .Pp
1.60 djm 173: .Nm
174: is also used to generate groups for use in Diffie-Hellman group
175: exchange (DH-GEX).
176: See the
177: .Sx MODULI GENERATION
178: section for details.
179: .Pp
1.111 djm 180: Finally,
181: .Nm
182: can be used to generate and update Key Revocation Lists, and to test whether
1.112 jmc 183: given keys have been revoked by one.
184: See the
1.111 djm 185: .Sx KEY REVOCATION LISTS
186: section for details.
187: .Pp
1.2 deraadt 188: Normally each user wishing to use SSH
1.99 djm 189: with public key authentication runs this once to create the authentication
1.1 deraadt 190: key in
1.118 naddy 191: .Pa ~/.ssh/id_dsa ,
1.99 djm 192: .Pa ~/.ssh/id_ecdsa ,
1.118 naddy 193: .Pa ~/.ssh/id_ed25519
1.15 deraadt 194: or
1.68 djm 195: .Pa ~/.ssh/id_rsa .
1.15 deraadt 196: Additionally, the system administrator may use this to generate host keys,
197: as seen in
198: .Pa /etc/rc .
1.2 deraadt 199: .Pp
1.1 deraadt 200: Normally this program generates the key and asks for a file in which
1.12 aaron 201: to store the private key.
202: The public key is stored in a file with the same name but
1.2 deraadt 203: .Dq .pub
1.12 aaron 204: appended.
205: The program also asks for a passphrase.
206: The passphrase may be empty to indicate no passphrase
1.26 markus 207: (host keys must have an empty passphrase), or it may be a string of
1.12 aaron 208: arbitrary length.
1.51 stevesk 209: A passphrase is similar to a password, except it can be a phrase with a
210: series of words, punctuation, numbers, whitespace, or any string of
211: characters you want.
212: Good passphrases are 10-30 characters long, are
1.1 deraadt 213: not simple sentences or otherwise easily guessable (English
1.42 markus 214: prose has only 1-2 bits of entropy per character, and provides very bad
1.51 stevesk 215: passphrases), and contain a mix of upper and lowercase letters,
216: numbers, and non-alphanumeric characters.
1.12 aaron 217: The passphrase can be changed later by using the
1.2 deraadt 218: .Fl p
1.1 deraadt 219: option.
1.2 deraadt 220: .Pp
1.12 aaron 221: There is no way to recover a lost passphrase.
1.105 djm 222: If the passphrase is lost or forgotten, a new key must be generated
223: and the corresponding public key copied to other machines.
1.2 deraadt 224: .Pp
1.153 djm 225: .Nm
226: will by default write keys in an OpenSSH-specific format.
227: This format is preferred as it offers better protection for
228: keys at rest as well as allowing storage of key comments within
229: the private key file itself.
230: The key comment may be useful to help identify the key.
1.12 aaron 231: The comment is initialized to
1.2 deraadt 232: .Dq user@host
233: when the key is created, but can be changed using the
234: .Fl c
1.1 deraadt 235: option.
1.153 djm 236: .Pp
237: It is still possible for
238: .Nm
239: to write the previously-used PEM format private keys using the
240: .Fl m
241: flag.
242: This may be used when generating new keys, and existing new-format
243: keys may be converted using this option in conjunction with the
244: .Fl p
245: (change passphrase) flag.
1.2 deraadt 246: .Pp
1.15 deraadt 247: After a key is generated, instructions below detail where the keys
248: should be placed to be activated.
249: .Pp
1.2 deraadt 250: The options are as follows:
251: .Bl -tag -width Ds
1.102 stevesk 252: .It Fl A
1.139 jmc 253: For each of the key types (rsa, dsa, ecdsa and ed25519)
1.118 naddy 254: for which host keys
1.102 stevesk 255: do not exist, generate the host keys with the default key file path,
256: an empty passphrase, default bits for the key type, and default comment.
1.144 jmc 257: If
1.143 djm 258: .Fl f
1.144 jmc 259: has also been specified, its argument is used as a prefix to the
1.143 djm 260: default path for the resulting host key files.
1.104 jmc 261: This is used by
1.102 stevesk 262: .Pa /etc/rc
263: to generate new host keys.
1.117 djm 264: .It Fl a Ar rounds
1.169 jmc 265: When saving a private key, this option specifies the number of KDF
1.148 djm 266: (key derivation function) rounds used.
1.117 djm 267: Higher numbers result in slower passphrase verification and increased
268: resistance to brute-force password cracking (should the keys be stolen).
269: .Pp
1.140 jmc 270: When screening DH-GEX candidates (using the
1.60 djm 271: .Fl T
1.169 jmc 272: command),
273: this option specifies the number of primality tests to perform.
1.66 jmc 274: .It Fl B
275: Show the bubblebabble digest of specified private or public key file.
1.2 deraadt 276: .It Fl b Ar bits
1.12 aaron 277: Specifies the number of bits in the key to create.
1.158 dtucker 278: For RSA keys, the minimum size is 1024 bits and the default is 3072 bits.
279: Generally, 3072 bits is considered sufficient.
1.72 dtucker 280: DSA keys must be exactly 1024 bits as specified by FIPS 186-2.
1.106 djm 281: For ECDSA keys, the
282: .Fl b
1.107 deraadt 283: flag determines the key length by selecting from one of three elliptic
1.106 djm 284: curve sizes: 256, 384 or 521 bits.
285: Attempting to use bit lengths other than these three values for ECDSA keys
286: will fail.
1.123 sobrado 287: Ed25519 keys have a fixed length and the
1.118 naddy 288: .Fl b
289: flag will be ignored.
1.66 jmc 290: .It Fl C Ar comment
291: Provides a new comment.
1.2 deraadt 292: .It Fl c
1.1 deraadt 293: Requests changing the comment in the private and public key files.
294: The program will prompt for the file containing the private keys, for
1.41 stevesk 295: the passphrase if the key has one, and for the new comment.
1.81 markus 296: .It Fl D Ar pkcs11
1.157 naddy 297: Download the public keys provided by the PKCS#11 shared library
1.83 markus 298: .Ar pkcs11 .
1.98 djm 299: When used in combination with
300: .Fl s ,
301: this option indicates that a CA key resides in a PKCS#11 token (see the
302: .Sx CERTIFICATES
303: section for details).
1.124 djm 304: .It Fl E Ar fingerprint_hash
305: Specifies the hash algorithm used when displaying key fingerprints.
306: Valid options are:
307: .Dq md5
308: and
309: .Dq sha256 .
310: The default is
311: .Dq sha256 .
1.37 markus 312: .It Fl e
1.40 markus 313: This option will read a private or public OpenSSH key file and
1.154 djm 314: print to stdout a public key in one of the formats specified by the
1.95 djm 315: .Fl m
316: option.
317: The default export format is
318: .Dq RFC4716 .
1.96 jmc 319: This option allows exporting OpenSSH keys for use by other programs, including
1.95 djm 320: several commercial SSH implementations.
1.151 djm 321: .It Fl F Ar hostname | [hostname]:port
1.66 jmc 322: Search for the specified
323: .Ar hostname
1.151 djm 324: (with optional port number)
1.66 jmc 325: in a
326: .Pa known_hosts
327: file, listing any occurrences found.
328: This option is useful to find hashed host names or addresses and may also be
329: used in conjunction with the
330: .Fl H
331: option to print found keys in a hashed format.
332: .It Fl f Ar filename
333: Specifies the filename of the key file.
334: .It Fl G Ar output_file
335: Generate candidate primes for DH-GEX.
336: These primes must be screened for
337: safety (using the
338: .Fl T
339: option) before use.
1.57 jakob 340: .It Fl g
1.62 jakob 341: Use generic DNS format when printing fingerprint resource records using the
1.63 jmc 342: .Fl r
1.62 jakob 343: command.
1.66 jmc 344: .It Fl H
345: Hash a
346: .Pa known_hosts
1.67 dtucker 347: file.
348: This replaces all hostnames and addresses with hashed representations
349: within the specified file; the original content is moved to a file with
350: a .old suffix.
1.66 jmc 351: These hashes may be used normally by
352: .Nm ssh
353: and
354: .Nm sshd ,
355: but they do not reveal identifying information should the file's contents
356: be disclosed.
357: This option will not modify existing hashed hostnames and is therefore safe
358: to use on files that mix hashed and non-hashed names.
1.84 djm 359: .It Fl h
360: When signing a key, create a host certificate instead of a user
361: certificate.
362: Please see the
363: .Sx CERTIFICATES
364: section for details.
1.85 jmc 365: .It Fl I Ar certificate_identity
1.84 djm 366: Specify the key identity when signing a public key.
367: Please see the
368: .Sx CERTIFICATES
369: section for details.
1.37 markus 370: .It Fl i
371: This option will read an unencrypted private (or public) key file
1.95 djm 372: in the format specified by the
373: .Fl m
374: option and print an OpenSSH compatible private
1.37 markus 375: (or public) key to stdout.
1.122 jmc 376: This option allows importing keys from other software, including several
377: commercial SSH implementations.
378: The default import format is
379: .Dq RFC4716 .
1.109 dtucker 380: .It Fl J Ar num_lines
381: Exit after screening the specified number of lines
382: while performing DH candidate screening using the
383: .Fl T
384: option.
385: .It Fl j Ar start_line
386: Start screening at the specified line number
387: while performing DH candidate screening using the
388: .Fl T
389: option.
1.108 dtucker 390: .It Fl K Ar checkpt
391: Write the last line processed to the file
392: .Ar checkpt
393: while performing DH candidate screening using the
394: .Fl T
395: option.
396: This will be used to skip lines in the input file that have already been
397: processed if the job is restarted.
1.111 djm 398: .It Fl k
399: Generate a KRL file.
400: In this mode,
401: .Nm
402: will generate a KRL file at the location specified via the
403: .Fl f
1.114 jmc 404: flag that revokes every key or certificate presented on the command line.
1.111 djm 405: Keys/certificates to be revoked may be specified by public key file or
406: using the format described in the
407: .Sx KEY REVOCATION LISTS
408: section.
1.86 djm 409: .It Fl L
1.129 djm 410: Prints the contents of one or more certificates.
1.9 markus 411: .It Fl l
1.77 grunk 412: Show fingerprint of specified public key file.
1.50 markus 413: For RSA and DSA keys
414: .Nm
1.78 jmc 415: tries to find the matching public key file and prints its fingerprint.
416: If combined with
417: .Fl v ,
1.132 jmc 418: a visual ASCII art representation of the key is supplied with the
1.131 djm 419: fingerprint.
1.96 jmc 420: .It Fl M Ar memory
421: Specify the amount of memory to use (in megabytes) when generating
422: candidate moduli for DH-GEX.
1.95 djm 423: .It Fl m Ar key_format
1.155 djm 424: Specify a key format for key generation, the
1.95 djm 425: .Fl i
1.155 djm 426: (import),
1.95 djm 427: .Fl e
1.155 djm 428: (export) conversion options, and the
429: .Fl p
430: change passphrase operation.
431: The latter may be used to convert between OpenSSH private key and PEM
432: private key formats.
1.95 djm 433: The supported key formats are:
434: .Dq RFC4716
1.96 jmc 435: (RFC 4716/SSH2 public or private key),
1.95 djm 436: .Dq PKCS8
1.161 djm 437: (PKCS8 public or private key)
1.95 djm 438: or
439: .Dq PEM
440: (PEM public key).
1.161 djm 441: By default OpenSSH will write newly-generated private keys in its own
442: format, but when converting public keys for export the default format is
1.95 djm 443: .Dq RFC4716 .
1.148 djm 444: Setting a format of
445: .Dq PEM
446: when generating or updating a supported private key type will cause the
447: key to be stored in the legacy PEM private key format.
1.66 jmc 448: .It Fl N Ar new_passphrase
449: Provides the new passphrase.
1.84 djm 450: .It Fl n Ar principals
451: Specify one or more principals (user or host names) to be included in
452: a certificate when signing a key.
453: Multiple principals may be specified, separated by commas.
454: Please see the
455: .Sx CERTIFICATES
456: section for details.
1.93 djm 457: .It Fl O Ar option
458: Specify a certificate option when signing a key.
1.84 djm 459: This option may be specified multiple times.
1.137 jmc 460: See also the
1.84 djm 461: .Sx CERTIFICATES
1.137 jmc 462: section for further details.
1.146 djm 463: .Pp
464: At present, no standard options are valid for host keys.
1.93 djm 465: The options that are valid for user certificates are:
1.137 jmc 466: .Pp
467: .Bl -tag -width Ds -compact
1.89 jmc 468: .It Ic clear
469: Clear all enabled permissions.
470: This is useful for clearing the default set of permissions so permissions may
471: be added individually.
1.137 jmc 472: .Pp
473: .It Ic critical : Ns Ar name Ns Op Ns = Ns Ar contents
474: .It Ic extension : Ns Ar name Ns Op Ns = Ns Ar contents
475: Includes an arbitrary certificate critical option or extension.
476: The specified
477: .Ar name
478: should include a domain suffix, e.g.\&
479: .Dq name@example.com .
480: If
481: .Ar contents
482: is specified then it is included as the contents of the extension/option
483: encoded as a string, otherwise the extension/option is created with no
484: contents (usually indicating a flag).
485: Extensions may be ignored by a client or server that does not recognise them,
486: whereas unknown critical options will cause the certificate to be refused.
1.138 jmc 487: .Pp
1.89 jmc 488: .It Ic force-command Ns = Ns Ar command
489: Forces the execution of
490: .Ar command
491: instead of any shell or command specified by the user when
492: the certificate is used for authentication.
1.137 jmc 493: .Pp
1.84 djm 494: .It Ic no-agent-forwarding
495: Disable
496: .Xr ssh-agent 1
1.85 jmc 497: forwarding (permitted by default).
1.137 jmc 498: .Pp
1.84 djm 499: .It Ic no-port-forwarding
1.85 jmc 500: Disable port forwarding (permitted by default).
1.137 jmc 501: .Pp
1.84 djm 502: .It Ic no-pty
1.85 jmc 503: Disable PTY allocation (permitted by default).
1.137 jmc 504: .Pp
1.84 djm 505: .It Ic no-user-rc
506: Disable execution of
507: .Pa ~/.ssh/rc
508: by
1.85 jmc 509: .Xr sshd 8
510: (permitted by default).
1.137 jmc 511: .Pp
1.89 jmc 512: .It Ic no-x11-forwarding
513: Disable X11 forwarding (permitted by default).
1.137 jmc 514: .Pp
1.88 djm 515: .It Ic permit-agent-forwarding
516: Allows
517: .Xr ssh-agent 1
518: forwarding.
1.137 jmc 519: .Pp
1.84 djm 520: .It Ic permit-port-forwarding
521: Allows port forwarding.
1.137 jmc 522: .Pp
1.84 djm 523: .It Ic permit-pty
524: Allows PTY allocation.
1.137 jmc 525: .Pp
1.84 djm 526: .It Ic permit-user-rc
527: Allows execution of
528: .Pa ~/.ssh/rc
529: by
530: .Xr sshd 8 .
1.137 jmc 531: .Pp
1.146 djm 532: .It Ic permit-X11-forwarding
1.89 jmc 533: Allows X11 forwarding.
1.137 jmc 534: .Pp
1.89 jmc 535: .It Ic source-address Ns = Ns Ar address_list
1.90 jmc 536: Restrict the source addresses from which the certificate is considered valid.
1.84 djm 537: The
538: .Ar address_list
539: is a comma-separated list of one or more address/netmask pairs in CIDR
540: format.
541: .El
1.66 jmc 542: .It Fl P Ar passphrase
543: Provides the (old) passphrase.
1.2 deraadt 544: .It Fl p
1.1 deraadt 545: Requests changing the passphrase of a private key file instead of
1.12 aaron 546: creating a new private key.
547: The program will prompt for the file
1.1 deraadt 548: containing the private key, for the old passphrase, and twice for the
549: new passphrase.
1.113 jmc 550: .It Fl Q
551: Test whether keys have been revoked in a KRL.
1.5 aaron 552: .It Fl q
553: Silence
554: .Nm ssh-keygen .
1.152 djm 555: .It Fl R Ar hostname | [hostname]:port
1.151 djm 556: Removes all keys belonging to the specified
1.64 djm 557: .Ar hostname
1.151 djm 558: (with optional port number)
1.65 jmc 559: from a
1.64 djm 560: .Pa known_hosts
561: file.
1.65 jmc 562: This option is useful to delete hashed hosts (see the
1.64 djm 563: .Fl H
564: option above).
1.66 jmc 565: .It Fl r Ar hostname
566: Print the SSHFP fingerprint resource record named
567: .Ar hostname
568: for the specified public key file.
1.60 djm 569: .It Fl S Ar start
570: Specify start point (in hex) when generating candidate moduli for DH-GEX.
1.84 djm 571: .It Fl s Ar ca_key
572: Certify (sign) a public key using the specified CA key.
573: Please see the
574: .Sx CERTIFICATES
575: section for details.
1.111 djm 576: .Pp
577: When generating a KRL,
578: .Fl s
1.112 jmc 579: specifies a path to a CA public key file used to revoke certificates directly
1.111 djm 580: by key ID or serial number.
581: See the
582: .Sx KEY REVOCATION LISTS
583: section for details.
1.60 djm 584: .It Fl T Ar output_file
585: Test DH group exchange candidate primes (generated using the
586: .Fl G
587: option) for safety.
1.139 jmc 588: .It Fl t Cm dsa | ecdsa | ed25519 | rsa
1.66 jmc 589: Specifies the type of key to create.
590: The possible values are
1.100 naddy 591: .Dq dsa ,
1.118 naddy 592: .Dq ecdsa ,
593: .Dq ed25519 ,
1.100 naddy 594: or
1.139 jmc 595: .Dq rsa .
1.159 djm 596: .Pp
597: This flag may also be used to specify the desired signature type when
1.160 jmc 598: signing certificates using an RSA CA key.
1.159 djm 599: The available RSA signature variants are
600: .Dq ssh-rsa
601: (SHA1 signatures, not recommended),
1.160 jmc 602: .Dq rsa-sha2-256 ,
603: and
1.159 djm 604: .Dq rsa-sha2-512
605: (the default).
1.142 djm 606: .It Fl U
607: When used in combination with
608: .Fl s ,
609: this option indicates that a CA key resides in a
610: .Xr ssh-agent 1 .
611: See the
612: .Sx CERTIFICATES
613: section for more information.
1.112 jmc 614: .It Fl u
615: Update a KRL.
616: When specified with
617: .Fl k ,
1.114 jmc 618: keys listed via the command line are added to the existing KRL rather than
1.112 jmc 619: a new KRL being created.
1.84 djm 620: .It Fl V Ar validity_interval
621: Specify a validity interval when signing a certificate.
622: A validity interval may consist of a single time, indicating that the
623: certificate is valid beginning now and expiring at that time, or may consist
624: of two times separated by a colon to indicate an explicit time interval.
1.145 djm 625: .Pp
626: The start time may be specified as the string
627: .Dq always
628: to indicate the certificate has no specified start time,
1.147 djm 629: a date in YYYYMMDD format, a time in YYYYMMDDHHMM[SS] format,
1.145 djm 630: a relative time (to the current time) consisting of a minus sign followed by
631: an interval in the format described in the
1.116 jmc 632: TIME FORMATS section of
1.90 jmc 633: .Xr sshd_config 5 .
1.145 djm 634: .Pp
1.147 djm 635: The end time may be specified as a YYYYMMDD date, a YYYYMMDDHHMM[SS] time,
1.145 djm 636: a relative time starting with a plus character or the string
637: .Dq forever
638: to indicate that the certificate has no expirty date.
1.84 djm 639: .Pp
640: For example:
641: .Dq +52w1d
642: (valid from now to 52 weeks and one day from now),
643: .Dq -4w:+4w
644: (valid from four weeks ago to four weeks from now),
645: .Dq 20100101123000:20110101123000
646: (valid from 12:30 PM, January 1st, 2010 to 12:30 PM, January 1st, 2011),
647: .Dq -1d:20110101
648: (valid from yesterday to midnight, January 1st, 2011).
1.145 djm 649: .Dq -1m:forever
650: (valid from one minute ago and never expiring).
1.61 djm 651: .It Fl v
652: Verbose mode.
653: Causes
654: .Nm
655: to print debugging messages about its progress.
656: This is helpful for debugging moduli generation.
657: Multiple
658: .Fl v
659: options increase the verbosity.
660: The maximum is 3.
1.66 jmc 661: .It Fl W Ar generator
662: Specify desired generator when testing candidate moduli for DH-GEX.
663: .It Fl y
664: This option will read a private
665: OpenSSH format file and print an OpenSSH public key to stdout.
1.166 jmc 666: .It Fl Y Cm sign
1.163 djm 667: Cryptographically sign a file or some data using a SSH key.
668: When signing,
669: .Nm
670: accepts zero or more files to sign on the command-line - if no files
671: are specified then
672: .Nm
673: will sign data presented on standard input.
674: Signatures are written to the path of the input file with
675: .Dq .sig
676: appended, or to standard output if the message to be signed was read from
677: standard input.
678: .Pp
679: The key used for signing is specified using the
680: .Fl f
681: option and may refer to either a private key, or a public key with the private
682: half available via
683: .Xr ssh-agent 1 .
684: An additional signature namespace, used to prevent signature confusion across
685: different domains of use (e.g. file signing vs email signing) must be provided
686: via the
687: .Fl n
688: flag.
689: Namespaces are arbitrary strings, and may include:
690: .Dq file
691: for file signing,
692: .Dq email
693: for email signing.
694: For custom uses, it is recommended to use names following a
695: NAMESPACE@YOUR.DOMAIN pattern to generate unambiguous namespaces.
1.166 jmc 696: .It Fl Y Cm verify
1.163 djm 697: Request to verify a signature generated using
698: .Nm
1.166 jmc 699: .Fl Y Cm sign
1.163 djm 700: as described above.
701: When verifying a signature,
702: .Nm
703: accepts a message on standard input and a signature namespace using
704: .Fl n .
705: A file containing the corresponding signature must also be supplied using the
706: .Fl s
707: flag, along with the identity of the signer using
708: .Fl I
709: and a list of allowed signers via the
710: .Fl f
711: flag.
712: The format of the allowed signers file is documented in the
713: .Sx ALLOWED SIGNERS
714: section below.
715: A file containing revoked keys can be passed using the
716: .Fl r
1.165 jmc 717: flag.
718: The revocation file may be a KRL or a one-per-line list of public keys.
1.163 djm 719: Successful verification by an authorized signer is signalled by
1.167 djm 720: .Nm
721: .It Fl Y Cm check-novalidate
722: Checks that a signature generated using
723: .Nm
724: .Fl Y Cm sign
725: has a valid structure.
726: This does not validate if a signature comes from an authorized signer.
727: When testing a signature,
728: .Nm
729: accepts a message on standard input and a signature namespace using
730: .Fl n .
731: A file containing the corresponding signature must also be supplied using the
732: .Fl s
1.168 jmc 733: flag.
734: Successful testing of the signature is signalled by
1.163 djm 735: .Nm
736: returning a zero exit status.
1.93 djm 737: .It Fl z Ar serial_number
738: Specifies a serial number to be embedded in the certificate to distinguish
739: this certificate from others from the same CA.
1.156 djm 740: If the
741: .Ar serial_number
742: is prefixed with a
743: .Sq +
744: character, then the serial number will be incremented for each certificate
745: signed on a single command-line.
1.93 djm 746: The default serial number is zero.
1.111 djm 747: .Pp
748: When generating a KRL, the
749: .Fl z
750: flag is used to specify a KRL version number.
1.2 deraadt 751: .El
1.60 djm 752: .Sh MODULI GENERATION
753: .Nm
754: may be used to generate groups for the Diffie-Hellman Group Exchange
755: (DH-GEX) protocol.
756: Generating these groups is a two-step process: first, candidate
757: primes are generated using a fast, but memory intensive process.
758: These candidate primes are then tested for suitability (a CPU-intensive
759: process).
760: .Pp
761: Generation of primes is performed using the
762: .Fl G
763: option.
764: The desired length of the primes may be specified by the
765: .Fl b
766: option.
767: For example:
768: .Pp
1.66 jmc 769: .Dl # ssh-keygen -G moduli-2048.candidates -b 2048
1.60 djm 770: .Pp
771: By default, the search for primes begins at a random point in the
772: desired length range.
773: This may be overridden using the
774: .Fl S
775: option, which specifies a different start point (in hex).
776: .Pp
1.109 dtucker 777: Once a set of candidates have been generated, they must be screened for
1.60 djm 778: suitability.
779: This may be performed using the
780: .Fl T
781: option.
782: In this mode
783: .Nm
784: will read candidates from standard input (or a file specified using the
785: .Fl f
786: option).
787: For example:
788: .Pp
1.66 jmc 789: .Dl # ssh-keygen -T moduli-2048 -f moduli-2048.candidates
1.60 djm 790: .Pp
791: By default, each candidate will be subjected to 100 primality tests.
792: This may be overridden using the
793: .Fl a
794: option.
795: The DH generator value will be chosen automatically for the
796: prime under consideration.
797: If a specific generator is desired, it may be requested using the
798: .Fl W
799: option.
1.66 jmc 800: Valid generator values are 2, 3, and 5.
1.60 djm 801: .Pp
802: Screened DH groups may be installed in
803: .Pa /etc/moduli .
804: It is important that this file contains moduli of a range of bit lengths and
805: that both ends of a connection share common moduli.
1.84 djm 806: .Sh CERTIFICATES
807: .Nm
808: supports signing of keys to produce certificates that may be used for
809: user or host authentication.
810: Certificates consist of a public key, some identity information, zero or
1.94 jmc 811: more principal (user or host) names and a set of options that
1.84 djm 812: are signed by a Certification Authority (CA) key.
813: Clients or servers may then trust only the CA key and verify its signature
814: on a certificate rather than trusting many user/host keys.
815: Note that OpenSSH certificates are a different, and much simpler, format to
816: the X.509 certificates used in
817: .Xr ssl 8 .
818: .Pp
819: .Nm
820: supports two types of certificates: user and host.
821: User certificates authenticate users to servers, whereas host certificates
1.85 jmc 822: authenticate server hosts to users.
823: To generate a user certificate:
1.84 djm 824: .Pp
825: .Dl $ ssh-keygen -s /path/to/ca_key -I key_id /path/to/user_key.pub
826: .Pp
827: The resultant certificate will be placed in
1.91 djm 828: .Pa /path/to/user_key-cert.pub .
1.84 djm 829: A host certificate requires the
830: .Fl h
831: option:
832: .Pp
833: .Dl $ ssh-keygen -s /path/to/ca_key -I key_id -h /path/to/host_key.pub
834: .Pp
835: The host certificate will be output to
1.91 djm 836: .Pa /path/to/host_key-cert.pub .
1.98 djm 837: .Pp
838: It is possible to sign using a CA key stored in a PKCS#11 token by
839: providing the token library using
840: .Fl D
841: and identifying the CA key by providing its public half as an argument
842: to
843: .Fl s :
844: .Pp
1.127 naddy 845: .Dl $ ssh-keygen -s ca_key.pub -D libpkcs11.so -I key_id user_key.pub
1.142 djm 846: .Pp
847: Similarly, it is possible for the CA key to be hosted in a
848: .Xr ssh-agent 1 .
849: This is indicated by the
850: .Fl U
851: flag and, again, the CA key must be identified by its public half.
852: .Pp
853: .Dl $ ssh-keygen -Us ca_key.pub -I key_id user_key.pub
1.98 djm 854: .Pp
855: In all cases,
1.84 djm 856: .Ar key_id
857: is a "key identifier" that is logged by the server when the certificate
858: is used for authentication.
859: .Pp
860: Certificates may be limited to be valid for a set of principal (user/host)
861: names.
862: By default, generated certificates are valid for all users or hosts.
863: To generate a certificate for a specified set of principals:
864: .Pp
865: .Dl $ ssh-keygen -s ca_key -I key_id -n user1,user2 user_key.pub
1.127 naddy 866: .Dl "$ ssh-keygen -s ca_key -I key_id -h -n host.domain host_key.pub"
1.84 djm 867: .Pp
868: Additional limitations on the validity and use of user certificates may
1.94 jmc 869: be specified through certificate options.
1.93 djm 870: A certificate option may disable features of the SSH session, may be
1.84 djm 871: valid only when presented from particular source addresses or may
872: force the use of a specific command.
1.93 djm 873: For a list of valid certificate options, see the documentation for the
1.84 djm 874: .Fl O
875: option above.
876: .Pp
877: Finally, certificates may be defined with a validity lifetime.
878: The
879: .Fl V
880: option allows specification of certificate start and end times.
881: A certificate that is presented at a time outside this range will not be
882: considered valid.
1.110 jmc 883: By default, certificates are valid from
884: .Ux
885: Epoch to the distant future.
1.84 djm 886: .Pp
887: For certificates to be used for user or host authentication, the CA
888: public key must be trusted by
889: .Xr sshd 8
890: or
891: .Xr ssh 1 .
892: Please refer to those manual pages for details.
1.111 djm 893: .Sh KEY REVOCATION LISTS
894: .Nm
895: is able to manage OpenSSH format Key Revocation Lists (KRLs).
896: These binary files specify keys or certificates to be revoked using a
1.119 tedu 897: compact format, taking as little as one bit per certificate if they are being
1.111 djm 898: revoked by serial number.
899: .Pp
900: KRLs may be generated using the
901: .Fl k
902: flag.
1.114 jmc 903: This option reads one or more files from the command line and generates a new
1.111 djm 904: KRL.
905: The files may either contain a KRL specification (see below) or public keys,
906: listed one per line.
907: Plain public keys are revoked by listing their hash or contents in the KRL and
908: certificates revoked by serial number or key ID (if the serial is zero or
909: not available).
910: .Pp
911: Revoking keys using a KRL specification offers explicit control over the
912: types of record used to revoke keys and may be used to directly revoke
913: certificates by serial number or key ID without having the complete original
914: certificate on hand.
915: A KRL specification consists of lines containing one of the following directives
916: followed by a colon and some directive-specific information.
917: .Bl -tag -width Ds
1.115 jmc 918: .It Cm serial : Ar serial_number Ns Op - Ns Ar serial_number
1.111 djm 919: Revokes a certificate with the specified serial number.
1.112 jmc 920: Serial numbers are 64-bit values, not including zero and may be expressed
1.111 djm 921: in decimal, hex or octal.
922: If two serial numbers are specified separated by a hyphen, then the range
923: of serial numbers including and between each is revoked.
924: The CA key must have been specified on the
925: .Nm
1.114 jmc 926: command line using the
1.111 djm 927: .Fl s
928: option.
929: .It Cm id : Ar key_id
930: Revokes a certificate with the specified key ID string.
931: The CA key must have been specified on the
932: .Nm
1.114 jmc 933: command line using the
1.111 djm 934: .Fl s
935: option.
936: .It Cm key : Ar public_key
937: Revokes the specified key.
1.112 jmc 938: If a certificate is listed, then it is revoked as a plain public key.
1.111 djm 939: .It Cm sha1 : Ar public_key
1.149 djm 940: Revokes the specified key by including its SHA1 hash in the KRL.
941: .It Cm sha256 : Ar public_key
942: Revokes the specified key by including its SHA256 hash in the KRL.
943: KRLs that revoke keys by SHA256 hash are not supported by OpenSSH versions
944: prior to 7.9.
945: .It Cm hash : Ar fingerprint
1.150 djm 946: Revokes a key using a fingerprint hash, as obtained from a
1.149 djm 947: .Xr sshd 8
948: authentication log message or the
949: .Nm
950: .Fl l
951: flag.
952: Only SHA256 fingerprints are supported here and resultant KRLs are
953: not supported by OpenSSH versions prior to 7.9.
1.111 djm 954: .El
955: .Pp
956: KRLs may be updated using the
957: .Fl u
958: flag in addition to
959: .Fl k .
1.114 jmc 960: When this option is specified, keys listed via the command line are merged into
1.111 djm 961: the KRL, adding to those already there.
962: .Pp
963: It is also possible, given a KRL, to test whether it revokes a particular key
964: (or keys).
965: The
966: .Fl Q
1.128 jmc 967: flag will query an existing KRL, testing each key specified on the command line.
1.114 jmc 968: If any key listed on the command line has been revoked (or an error encountered)
1.111 djm 969: then
970: .Nm
971: will exit with a non-zero exit status.
972: A zero exit status will only be returned if no key was revoked.
1.163 djm 973: .Sh ALLOWED SIGNERS
974: When verifying signatures,
975: .Nm
976: uses a simple list of identities and keys to determine whether a signature
977: comes from an authorized source.
978: This "allowed signers" file uses a format patterned after the
979: AUTHORIZED_KEYS FILE FORMAT described in
1.165 jmc 980: .Xr sshd 8 .
1.163 djm 981: Each line of the file contains the following space-separated fields:
982: principals, options, keytype, base64-encoded key.
983: Empty lines and lines starting with a
984: .Ql #
985: are ignored as comments.
986: .Pp
987: The principals field is a pattern-list (See PATTERNS in
988: .Xr ssh_config 5 )
989: consisting of one or more comma-separated USER@DOMAIN identity patterns
990: that are accepted for signing.
991: When verifying, the identity presented via the
992: .Fl I option
993: must match a principals pattern in order for the corresponding key to be
994: considered acceptable for verification.
995: .Pp
996: The options (if present) consist of comma-separated option specifications.
997: No spaces are permitted, except within double quotes.
998: The following option specifications are supported (note that option keywords
999: are case-insensitive):
1000: .Bl -tag -width Ds
1001: .It Cm cert-authority
1002: Indicates that this key is accepted as a certificate authority (CA) and
1003: that certificates signed by this CA may be accepted for verification.
1004: .It Cm namespaces="namespace-list"
1005: Specifies a pattern-list of namespaces that are accepted for this key.
1.164 djm 1006: If this option is present, the signature namespace embedded in the
1.163 djm 1007: signature object and presented on the verification command-line must
1008: match the specified list before the key will be considered acceptable.
1009: .El
1010: .Pp
1011: When verifying signatures made by certificates, the expected principal
1012: name must match both the principals pattern in the allowed signers file and
1013: the principals embedded in the certificate itself.
1014: .Pp
1015: An example allowed signers file:
1016: .Bd -literal -offset 3n
1017: # Comments allowed at start of line
1018: user1@example.com,user2@example.com ssh-rsa AAAAX1...
1019: # A certificate authority, trusted for all principals in a domain.
1020: *@example.com cert-authority ssh-ed25519 AAAB4...
1021: # A key that is accepted only for file signing.
1022: user2@example.com namespaces="file" ssh-ed25519 AAA41...
1023: .Ed
1.2 deraadt 1024: .Sh FILES
1.100 naddy 1025: .Bl -tag -width Ds -compact
1.68 djm 1026: .It Pa ~/.ssh/id_dsa
1.100 naddy 1027: .It Pa ~/.ssh/id_ecdsa
1.118 naddy 1028: .It Pa ~/.ssh/id_ed25519
1.100 naddy 1029: .It Pa ~/.ssh/id_rsa
1.141 naddy 1030: Contains the DSA, ECDSA, Ed25519 or RSA
1.118 naddy 1031: authentication identity of the user.
1.15 deraadt 1032: This file should not be readable by anyone but the user.
1033: It is possible to
1034: specify a passphrase when generating the key; that passphrase will be
1.80 dtucker 1035: used to encrypt the private part of this file using 128-bit AES.
1.15 deraadt 1036: This file is not automatically accessed by
1037: .Nm
1038: but it is offered as the default file for the private key.
1.46 markus 1039: .Xr ssh 1
1.15 deraadt 1040: will read this file when a login attempt is made.
1.100 naddy 1041: .Pp
1.68 djm 1042: .It Pa ~/.ssh/id_dsa.pub
1.100 naddy 1043: .It Pa ~/.ssh/id_ecdsa.pub
1.118 naddy 1044: .It Pa ~/.ssh/id_ed25519.pub
1.68 djm 1045: .It Pa ~/.ssh/id_rsa.pub
1.141 naddy 1046: Contains the DSA, ECDSA, Ed25519 or RSA
1.118 naddy 1047: public key for authentication.
1.15 deraadt 1048: The contents of this file should be added to
1.68 djm 1049: .Pa ~/.ssh/authorized_keys
1.15 deraadt 1050: on all machines
1.49 deraadt 1051: where the user wishes to log in using public key authentication.
1.12 aaron 1052: There is no need to keep the contents of this file secret.
1.100 naddy 1053: .Pp
1.60 djm 1054: .It Pa /etc/moduli
1055: Contains Diffie-Hellman groups used for DH-GEX.
1056: The file format is described in
1057: .Xr moduli 5 .
1.19 aaron 1058: .El
1.2 deraadt 1059: .Sh SEE ALSO
1060: .Xr ssh 1 ,
1061: .Xr ssh-add 1 ,
1.8 ericj 1062: .Xr ssh-agent 1 ,
1.60 djm 1063: .Xr moduli 5 ,
1.30 itojun 1064: .Xr sshd 8
1.37 markus 1065: .Rs
1.73 markus 1066: .%R RFC 4716
1067: .%T "The Secure Shell (SSH) Public Key File Format"
1068: .%D 2006
1.37 markus 1069: .Re
1.59 jmc 1070: .Sh AUTHORS
1071: OpenSSH is a derivative of the original and free
1072: ssh 1.2.12 release by Tatu Ylonen.
1073: Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos,
1074: Theo de Raadt and Dug Song
1075: removed many bugs, re-added newer features and
1076: created OpenSSH.
1077: Markus Friedl contributed the support for SSH
1078: protocol versions 1.5 and 2.0.