Annotation of src/usr.bin/ssh/ssh-keygen.1, Revision 1.185
1.185 ! djm 1: .\" $OpenBSD: ssh-keygen.1,v 1.184 2019/12/30 03:30: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.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.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
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.185 ! djm 456: When generating a key that will be hosted on a FIDO authenticator, this
! 457: flag may be used to specify key-specific options.
! 458: Two FIDO authenticator options are supported at present:
! 459: .Pp
! 460: .Cm no-touch-required
! 461: indicates that the generated private key should not require touch
! 462: events (user presence) when making signatures.
! 463: Note that
! 464: .Xr sshd 8
! 465: will refuse such signatures by default, unless overridden via
! 466: an authorized_keys option.
! 467: .Pp
! 468: .Cm resident
! 469: indicates that the key should be stored on the FIDO authenticator itself.
! 470: Resident keys may be supported on FIDO2 tokens and typically require that
! 471: a PIN be set on the token prior to generation.
! 472: Resident keys may be loaded off the token using
! 473: .Xr ssh-add 1 .
! 474: .Pp
! 475: The
! 476: .Fl O
! 477: option may be specified multiple times.
1.66 jmc 478: .It Fl P Ar passphrase
479: Provides the (old) passphrase.
1.2 deraadt 480: .It Fl p
1.1 deraadt 481: Requests changing the passphrase of a private key file instead of
1.12 aaron 482: creating a new private key.
483: The program will prompt for the file
1.1 deraadt 484: containing the private key, for the old passphrase, and twice for the
485: new passphrase.
1.113 jmc 486: .It Fl Q
487: Test whether keys have been revoked in a KRL.
1.5 aaron 488: .It Fl q
489: Silence
490: .Nm ssh-keygen .
1.152 djm 491: .It Fl R Ar hostname | [hostname]:port
1.151 djm 492: Removes all keys belonging to the specified
1.64 djm 493: .Ar hostname
1.151 djm 494: (with optional port number)
1.65 jmc 495: from a
1.64 djm 496: .Pa known_hosts
497: file.
1.65 jmc 498: This option is useful to delete hashed hosts (see the
1.64 djm 499: .Fl H
500: option above).
1.66 jmc 501: .It Fl r Ar hostname
502: Print the SSHFP fingerprint resource record named
503: .Ar hostname
504: for the specified public key file.
1.84 djm 505: .It Fl s Ar ca_key
506: Certify (sign) a public key using the specified CA key.
507: Please see the
508: .Sx CERTIFICATES
509: section for details.
1.111 djm 510: .Pp
511: When generating a KRL,
512: .Fl s
1.112 jmc 513: specifies a path to a CA public key file used to revoke certificates directly
1.111 djm 514: by key ID or serial number.
515: See the
516: .Sx KEY REVOCATION LISTS
517: section for details.
1.175 djm 518: .It Fl t Cm dsa | ecdsa | ecdsa-sk | ed25519 | ed25519-sk | rsa
1.66 jmc 519: Specifies the type of key to create.
520: The possible values are
1.100 naddy 521: .Dq dsa ,
1.118 naddy 522: .Dq ecdsa ,
1.173 naddy 523: .Dq ecdsa-sk ,
1.118 naddy 524: .Dq ed25519 ,
1.175 djm 525: .Dq ed25519-sk ,
1.100 naddy 526: or
1.139 jmc 527: .Dq rsa .
1.159 djm 528: .Pp
529: This flag may also be used to specify the desired signature type when
1.160 jmc 530: signing certificates using an RSA CA key.
1.159 djm 531: The available RSA signature variants are
532: .Dq ssh-rsa
533: (SHA1 signatures, not recommended),
1.160 jmc 534: .Dq rsa-sha2-256 ,
535: and
1.159 djm 536: .Dq rsa-sha2-512
537: (the default).
1.142 djm 538: .It Fl U
539: When used in combination with
540: .Fl s ,
541: this option indicates that a CA key resides in a
542: .Xr ssh-agent 1 .
543: See the
544: .Sx CERTIFICATES
545: section for more information.
1.112 jmc 546: .It Fl u
547: Update a KRL.
548: When specified with
549: .Fl k ,
1.114 jmc 550: keys listed via the command line are added to the existing KRL rather than
1.112 jmc 551: a new KRL being created.
1.84 djm 552: .It Fl V Ar validity_interval
553: Specify a validity interval when signing a certificate.
554: A validity interval may consist of a single time, indicating that the
555: certificate is valid beginning now and expiring at that time, or may consist
556: of two times separated by a colon to indicate an explicit time interval.
1.145 djm 557: .Pp
558: The start time may be specified as the string
559: .Dq always
560: to indicate the certificate has no specified start time,
1.147 djm 561: a date in YYYYMMDD format, a time in YYYYMMDDHHMM[SS] format,
1.145 djm 562: a relative time (to the current time) consisting of a minus sign followed by
563: an interval in the format described in the
1.116 jmc 564: TIME FORMATS section of
1.90 jmc 565: .Xr sshd_config 5 .
1.145 djm 566: .Pp
1.147 djm 567: The end time may be specified as a YYYYMMDD date, a YYYYMMDDHHMM[SS] time,
1.145 djm 568: a relative time starting with a plus character or the string
569: .Dq forever
570: to indicate that the certificate has no expirty date.
1.84 djm 571: .Pp
572: For example:
573: .Dq +52w1d
574: (valid from now to 52 weeks and one day from now),
575: .Dq -4w:+4w
576: (valid from four weeks ago to four weeks from now),
577: .Dq 20100101123000:20110101123000
578: (valid from 12:30 PM, January 1st, 2010 to 12:30 PM, January 1st, 2011),
579: .Dq -1d:20110101
580: (valid from yesterday to midnight, January 1st, 2011).
1.145 djm 581: .Dq -1m:forever
582: (valid from one minute ago and never expiring).
1.61 djm 583: .It Fl v
584: Verbose mode.
585: Causes
586: .Nm
587: to print debugging messages about its progress.
588: This is helpful for debugging moduli generation.
589: Multiple
590: .Fl v
591: options increase the verbosity.
592: The maximum is 3.
1.173 naddy 593: .It Fl w Ar provider
1.180 naddy 594: Specifies a path to a library that will be used when creating
595: FIDO authenticator-hosted keys, overriding the default of using
596: the internal USB HID support.
1.182 jmc 597: .It Fl Y Cm check-novalidate
598: Checks that a signature generated using
599: .Nm
600: .Fl Y Cm sign
601: has a valid structure.
602: This does not validate if a signature comes from an authorized signer.
603: When testing a signature,
604: .Nm
605: accepts a message on standard input and a signature namespace using
606: .Fl n .
607: A file containing the corresponding signature must also be supplied using the
608: .Fl s
609: flag.
610: Successful testing of the signature is signalled by
611: .Nm
612: returning a zero exit status.
1.166 jmc 613: .It Fl Y Cm sign
1.163 djm 614: Cryptographically sign a file or some data using a SSH key.
615: When signing,
616: .Nm
617: accepts zero or more files to sign on the command-line - if no files
618: are specified then
619: .Nm
620: will sign data presented on standard input.
621: Signatures are written to the path of the input file with
622: .Dq .sig
623: appended, or to standard output if the message to be signed was read from
624: standard input.
625: .Pp
626: The key used for signing is specified using the
627: .Fl f
628: option and may refer to either a private key, or a public key with the private
629: half available via
630: .Xr ssh-agent 1 .
631: An additional signature namespace, used to prevent signature confusion across
632: different domains of use (e.g. file signing vs email signing) must be provided
633: via the
634: .Fl n
635: flag.
636: Namespaces are arbitrary strings, and may include:
637: .Dq file
638: for file signing,
639: .Dq email
640: for email signing.
641: For custom uses, it is recommended to use names following a
642: NAMESPACE@YOUR.DOMAIN pattern to generate unambiguous namespaces.
1.166 jmc 643: .It Fl Y Cm verify
1.163 djm 644: Request to verify a signature generated using
645: .Nm
1.166 jmc 646: .Fl Y Cm sign
1.163 djm 647: as described above.
648: When verifying a signature,
649: .Nm
650: accepts a message on standard input and a signature namespace using
651: .Fl n .
652: A file containing the corresponding signature must also be supplied using the
653: .Fl s
654: flag, along with the identity of the signer using
655: .Fl I
656: and a list of allowed signers via the
657: .Fl f
658: flag.
659: The format of the allowed signers file is documented in the
660: .Sx ALLOWED SIGNERS
661: section below.
662: A file containing revoked keys can be passed using the
663: .Fl r
1.165 jmc 664: flag.
665: The revocation file may be a KRL or a one-per-line list of public keys.
1.163 djm 666: Successful verification by an authorized signer is signalled by
667: .Nm
668: returning a zero exit status.
1.181 jmc 669: .It Fl y
670: This option will read a private
671: OpenSSH format file and print an OpenSSH public key to stdout.
1.93 djm 672: .It Fl z Ar serial_number
673: Specifies a serial number to be embedded in the certificate to distinguish
674: this certificate from others from the same CA.
1.156 djm 675: If the
676: .Ar serial_number
677: is prefixed with a
678: .Sq +
679: character, then the serial number will be incremented for each certificate
680: signed on a single command-line.
1.93 djm 681: The default serial number is zero.
1.111 djm 682: .Pp
683: When generating a KRL, the
684: .Fl z
685: flag is used to specify a KRL version number.
1.2 deraadt 686: .El
1.60 djm 687: .Sh MODULI GENERATION
688: .Nm
689: may be used to generate groups for the Diffie-Hellman Group Exchange
690: (DH-GEX) protocol.
691: Generating these groups is a two-step process: first, candidate
692: primes are generated using a fast, but memory intensive process.
693: These candidate primes are then tested for suitability (a CPU-intensive
694: process).
695: .Pp
696: Generation of primes is performed using the
1.184 djm 697: .Fl M Cm generate
1.60 djm 698: option.
699: The desired length of the primes may be specified by the
1.184 djm 700: .Fl O Cm bits
1.60 djm 701: option.
702: For example:
703: .Pp
1.184 djm 704: .Dl # ssh-keygen -M generate -O bits=2048 moduli-2048.candidates
1.60 djm 705: .Pp
706: By default, the search for primes begins at a random point in the
707: desired length range.
708: This may be overridden using the
1.184 djm 709: .Fl O Cm start
1.60 djm 710: option, which specifies a different start point (in hex).
711: .Pp
1.109 dtucker 712: Once a set of candidates have been generated, they must be screened for
1.60 djm 713: suitability.
714: This may be performed using the
1.184 djm 715: .Fl M Cm screen
1.60 djm 716: option.
717: In this mode
718: .Nm
719: will read candidates from standard input (or a file specified using the
720: .Fl f
721: option).
722: For example:
723: .Pp
1.184 djm 724: .Dl # ssh-keygen -M screen -f moduli-2048.candidates moduli-2048
1.60 djm 725: .Pp
726: By default, each candidate will be subjected to 100 primality tests.
727: This may be overridden using the
1.184 djm 728: .Fl O Cm prime-tests
1.60 djm 729: option.
730: The DH generator value will be chosen automatically for the
731: prime under consideration.
732: If a specific generator is desired, it may be requested using the
1.184 djm 733: .Fl O Cm generator
1.60 djm 734: option.
1.66 jmc 735: Valid generator values are 2, 3, and 5.
1.60 djm 736: .Pp
737: Screened DH groups may be installed in
738: .Pa /etc/moduli .
739: It is important that this file contains moduli of a range of bit lengths and
740: that both ends of a connection share common moduli.
1.184 djm 741: .Pp
742: A number of options are available for moduli generation and screening via the
743: .Fl O
744: flag:
745: .Bl -tag -width Ds -compact
746: .Pp
747: .It Ic lines Ns = Ns Ar number
748: Exit after screening the specified number of lines while performing DH
749: candidate screening.
750: .Pp
751: .It Ic start-line Ns = Ns Ar line-number
752: Start screening at the specified line number while performing DH candidate
753: screening.
754: .Pp
755: .It Ic checkpoint Ns = Ns Ar filename
756: Write the last line processed to the specified file while performing DH
757: candidate screening.
758: This will be used to skip lines in the input file that have already been
759: processed if the job is restarted.
760: .Pp
761: .It Ic memory Ns = Ns Ar mbytes
762: Specify the amount of memory to use (in megabytes) when generating
763: candidate moduli for DH-GEX.
764: .Pp
765: .It Ic start Ns = Ns Ar hex-value
766: Specify start point (in hex) when generating candidate moduli for DH-GEX.
767: .Pp
768: .It Ic generator Ns = Ns Ar value
769: Specify desired generator (in decimal) when testing candidate moduli for DH-GEX.
770: .El
1.84 djm 771: .Sh CERTIFICATES
772: .Nm
773: supports signing of keys to produce certificates that may be used for
774: user or host authentication.
775: Certificates consist of a public key, some identity information, zero or
1.94 jmc 776: more principal (user or host) names and a set of options that
1.84 djm 777: are signed by a Certification Authority (CA) key.
778: Clients or servers may then trust only the CA key and verify its signature
779: on a certificate rather than trusting many user/host keys.
780: Note that OpenSSH certificates are a different, and much simpler, format to
781: the X.509 certificates used in
782: .Xr ssl 8 .
783: .Pp
784: .Nm
785: supports two types of certificates: user and host.
786: User certificates authenticate users to servers, whereas host certificates
1.85 jmc 787: authenticate server hosts to users.
788: To generate a user certificate:
1.84 djm 789: .Pp
790: .Dl $ ssh-keygen -s /path/to/ca_key -I key_id /path/to/user_key.pub
791: .Pp
792: The resultant certificate will be placed in
1.91 djm 793: .Pa /path/to/user_key-cert.pub .
1.84 djm 794: A host certificate requires the
795: .Fl h
796: option:
797: .Pp
798: .Dl $ ssh-keygen -s /path/to/ca_key -I key_id -h /path/to/host_key.pub
799: .Pp
800: The host certificate will be output to
1.91 djm 801: .Pa /path/to/host_key-cert.pub .
1.98 djm 802: .Pp
803: It is possible to sign using a CA key stored in a PKCS#11 token by
804: providing the token library using
805: .Fl D
806: and identifying the CA key by providing its public half as an argument
807: to
808: .Fl s :
809: .Pp
1.127 naddy 810: .Dl $ ssh-keygen -s ca_key.pub -D libpkcs11.so -I key_id user_key.pub
1.142 djm 811: .Pp
812: Similarly, it is possible for the CA key to be hosted in a
813: .Xr ssh-agent 1 .
814: This is indicated by the
815: .Fl U
816: flag and, again, the CA key must be identified by its public half.
817: .Pp
818: .Dl $ ssh-keygen -Us ca_key.pub -I key_id user_key.pub
1.98 djm 819: .Pp
820: In all cases,
1.84 djm 821: .Ar key_id
822: is a "key identifier" that is logged by the server when the certificate
823: is used for authentication.
824: .Pp
825: Certificates may be limited to be valid for a set of principal (user/host)
826: names.
827: By default, generated certificates are valid for all users or hosts.
828: To generate a certificate for a specified set of principals:
829: .Pp
830: .Dl $ ssh-keygen -s ca_key -I key_id -n user1,user2 user_key.pub
1.127 naddy 831: .Dl "$ ssh-keygen -s ca_key -I key_id -h -n host.domain host_key.pub"
1.84 djm 832: .Pp
833: Additional limitations on the validity and use of user certificates may
1.94 jmc 834: be specified through certificate options.
1.93 djm 835: A certificate option may disable features of the SSH session, may be
1.84 djm 836: valid only when presented from particular source addresses or may
837: force the use of a specific command.
1.183 djm 838: .Pp
839: The options that are valid for user certificates are:
840: .Pp
841: .Bl -tag -width Ds -compact
842: .It Ic clear
843: Clear all enabled permissions.
844: This is useful for clearing the default set of permissions so permissions may
845: be added individually.
846: .Pp
847: .It Ic critical : Ns Ar name Ns Op Ns = Ns Ar contents
848: .It Ic extension : Ns Ar name Ns Op Ns = Ns Ar contents
849: Includes an arbitrary certificate critical option or extension.
850: The specified
851: .Ar name
852: should include a domain suffix, e.g.\&
853: .Dq name@example.com .
854: If
855: .Ar contents
856: is specified then it is included as the contents of the extension/option
857: encoded as a string, otherwise the extension/option is created with no
858: contents (usually indicating a flag).
859: Extensions may be ignored by a client or server that does not recognise them,
860: whereas unknown critical options will cause the certificate to be refused.
861: .Pp
862: .It Ic force-command Ns = Ns Ar command
863: Forces the execution of
864: .Ar command
865: instead of any shell or command specified by the user when
866: the certificate is used for authentication.
867: .Pp
868: .It Ic no-agent-forwarding
869: Disable
870: .Xr ssh-agent 1
871: forwarding (permitted by default).
872: .Pp
873: .It Ic no-port-forwarding
874: Disable port forwarding (permitted by default).
875: .Pp
876: .It Ic no-pty
877: Disable PTY allocation (permitted by default).
878: .Pp
879: .It Ic no-user-rc
880: Disable execution of
881: .Pa ~/.ssh/rc
882: by
883: .Xr sshd 8
884: (permitted by default).
885: .Pp
886: .It Ic no-x11-forwarding
887: Disable X11 forwarding (permitted by default).
888: .Pp
889: .It Ic permit-agent-forwarding
890: Allows
891: .Xr ssh-agent 1
892: forwarding.
893: .Pp
894: .It Ic permit-port-forwarding
895: Allows port forwarding.
896: .Pp
897: .It Ic permit-pty
898: Allows PTY allocation.
899: .Pp
900: .It Ic permit-user-rc
901: Allows execution of
902: .Pa ~/.ssh/rc
903: by
904: .Xr sshd 8 .
905: .Pp
906: .It Ic permit-X11-forwarding
907: Allows X11 forwarding.
908: .Pp
909: .It Ic no-touch-required
910: Do not require signatures made using this key require demonstration
911: of user presence (e.g. by having the user touch the key).
912: This option only makes sense for the Security Key algorithms
913: .Cm ecdsa-sk
914: and
915: .Cm ed25519-sk .
916: .Pp
917: .It Ic source-address Ns = Ns Ar address_list
918: Restrict the source addresses from which the certificate is considered valid.
919: The
920: .Ar address_list
921: is a comma-separated list of one or more address/netmask pairs in CIDR
922: format.
923: .El
924: .Pp
925: At present, no standard options are valid for host keys.
1.84 djm 926: .Pp
927: Finally, certificates may be defined with a validity lifetime.
928: The
929: .Fl V
930: option allows specification of certificate start and end times.
931: A certificate that is presented at a time outside this range will not be
932: considered valid.
1.110 jmc 933: By default, certificates are valid from
934: .Ux
935: Epoch to the distant future.
1.84 djm 936: .Pp
937: For certificates to be used for user or host authentication, the CA
938: public key must be trusted by
939: .Xr sshd 8
940: or
941: .Xr ssh 1 .
942: Please refer to those manual pages for details.
1.111 djm 943: .Sh KEY REVOCATION LISTS
944: .Nm
945: is able to manage OpenSSH format Key Revocation Lists (KRLs).
946: These binary files specify keys or certificates to be revoked using a
1.119 tedu 947: compact format, taking as little as one bit per certificate if they are being
1.111 djm 948: revoked by serial number.
949: .Pp
950: KRLs may be generated using the
951: .Fl k
952: flag.
1.114 jmc 953: This option reads one or more files from the command line and generates a new
1.111 djm 954: KRL.
955: The files may either contain a KRL specification (see below) or public keys,
956: listed one per line.
957: Plain public keys are revoked by listing their hash or contents in the KRL and
958: certificates revoked by serial number or key ID (if the serial is zero or
959: not available).
960: .Pp
961: Revoking keys using a KRL specification offers explicit control over the
962: types of record used to revoke keys and may be used to directly revoke
963: certificates by serial number or key ID without having the complete original
964: certificate on hand.
965: A KRL specification consists of lines containing one of the following directives
966: followed by a colon and some directive-specific information.
967: .Bl -tag -width Ds
1.115 jmc 968: .It Cm serial : Ar serial_number Ns Op - Ns Ar serial_number
1.111 djm 969: Revokes a certificate with the specified serial number.
1.112 jmc 970: Serial numbers are 64-bit values, not including zero and may be expressed
1.111 djm 971: in decimal, hex or octal.
972: If two serial numbers are specified separated by a hyphen, then the range
973: of serial numbers including and between each is revoked.
974: The CA key must have been specified on the
975: .Nm
1.114 jmc 976: command line using the
1.111 djm 977: .Fl s
978: option.
979: .It Cm id : Ar key_id
980: Revokes a certificate with the specified key ID string.
981: The CA key must have been specified on the
982: .Nm
1.114 jmc 983: command line using the
1.111 djm 984: .Fl s
985: option.
986: .It Cm key : Ar public_key
987: Revokes the specified key.
1.112 jmc 988: If a certificate is listed, then it is revoked as a plain public key.
1.111 djm 989: .It Cm sha1 : Ar public_key
1.149 djm 990: Revokes the specified key by including its SHA1 hash in the KRL.
991: .It Cm sha256 : Ar public_key
992: Revokes the specified key by including its SHA256 hash in the KRL.
993: KRLs that revoke keys by SHA256 hash are not supported by OpenSSH versions
994: prior to 7.9.
995: .It Cm hash : Ar fingerprint
1.150 djm 996: Revokes a key using a fingerprint hash, as obtained from a
1.149 djm 997: .Xr sshd 8
998: authentication log message or the
999: .Nm
1000: .Fl l
1001: flag.
1002: Only SHA256 fingerprints are supported here and resultant KRLs are
1003: not supported by OpenSSH versions prior to 7.9.
1.111 djm 1004: .El
1005: .Pp
1006: KRLs may be updated using the
1007: .Fl u
1008: flag in addition to
1009: .Fl k .
1.114 jmc 1010: When this option is specified, keys listed via the command line are merged into
1.111 djm 1011: the KRL, adding to those already there.
1012: .Pp
1013: It is also possible, given a KRL, to test whether it revokes a particular key
1014: (or keys).
1015: The
1016: .Fl Q
1.128 jmc 1017: flag will query an existing KRL, testing each key specified on the command line.
1.114 jmc 1018: If any key listed on the command line has been revoked (or an error encountered)
1.111 djm 1019: then
1020: .Nm
1021: will exit with a non-zero exit status.
1022: A zero exit status will only be returned if no key was revoked.
1.163 djm 1023: .Sh ALLOWED SIGNERS
1024: When verifying signatures,
1025: .Nm
1026: uses a simple list of identities and keys to determine whether a signature
1027: comes from an authorized source.
1028: This "allowed signers" file uses a format patterned after the
1029: AUTHORIZED_KEYS FILE FORMAT described in
1.165 jmc 1030: .Xr sshd 8 .
1.163 djm 1031: Each line of the file contains the following space-separated fields:
1032: principals, options, keytype, base64-encoded key.
1033: Empty lines and lines starting with a
1034: .Ql #
1035: are ignored as comments.
1036: .Pp
1037: The principals field is a pattern-list (See PATTERNS in
1038: .Xr ssh_config 5 )
1039: consisting of one or more comma-separated USER@DOMAIN identity patterns
1040: that are accepted for signing.
1041: When verifying, the identity presented via the
1.172 jmc 1042: .Fl I
1043: option must match a principals pattern in order for the corresponding key to be
1.163 djm 1044: considered acceptable for verification.
1045: .Pp
1046: The options (if present) consist of comma-separated option specifications.
1047: No spaces are permitted, except within double quotes.
1048: The following option specifications are supported (note that option keywords
1049: are case-insensitive):
1050: .Bl -tag -width Ds
1051: .It Cm cert-authority
1052: Indicates that this key is accepted as a certificate authority (CA) and
1053: that certificates signed by this CA may be accepted for verification.
1054: .It Cm namespaces="namespace-list"
1055: Specifies a pattern-list of namespaces that are accepted for this key.
1.164 djm 1056: If this option is present, the signature namespace embedded in the
1.163 djm 1057: signature object and presented on the verification command-line must
1058: match the specified list before the key will be considered acceptable.
1059: .El
1060: .Pp
1061: When verifying signatures made by certificates, the expected principal
1062: name must match both the principals pattern in the allowed signers file and
1063: the principals embedded in the certificate itself.
1064: .Pp
1065: An example allowed signers file:
1066: .Bd -literal -offset 3n
1067: # Comments allowed at start of line
1068: user1@example.com,user2@example.com ssh-rsa AAAAX1...
1069: # A certificate authority, trusted for all principals in a domain.
1070: *@example.com cert-authority ssh-ed25519 AAAB4...
1071: # A key that is accepted only for file signing.
1072: user2@example.com namespaces="file" ssh-ed25519 AAA41...
1073: .Ed
1.173 naddy 1074: .Sh ENVIRONMENT
1075: .Bl -tag -width Ds
1076: .It Ev SSH_SK_PROVIDER
1.180 naddy 1077: Specifies the path to a library used to interact with FIDO authenticators.
1.173 naddy 1078: .El
1.2 deraadt 1079: .Sh FILES
1.100 naddy 1080: .Bl -tag -width Ds -compact
1.68 djm 1081: .It Pa ~/.ssh/id_dsa
1.100 naddy 1082: .It Pa ~/.ssh/id_ecdsa
1.173 naddy 1083: .It Pa ~/.ssh/id_ecdsa_sk
1.118 naddy 1084: .It Pa ~/.ssh/id_ed25519
1.176 naddy 1085: .It Pa ~/.ssh/id_ed25519_sk
1.100 naddy 1086: .It Pa ~/.ssh/id_rsa
1.180 naddy 1087: Contains the DSA, ECDSA, authenticator-hosted ECDSA, Ed25519,
1088: authenticator-hosted Ed25519 or RSA authentication identity of the user.
1.15 deraadt 1089: This file should not be readable by anyone but the user.
1090: It is possible to
1091: specify a passphrase when generating the key; that passphrase will be
1.80 dtucker 1092: used to encrypt the private part of this file using 128-bit AES.
1.15 deraadt 1093: This file is not automatically accessed by
1094: .Nm
1095: but it is offered as the default file for the private key.
1.46 markus 1096: .Xr ssh 1
1.15 deraadt 1097: will read this file when a login attempt is made.
1.100 naddy 1098: .Pp
1.68 djm 1099: .It Pa ~/.ssh/id_dsa.pub
1.100 naddy 1100: .It Pa ~/.ssh/id_ecdsa.pub
1.173 naddy 1101: .It Pa ~/.ssh/id_ecdsa_sk.pub
1.118 naddy 1102: .It Pa ~/.ssh/id_ed25519.pub
1.176 naddy 1103: .It Pa ~/.ssh/id_ed25519_sk.pub
1.68 djm 1104: .It Pa ~/.ssh/id_rsa.pub
1.180 naddy 1105: Contains the DSA, ECDSA, authenticator-hosted ECDSA, Ed25519,
1106: authenticator-hosted Ed25519 or RSA public key for authentication.
1.15 deraadt 1107: The contents of this file should be added to
1.68 djm 1108: .Pa ~/.ssh/authorized_keys
1.15 deraadt 1109: on all machines
1.49 deraadt 1110: where the user wishes to log in using public key authentication.
1.12 aaron 1111: There is no need to keep the contents of this file secret.
1.100 naddy 1112: .Pp
1.60 djm 1113: .It Pa /etc/moduli
1114: Contains Diffie-Hellman groups used for DH-GEX.
1115: The file format is described in
1116: .Xr moduli 5 .
1.19 aaron 1117: .El
1.2 deraadt 1118: .Sh SEE ALSO
1119: .Xr ssh 1 ,
1120: .Xr ssh-add 1 ,
1.8 ericj 1121: .Xr ssh-agent 1 ,
1.60 djm 1122: .Xr moduli 5 ,
1.30 itojun 1123: .Xr sshd 8
1.37 markus 1124: .Rs
1.73 markus 1125: .%R RFC 4716
1126: .%T "The Secure Shell (SSH) Public Key File Format"
1127: .%D 2006
1.37 markus 1128: .Re
1.59 jmc 1129: .Sh AUTHORS
1130: OpenSSH is a derivative of the original and free
1131: ssh 1.2.12 release by Tatu Ylonen.
1132: Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos,
1133: Theo de Raadt and Dug Song
1134: removed many bugs, re-added newer features and
1135: created OpenSSH.
1136: Markus Friedl contributed the support for SSH
1137: protocol versions 1.5 and 2.0.