Annotation of src/usr.bin/ssh/ssh-keygen.1, Revision 1.177
1.177 ! djm 1: .\" $OpenBSD: ssh-keygen.1,v 1.176 2019/11/18 23:16:49 naddy 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.176 naddy 38: .Dd $Mdocdate: November 18 2019 $
1.2 deraadt 39: .Dt SSH-KEYGEN 1
40: .Os
41: .Sh NAME
42: .Nm ssh-keygen
1.37 markus 43: .Nd authentication key generation, management and conversion
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).
! 540: This option only makes sense for the Security Key algorithms
! 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
676: Specifies a path to a security key provider library that will be used when
1.174 djm 677: creating any security key-hosted keys, overriding the default of the
678: internal support for USB HID keys.
1.173 naddy 679: .It Fl x Ar flags
680: Specifies the security key flags to use when enrolling a security key-hosted
681: key.
1.66 jmc 682: .It Fl y
683: This option will read a private
684: OpenSSH format file and print an OpenSSH public key to stdout.
1.166 jmc 685: .It Fl Y Cm sign
1.163 djm 686: Cryptographically sign a file or some data using a SSH key.
687: When signing,
688: .Nm
689: accepts zero or more files to sign on the command-line - if no files
690: are specified then
691: .Nm
692: will sign data presented on standard input.
693: Signatures are written to the path of the input file with
694: .Dq .sig
695: appended, or to standard output if the message to be signed was read from
696: standard input.
697: .Pp
698: The key used for signing is specified using the
699: .Fl f
700: option and may refer to either a private key, or a public key with the private
701: half available via
702: .Xr ssh-agent 1 .
703: An additional signature namespace, used to prevent signature confusion across
704: different domains of use (e.g. file signing vs email signing) must be provided
705: via the
706: .Fl n
707: flag.
708: Namespaces are arbitrary strings, and may include:
709: .Dq file
710: for file signing,
711: .Dq email
712: for email signing.
713: For custom uses, it is recommended to use names following a
714: NAMESPACE@YOUR.DOMAIN pattern to generate unambiguous namespaces.
1.166 jmc 715: .It Fl Y Cm verify
1.163 djm 716: Request to verify a signature generated using
717: .Nm
1.166 jmc 718: .Fl Y Cm sign
1.163 djm 719: as described above.
720: When verifying a signature,
721: .Nm
722: accepts a message on standard input and a signature namespace using
723: .Fl n .
724: A file containing the corresponding signature must also be supplied using the
725: .Fl s
726: flag, along with the identity of the signer using
727: .Fl I
728: and a list of allowed signers via the
729: .Fl f
730: flag.
731: The format of the allowed signers file is documented in the
732: .Sx ALLOWED SIGNERS
733: section below.
734: A file containing revoked keys can be passed using the
735: .Fl r
1.165 jmc 736: flag.
737: The revocation file may be a KRL or a one-per-line list of public keys.
1.163 djm 738: Successful verification by an authorized signer is signalled by
1.167 djm 739: .Nm
1.172 jmc 740: returning a zero exit status.
1.167 djm 741: .It Fl Y Cm check-novalidate
742: Checks that a signature generated using
743: .Nm
744: .Fl Y Cm sign
745: has a valid structure.
746: This does not validate if a signature comes from an authorized signer.
747: When testing a signature,
748: .Nm
749: accepts a message on standard input and a signature namespace using
750: .Fl n .
751: A file containing the corresponding signature must also be supplied using the
752: .Fl s
1.168 jmc 753: flag.
754: Successful testing of the signature is signalled by
1.163 djm 755: .Nm
756: returning a zero exit status.
1.93 djm 757: .It Fl z Ar serial_number
758: Specifies a serial number to be embedded in the certificate to distinguish
759: this certificate from others from the same CA.
1.156 djm 760: If the
761: .Ar serial_number
762: is prefixed with a
763: .Sq +
764: character, then the serial number will be incremented for each certificate
765: signed on a single command-line.
1.93 djm 766: The default serial number is zero.
1.111 djm 767: .Pp
768: When generating a KRL, the
769: .Fl z
770: flag is used to specify a KRL version number.
1.2 deraadt 771: .El
1.60 djm 772: .Sh MODULI GENERATION
773: .Nm
774: may be used to generate groups for the Diffie-Hellman Group Exchange
775: (DH-GEX) protocol.
776: Generating these groups is a two-step process: first, candidate
777: primes are generated using a fast, but memory intensive process.
778: These candidate primes are then tested for suitability (a CPU-intensive
779: process).
780: .Pp
781: Generation of primes is performed using the
782: .Fl G
783: option.
784: The desired length of the primes may be specified by the
785: .Fl b
786: option.
787: For example:
788: .Pp
1.66 jmc 789: .Dl # ssh-keygen -G moduli-2048.candidates -b 2048
1.60 djm 790: .Pp
791: By default, the search for primes begins at a random point in the
792: desired length range.
793: This may be overridden using the
794: .Fl S
795: option, which specifies a different start point (in hex).
796: .Pp
1.109 dtucker 797: Once a set of candidates have been generated, they must be screened for
1.60 djm 798: suitability.
799: This may be performed using the
800: .Fl T
801: option.
802: In this mode
803: .Nm
804: will read candidates from standard input (or a file specified using the
805: .Fl f
806: option).
807: For example:
808: .Pp
1.66 jmc 809: .Dl # ssh-keygen -T moduli-2048 -f moduli-2048.candidates
1.60 djm 810: .Pp
811: By default, each candidate will be subjected to 100 primality tests.
812: This may be overridden using the
813: .Fl a
814: option.
815: The DH generator value will be chosen automatically for the
816: prime under consideration.
817: If a specific generator is desired, it may be requested using the
818: .Fl W
819: option.
1.66 jmc 820: Valid generator values are 2, 3, and 5.
1.60 djm 821: .Pp
822: Screened DH groups may be installed in
823: .Pa /etc/moduli .
824: It is important that this file contains moduli of a range of bit lengths and
825: that both ends of a connection share common moduli.
1.84 djm 826: .Sh CERTIFICATES
827: .Nm
828: supports signing of keys to produce certificates that may be used for
829: user or host authentication.
830: Certificates consist of a public key, some identity information, zero or
1.94 jmc 831: more principal (user or host) names and a set of options that
1.84 djm 832: are signed by a Certification Authority (CA) key.
833: Clients or servers may then trust only the CA key and verify its signature
834: on a certificate rather than trusting many user/host keys.
835: Note that OpenSSH certificates are a different, and much simpler, format to
836: the X.509 certificates used in
837: .Xr ssl 8 .
838: .Pp
839: .Nm
840: supports two types of certificates: user and host.
841: User certificates authenticate users to servers, whereas host certificates
1.85 jmc 842: authenticate server hosts to users.
843: To generate a user certificate:
1.84 djm 844: .Pp
845: .Dl $ ssh-keygen -s /path/to/ca_key -I key_id /path/to/user_key.pub
846: .Pp
847: The resultant certificate will be placed in
1.91 djm 848: .Pa /path/to/user_key-cert.pub .
1.84 djm 849: A host certificate requires the
850: .Fl h
851: option:
852: .Pp
853: .Dl $ ssh-keygen -s /path/to/ca_key -I key_id -h /path/to/host_key.pub
854: .Pp
855: The host certificate will be output to
1.91 djm 856: .Pa /path/to/host_key-cert.pub .
1.98 djm 857: .Pp
858: It is possible to sign using a CA key stored in a PKCS#11 token by
859: providing the token library using
860: .Fl D
861: and identifying the CA key by providing its public half as an argument
862: to
863: .Fl s :
864: .Pp
1.127 naddy 865: .Dl $ ssh-keygen -s ca_key.pub -D libpkcs11.so -I key_id user_key.pub
1.142 djm 866: .Pp
867: Similarly, it is possible for the CA key to be hosted in a
868: .Xr ssh-agent 1 .
869: This is indicated by the
870: .Fl U
871: flag and, again, the CA key must be identified by its public half.
872: .Pp
873: .Dl $ ssh-keygen -Us ca_key.pub -I key_id user_key.pub
1.98 djm 874: .Pp
875: In all cases,
1.84 djm 876: .Ar key_id
877: is a "key identifier" that is logged by the server when the certificate
878: is used for authentication.
879: .Pp
880: Certificates may be limited to be valid for a set of principal (user/host)
881: names.
882: By default, generated certificates are valid for all users or hosts.
883: To generate a certificate for a specified set of principals:
884: .Pp
885: .Dl $ ssh-keygen -s ca_key -I key_id -n user1,user2 user_key.pub
1.127 naddy 886: .Dl "$ ssh-keygen -s ca_key -I key_id -h -n host.domain host_key.pub"
1.84 djm 887: .Pp
888: Additional limitations on the validity and use of user certificates may
1.94 jmc 889: be specified through certificate options.
1.93 djm 890: A certificate option may disable features of the SSH session, may be
1.84 djm 891: valid only when presented from particular source addresses or may
892: force the use of a specific command.
1.93 djm 893: For a list of valid certificate options, see the documentation for the
1.84 djm 894: .Fl O
895: option above.
896: .Pp
897: Finally, certificates may be defined with a validity lifetime.
898: The
899: .Fl V
900: option allows specification of certificate start and end times.
901: A certificate that is presented at a time outside this range will not be
902: considered valid.
1.110 jmc 903: By default, certificates are valid from
904: .Ux
905: Epoch to the distant future.
1.84 djm 906: .Pp
907: For certificates to be used for user or host authentication, the CA
908: public key must be trusted by
909: .Xr sshd 8
910: or
911: .Xr ssh 1 .
912: Please refer to those manual pages for details.
1.111 djm 913: .Sh KEY REVOCATION LISTS
914: .Nm
915: is able to manage OpenSSH format Key Revocation Lists (KRLs).
916: These binary files specify keys or certificates to be revoked using a
1.119 tedu 917: compact format, taking as little as one bit per certificate if they are being
1.111 djm 918: revoked by serial number.
919: .Pp
920: KRLs may be generated using the
921: .Fl k
922: flag.
1.114 jmc 923: This option reads one or more files from the command line and generates a new
1.111 djm 924: KRL.
925: The files may either contain a KRL specification (see below) or public keys,
926: listed one per line.
927: Plain public keys are revoked by listing their hash or contents in the KRL and
928: certificates revoked by serial number or key ID (if the serial is zero or
929: not available).
930: .Pp
931: Revoking keys using a KRL specification offers explicit control over the
932: types of record used to revoke keys and may be used to directly revoke
933: certificates by serial number or key ID without having the complete original
934: certificate on hand.
935: A KRL specification consists of lines containing one of the following directives
936: followed by a colon and some directive-specific information.
937: .Bl -tag -width Ds
1.115 jmc 938: .It Cm serial : Ar serial_number Ns Op - Ns Ar serial_number
1.111 djm 939: Revokes a certificate with the specified serial number.
1.112 jmc 940: Serial numbers are 64-bit values, not including zero and may be expressed
1.111 djm 941: in decimal, hex or octal.
942: If two serial numbers are specified separated by a hyphen, then the range
943: of serial numbers including and between each is revoked.
944: The CA key must have been specified on the
945: .Nm
1.114 jmc 946: command line using the
1.111 djm 947: .Fl s
948: option.
949: .It Cm id : Ar key_id
950: Revokes a certificate with the specified key ID string.
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 key : Ar public_key
957: Revokes the specified key.
1.112 jmc 958: If a certificate is listed, then it is revoked as a plain public key.
1.111 djm 959: .It Cm sha1 : Ar public_key
1.149 djm 960: Revokes the specified key by including its SHA1 hash in the KRL.
961: .It Cm sha256 : Ar public_key
962: Revokes the specified key by including its SHA256 hash in the KRL.
963: KRLs that revoke keys by SHA256 hash are not supported by OpenSSH versions
964: prior to 7.9.
965: .It Cm hash : Ar fingerprint
1.150 djm 966: Revokes a key using a fingerprint hash, as obtained from a
1.149 djm 967: .Xr sshd 8
968: authentication log message or the
969: .Nm
970: .Fl l
971: flag.
972: Only SHA256 fingerprints are supported here and resultant KRLs are
973: not supported by OpenSSH versions prior to 7.9.
1.111 djm 974: .El
975: .Pp
976: KRLs may be updated using the
977: .Fl u
978: flag in addition to
979: .Fl k .
1.114 jmc 980: When this option is specified, keys listed via the command line are merged into
1.111 djm 981: the KRL, adding to those already there.
982: .Pp
983: It is also possible, given a KRL, to test whether it revokes a particular key
984: (or keys).
985: The
986: .Fl Q
1.128 jmc 987: flag will query an existing KRL, testing each key specified on the command line.
1.114 jmc 988: If any key listed on the command line has been revoked (or an error encountered)
1.111 djm 989: then
990: .Nm
991: will exit with a non-zero exit status.
992: A zero exit status will only be returned if no key was revoked.
1.163 djm 993: .Sh ALLOWED SIGNERS
994: When verifying signatures,
995: .Nm
996: uses a simple list of identities and keys to determine whether a signature
997: comes from an authorized source.
998: This "allowed signers" file uses a format patterned after the
999: AUTHORIZED_KEYS FILE FORMAT described in
1.165 jmc 1000: .Xr sshd 8 .
1.163 djm 1001: Each line of the file contains the following space-separated fields:
1002: principals, options, keytype, base64-encoded key.
1003: Empty lines and lines starting with a
1004: .Ql #
1005: are ignored as comments.
1006: .Pp
1007: The principals field is a pattern-list (See PATTERNS in
1008: .Xr ssh_config 5 )
1009: consisting of one or more comma-separated USER@DOMAIN identity patterns
1010: that are accepted for signing.
1011: When verifying, the identity presented via the
1.172 jmc 1012: .Fl I
1013: option must match a principals pattern in order for the corresponding key to be
1.163 djm 1014: considered acceptable for verification.
1015: .Pp
1016: The options (if present) consist of comma-separated option specifications.
1017: No spaces are permitted, except within double quotes.
1018: The following option specifications are supported (note that option keywords
1019: are case-insensitive):
1020: .Bl -tag -width Ds
1021: .It Cm cert-authority
1022: Indicates that this key is accepted as a certificate authority (CA) and
1023: that certificates signed by this CA may be accepted for verification.
1024: .It Cm namespaces="namespace-list"
1025: Specifies a pattern-list of namespaces that are accepted for this key.
1.164 djm 1026: If this option is present, the signature namespace embedded in the
1.163 djm 1027: signature object and presented on the verification command-line must
1028: match the specified list before the key will be considered acceptable.
1029: .El
1030: .Pp
1031: When verifying signatures made by certificates, the expected principal
1032: name must match both the principals pattern in the allowed signers file and
1033: the principals embedded in the certificate itself.
1034: .Pp
1035: An example allowed signers file:
1036: .Bd -literal -offset 3n
1037: # Comments allowed at start of line
1038: user1@example.com,user2@example.com ssh-rsa AAAAX1...
1039: # A certificate authority, trusted for all principals in a domain.
1040: *@example.com cert-authority ssh-ed25519 AAAB4...
1041: # A key that is accepted only for file signing.
1042: user2@example.com namespaces="file" ssh-ed25519 AAA41...
1043: .Ed
1.173 naddy 1044: .Sh ENVIRONMENT
1045: .Bl -tag -width Ds
1046: .It Ev SSH_SK_PROVIDER
1047: Specifies the path to a security key provider library used to interact with
1048: hardware security keys.
1049: .El
1.2 deraadt 1050: .Sh FILES
1.100 naddy 1051: .Bl -tag -width Ds -compact
1.68 djm 1052: .It Pa ~/.ssh/id_dsa
1.100 naddy 1053: .It Pa ~/.ssh/id_ecdsa
1.173 naddy 1054: .It Pa ~/.ssh/id_ecdsa_sk
1.118 naddy 1055: .It Pa ~/.ssh/id_ed25519
1.176 naddy 1056: .It Pa ~/.ssh/id_ed25519_sk
1.100 naddy 1057: .It Pa ~/.ssh/id_rsa
1.176 naddy 1058: Contains the DSA, ECDSA, security key-hosted ECDSA, Ed25519,
1059: security key-hosted Ed25519 or RSA authentication identity of the user.
1.15 deraadt 1060: This file should not be readable by anyone but the user.
1061: It is possible to
1062: specify a passphrase when generating the key; that passphrase will be
1.80 dtucker 1063: used to encrypt the private part of this file using 128-bit AES.
1.15 deraadt 1064: This file is not automatically accessed by
1065: .Nm
1066: but it is offered as the default file for the private key.
1.46 markus 1067: .Xr ssh 1
1.15 deraadt 1068: will read this file when a login attempt is made.
1.100 naddy 1069: .Pp
1.68 djm 1070: .It Pa ~/.ssh/id_dsa.pub
1.100 naddy 1071: .It Pa ~/.ssh/id_ecdsa.pub
1.173 naddy 1072: .It Pa ~/.ssh/id_ecdsa_sk.pub
1.118 naddy 1073: .It Pa ~/.ssh/id_ed25519.pub
1.176 naddy 1074: .It Pa ~/.ssh/id_ed25519_sk.pub
1.68 djm 1075: .It Pa ~/.ssh/id_rsa.pub
1.176 naddy 1076: Contains the DSA, ECDSA, security key-hosted ECDSA, Ed25519,
1077: security key-hosted Ed25519 or RSA public key for authentication.
1.15 deraadt 1078: The contents of this file should be added to
1.68 djm 1079: .Pa ~/.ssh/authorized_keys
1.15 deraadt 1080: on all machines
1.49 deraadt 1081: where the user wishes to log in using public key authentication.
1.12 aaron 1082: There is no need to keep the contents of this file secret.
1.100 naddy 1083: .Pp
1.60 djm 1084: .It Pa /etc/moduli
1085: Contains Diffie-Hellman groups used for DH-GEX.
1086: The file format is described in
1087: .Xr moduli 5 .
1.19 aaron 1088: .El
1.2 deraadt 1089: .Sh SEE ALSO
1090: .Xr ssh 1 ,
1091: .Xr ssh-add 1 ,
1.8 ericj 1092: .Xr ssh-agent 1 ,
1.60 djm 1093: .Xr moduli 5 ,
1.30 itojun 1094: .Xr sshd 8
1.37 markus 1095: .Rs
1.73 markus 1096: .%R RFC 4716
1097: .%T "The Secure Shell (SSH) Public Key File Format"
1098: .%D 2006
1.37 markus 1099: .Re
1.59 jmc 1100: .Sh AUTHORS
1101: OpenSSH is a derivative of the original and free
1102: ssh 1.2.12 release by Tatu Ylonen.
1103: Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos,
1104: Theo de Raadt and Dug Song
1105: removed many bugs, re-added newer features and
1106: created OpenSSH.
1107: Markus Friedl contributed the support for SSH
1108: protocol versions 1.5 and 2.0.