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