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