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