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