Annotation of src/usr.bin/ssh/ssh-keygen.1, Revision 1.169
1.169 ! jmc 1: .\" $OpenBSD: ssh-keygen.1,v 1.168 2019/09/20 18:50:58 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.169 ! jmc 38: .Dd $Mdocdate: September 20 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
1.97 schwarze 45: .Bk -words
1.2 deraadt 46: .Nm ssh-keygen
1.25 markus 47: .Op Fl q
1.2 deraadt 48: .Op Fl b Ar bits
1.139 jmc 49: .Op Fl t Cm dsa | ecdsa | ed25519 | rsa
1.2 deraadt 50: .Op Fl N Ar new_passphrase
51: .Op Fl C Ar comment
1.20 markus 52: .Op Fl f Ar output_keyfile
1.155 djm 53: .Op Fl m Ar format
1.2 deraadt 54: .Nm ssh-keygen
55: .Fl p
56: .Op Fl P Ar old_passphrase
57: .Op Fl N Ar new_passphrase
1.9 markus 58: .Op Fl f Ar keyfile
1.155 djm 59: .Op Fl m Ar format
1.2 deraadt 60: .Nm ssh-keygen
1.37 markus 61: .Fl i
1.95 djm 62: .Op Fl m Ar key_format
1.20 markus 63: .Op Fl f Ar input_keyfile
1.16 deraadt 64: .Nm ssh-keygen
1.37 markus 65: .Fl e
1.95 djm 66: .Op Fl m Ar key_format
1.20 markus 67: .Op Fl f Ar input_keyfile
1.16 deraadt 68: .Nm ssh-keygen
1.17 markus 69: .Fl y
1.20 markus 70: .Op Fl f Ar input_keyfile
1.17 markus 71: .Nm ssh-keygen
1.2 deraadt 72: .Fl c
73: .Op Fl P Ar passphrase
74: .Op Fl C Ar comment
1.9 markus 75: .Op Fl f Ar keyfile
76: .Nm ssh-keygen
77: .Fl l
1.125 naddy 78: .Op Fl v
1.124 djm 79: .Op Fl E Ar fingerprint_hash
1.35 markus 80: .Op Fl f Ar input_keyfile
81: .Nm ssh-keygen
82: .Fl B
1.20 markus 83: .Op Fl f Ar input_keyfile
1.48 jakob 84: .Nm ssh-keygen
1.82 jmc 85: .Fl D Ar pkcs11
1.48 jakob 86: .Nm ssh-keygen
1.64 djm 87: .Fl F Ar hostname
88: .Op Fl f Ar known_hosts_file
1.79 sthen 89: .Op Fl l
1.162 djm 90: .Op Fl v
1.64 djm 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
99: .Op Fl f Ar input_keyfile
100: .Op Fl g
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
108: .Fl T Ar output_file
109: .Fl f Ar input_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
117: .Fl s Ar ca_key
118: .Fl I Ar certificate_identity
119: .Op Fl h
1.142 djm 120: .Op Fl U
121: .Op Fl D Ar pkcs11_provider
1.84 djm 122: .Op Fl n Ar principals
1.93 djm 123: .Op Fl O Ar option
1.84 djm 124: .Op Fl V Ar validity_interval
1.93 djm 125: .Op Fl z Ar serial_number
1.84 djm 126: .Ar
1.86 djm 127: .Nm ssh-keygen
128: .Fl L
129: .Op Fl f Ar input_keyfile
1.102 stevesk 130: .Nm ssh-keygen
131: .Fl A
1.143 djm 132: .Op Fl f Ar prefix_path
1.111 djm 133: .Nm ssh-keygen
134: .Fl k
135: .Fl f Ar krl_file
136: .Op Fl u
1.112 jmc 137: .Op Fl s Ar ca_public
138: .Op Fl z Ar version_number
1.111 djm 139: .Ar
140: .Nm ssh-keygen
141: .Fl Q
142: .Fl f Ar krl_file
143: .Ar
1.163 djm 144: .Nm ssh-keygen
145: .Fl Y Cm sign
146: .Fl f Ar key_file
147: .Fl n Ar namespace
148: .Ar
149: .Nm ssh-keygen
150: .Fl Y Cm verify
151: .Fl I Ar signer_identity
1.167 djm 152: .Fl f Ar allowed_signers_file
1.163 djm 153: .Fl n Ar namespace
154: .Fl s Ar signature_file
155: .Op Fl r Ar revocation_file
1.167 djm 156: .Nm ssh-keygen
157: .Fl Y Cm check-novalidate
158: .Fl s Ar signature_file
159: .Fl n Ar namespace
1.85 jmc 160: .Ek
1.13 aaron 161: .Sh DESCRIPTION
1.2 deraadt 162: .Nm
1.37 markus 163: generates, manages and converts authentication keys for
1.2 deraadt 164: .Xr ssh 1 .
1.15 deraadt 165: .Nm
1.140 jmc 166: can create keys for use by SSH protocol version 2.
1.130 jmc 167: .Pp
1.58 jmc 168: The type of key to be generated is specified with the
1.25 markus 169: .Fl t
1.52 djm 170: option.
1.70 djm 171: If invoked without any arguments,
172: .Nm
1.141 naddy 173: will generate an RSA key.
1.15 deraadt 174: .Pp
1.60 djm 175: .Nm
176: is also used to generate groups for use in Diffie-Hellman group
177: exchange (DH-GEX).
178: See the
179: .Sx MODULI GENERATION
180: section for details.
181: .Pp
1.111 djm 182: Finally,
183: .Nm
184: can be used to generate and update Key Revocation Lists, and to test whether
1.112 jmc 185: given keys have been revoked by one.
186: See the
1.111 djm 187: .Sx KEY REVOCATION LISTS
188: section for details.
189: .Pp
1.2 deraadt 190: Normally each user wishing to use SSH
1.99 djm 191: with public key authentication runs this once to create the authentication
1.1 deraadt 192: key in
1.118 naddy 193: .Pa ~/.ssh/id_dsa ,
1.99 djm 194: .Pa ~/.ssh/id_ecdsa ,
1.118 naddy 195: .Pa ~/.ssh/id_ed25519
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.139 jmc 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.123 sobrado 289: Ed25519 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.137 jmc 536: .Pp
1.89 jmc 537: .It Ic source-address Ns = Ns Ar address_list
1.90 jmc 538: Restrict the source addresses from which the certificate is considered valid.
1.84 djm 539: The
540: .Ar address_list
541: is a comma-separated list of one or more address/netmask pairs in CIDR
542: format.
543: .El
1.66 jmc 544: .It Fl P Ar passphrase
545: Provides the (old) passphrase.
1.2 deraadt 546: .It Fl p
1.1 deraadt 547: Requests changing the passphrase of a private key file instead of
1.12 aaron 548: creating a new private key.
549: The program will prompt for the file
1.1 deraadt 550: containing the private key, for the old passphrase, and twice for the
551: new passphrase.
1.113 jmc 552: .It Fl Q
553: Test whether keys have been revoked in a KRL.
1.5 aaron 554: .It Fl q
555: Silence
556: .Nm ssh-keygen .
1.152 djm 557: .It Fl R Ar hostname | [hostname]:port
1.151 djm 558: Removes all keys belonging to the specified
1.64 djm 559: .Ar hostname
1.151 djm 560: (with optional port number)
1.65 jmc 561: from a
1.64 djm 562: .Pa known_hosts
563: file.
1.65 jmc 564: This option is useful to delete hashed hosts (see the
1.64 djm 565: .Fl H
566: option above).
1.66 jmc 567: .It Fl r Ar hostname
568: Print the SSHFP fingerprint resource record named
569: .Ar hostname
570: for the specified public key file.
1.60 djm 571: .It Fl S Ar start
572: Specify start point (in hex) when generating candidate moduli for DH-GEX.
1.84 djm 573: .It Fl s Ar ca_key
574: Certify (sign) a public key using the specified CA key.
575: Please see the
576: .Sx CERTIFICATES
577: section for details.
1.111 djm 578: .Pp
579: When generating a KRL,
580: .Fl s
1.112 jmc 581: specifies a path to a CA public key file used to revoke certificates directly
1.111 djm 582: by key ID or serial number.
583: See the
584: .Sx KEY REVOCATION LISTS
585: section for details.
1.60 djm 586: .It Fl T Ar output_file
587: Test DH group exchange candidate primes (generated using the
588: .Fl G
589: option) for safety.
1.139 jmc 590: .It Fl t Cm dsa | ecdsa | ed25519 | rsa
1.66 jmc 591: Specifies the type of key to create.
592: The possible values are
1.100 naddy 593: .Dq dsa ,
1.118 naddy 594: .Dq ecdsa ,
595: .Dq ed25519 ,
1.100 naddy 596: or
1.139 jmc 597: .Dq rsa .
1.159 djm 598: .Pp
599: This flag may also be used to specify the desired signature type when
1.160 jmc 600: signing certificates using an RSA CA key.
1.159 djm 601: The available RSA signature variants are
602: .Dq ssh-rsa
603: (SHA1 signatures, not recommended),
1.160 jmc 604: .Dq rsa-sha2-256 ,
605: and
1.159 djm 606: .Dq rsa-sha2-512
607: (the default).
1.142 djm 608: .It Fl U
609: When used in combination with
610: .Fl s ,
611: this option indicates that a CA key resides in a
612: .Xr ssh-agent 1 .
613: See the
614: .Sx CERTIFICATES
615: section for more information.
1.112 jmc 616: .It Fl u
617: Update a KRL.
618: When specified with
619: .Fl k ,
1.114 jmc 620: keys listed via the command line are added to the existing KRL rather than
1.112 jmc 621: a new KRL being created.
1.84 djm 622: .It Fl V Ar validity_interval
623: Specify a validity interval when signing a certificate.
624: A validity interval may consist of a single time, indicating that the
625: certificate is valid beginning now and expiring at that time, or may consist
626: of two times separated by a colon to indicate an explicit time interval.
1.145 djm 627: .Pp
628: The start time may be specified as the string
629: .Dq always
630: to indicate the certificate has no specified start time,
1.147 djm 631: a date in YYYYMMDD format, a time in YYYYMMDDHHMM[SS] format,
1.145 djm 632: a relative time (to the current time) consisting of a minus sign followed by
633: an interval in the format described in the
1.116 jmc 634: TIME FORMATS section of
1.90 jmc 635: .Xr sshd_config 5 .
1.145 djm 636: .Pp
1.147 djm 637: The end time may be specified as a YYYYMMDD date, a YYYYMMDDHHMM[SS] time,
1.145 djm 638: a relative time starting with a plus character or the string
639: .Dq forever
640: to indicate that the certificate has no expirty date.
1.84 djm 641: .Pp
642: For example:
643: .Dq +52w1d
644: (valid from now to 52 weeks and one day from now),
645: .Dq -4w:+4w
646: (valid from four weeks ago to four weeks from now),
647: .Dq 20100101123000:20110101123000
648: (valid from 12:30 PM, January 1st, 2010 to 12:30 PM, January 1st, 2011),
649: .Dq -1d:20110101
650: (valid from yesterday to midnight, January 1st, 2011).
1.145 djm 651: .Dq -1m:forever
652: (valid from one minute ago and never expiring).
1.61 djm 653: .It Fl v
654: Verbose mode.
655: Causes
656: .Nm
657: to print debugging messages about its progress.
658: This is helpful for debugging moduli generation.
659: Multiple
660: .Fl v
661: options increase the verbosity.
662: The maximum is 3.
1.66 jmc 663: .It Fl W Ar generator
664: Specify desired generator when testing candidate moduli for DH-GEX.
665: .It Fl y
666: This option will read a private
667: OpenSSH format file and print an OpenSSH public key to stdout.
1.166 jmc 668: .It Fl Y Cm sign
1.163 djm 669: Cryptographically sign a file or some data using a SSH key.
670: When signing,
671: .Nm
672: accepts zero or more files to sign on the command-line - if no files
673: are specified then
674: .Nm
675: will sign data presented on standard input.
676: Signatures are written to the path of the input file with
677: .Dq .sig
678: appended, or to standard output if the message to be signed was read from
679: standard input.
680: .Pp
681: The key used for signing is specified using the
682: .Fl f
683: option and may refer to either a private key, or a public key with the private
684: half available via
685: .Xr ssh-agent 1 .
686: An additional signature namespace, used to prevent signature confusion across
687: different domains of use (e.g. file signing vs email signing) must be provided
688: via the
689: .Fl n
690: flag.
691: Namespaces are arbitrary strings, and may include:
692: .Dq file
693: for file signing,
694: .Dq email
695: for email signing.
696: For custom uses, it is recommended to use names following a
697: NAMESPACE@YOUR.DOMAIN pattern to generate unambiguous namespaces.
1.166 jmc 698: .It Fl Y Cm verify
1.163 djm 699: Request to verify a signature generated using
700: .Nm
1.166 jmc 701: .Fl Y Cm sign
1.163 djm 702: as described above.
703: When verifying a signature,
704: .Nm
705: accepts a message on standard input and a signature namespace using
706: .Fl n .
707: A file containing the corresponding signature must also be supplied using the
708: .Fl s
709: flag, along with the identity of the signer using
710: .Fl I
711: and a list of allowed signers via the
712: .Fl f
713: flag.
714: The format of the allowed signers file is documented in the
715: .Sx ALLOWED SIGNERS
716: section below.
717: A file containing revoked keys can be passed using the
718: .Fl r
1.165 jmc 719: flag.
720: The revocation file may be a KRL or a one-per-line list of public keys.
1.163 djm 721: Successful verification by an authorized signer is signalled by
1.167 djm 722: .Nm
723: .It Fl Y Cm check-novalidate
724: Checks that a signature generated using
725: .Nm
726: .Fl Y Cm sign
727: has a valid structure.
728: This does not validate if a signature comes from an authorized signer.
729: When testing a signature,
730: .Nm
731: accepts a message on standard input and a signature namespace using
732: .Fl n .
733: A file containing the corresponding signature must also be supplied using the
734: .Fl s
1.168 jmc 735: flag.
736: Successful testing of the signature is signalled by
1.163 djm 737: .Nm
738: returning a zero exit status.
1.93 djm 739: .It Fl z Ar serial_number
740: Specifies a serial number to be embedded in the certificate to distinguish
741: this certificate from others from the same CA.
1.156 djm 742: If the
743: .Ar serial_number
744: is prefixed with a
745: .Sq +
746: character, then the serial number will be incremented for each certificate
747: signed on a single command-line.
1.93 djm 748: The default serial number is zero.
1.111 djm 749: .Pp
750: When generating a KRL, the
751: .Fl z
752: flag is used to specify a KRL version number.
1.2 deraadt 753: .El
1.60 djm 754: .Sh MODULI GENERATION
755: .Nm
756: may be used to generate groups for the Diffie-Hellman Group Exchange
757: (DH-GEX) protocol.
758: Generating these groups is a two-step process: first, candidate
759: primes are generated using a fast, but memory intensive process.
760: These candidate primes are then tested for suitability (a CPU-intensive
761: process).
762: .Pp
763: Generation of primes is performed using the
764: .Fl G
765: option.
766: The desired length of the primes may be specified by the
767: .Fl b
768: option.
769: For example:
770: .Pp
1.66 jmc 771: .Dl # ssh-keygen -G moduli-2048.candidates -b 2048
1.60 djm 772: .Pp
773: By default, the search for primes begins at a random point in the
774: desired length range.
775: This may be overridden using the
776: .Fl S
777: option, which specifies a different start point (in hex).
778: .Pp
1.109 dtucker 779: Once a set of candidates have been generated, they must be screened for
1.60 djm 780: suitability.
781: This may be performed using the
782: .Fl T
783: option.
784: In this mode
785: .Nm
786: will read candidates from standard input (or a file specified using the
787: .Fl f
788: option).
789: For example:
790: .Pp
1.66 jmc 791: .Dl # ssh-keygen -T moduli-2048 -f moduli-2048.candidates
1.60 djm 792: .Pp
793: By default, each candidate will be subjected to 100 primality tests.
794: This may be overridden using the
795: .Fl a
796: option.
797: The DH generator value will be chosen automatically for the
798: prime under consideration.
799: If a specific generator is desired, it may be requested using the
800: .Fl W
801: option.
1.66 jmc 802: Valid generator values are 2, 3, and 5.
1.60 djm 803: .Pp
804: Screened DH groups may be installed in
805: .Pa /etc/moduli .
806: It is important that this file contains moduli of a range of bit lengths and
807: that both ends of a connection share common moduli.
1.84 djm 808: .Sh CERTIFICATES
809: .Nm
810: supports signing of keys to produce certificates that may be used for
811: user or host authentication.
812: Certificates consist of a public key, some identity information, zero or
1.94 jmc 813: more principal (user or host) names and a set of options that
1.84 djm 814: are signed by a Certification Authority (CA) key.
815: Clients or servers may then trust only the CA key and verify its signature
816: on a certificate rather than trusting many user/host keys.
817: Note that OpenSSH certificates are a different, and much simpler, format to
818: the X.509 certificates used in
819: .Xr ssl 8 .
820: .Pp
821: .Nm
822: supports two types of certificates: user and host.
823: User certificates authenticate users to servers, whereas host certificates
1.85 jmc 824: authenticate server hosts to users.
825: To generate a user certificate:
1.84 djm 826: .Pp
827: .Dl $ ssh-keygen -s /path/to/ca_key -I key_id /path/to/user_key.pub
828: .Pp
829: The resultant certificate will be placed in
1.91 djm 830: .Pa /path/to/user_key-cert.pub .
1.84 djm 831: A host certificate requires the
832: .Fl h
833: option:
834: .Pp
835: .Dl $ ssh-keygen -s /path/to/ca_key -I key_id -h /path/to/host_key.pub
836: .Pp
837: The host certificate will be output to
1.91 djm 838: .Pa /path/to/host_key-cert.pub .
1.98 djm 839: .Pp
840: It is possible to sign using a CA key stored in a PKCS#11 token by
841: providing the token library using
842: .Fl D
843: and identifying the CA key by providing its public half as an argument
844: to
845: .Fl s :
846: .Pp
1.127 naddy 847: .Dl $ ssh-keygen -s ca_key.pub -D libpkcs11.so -I key_id user_key.pub
1.142 djm 848: .Pp
849: Similarly, it is possible for the CA key to be hosted in a
850: .Xr ssh-agent 1 .
851: This is indicated by the
852: .Fl U
853: flag and, again, the CA key must be identified by its public half.
854: .Pp
855: .Dl $ ssh-keygen -Us ca_key.pub -I key_id user_key.pub
1.98 djm 856: .Pp
857: In all cases,
1.84 djm 858: .Ar key_id
859: is a "key identifier" that is logged by the server when the certificate
860: is used for authentication.
861: .Pp
862: Certificates may be limited to be valid for a set of principal (user/host)
863: names.
864: By default, generated certificates are valid for all users or hosts.
865: To generate a certificate for a specified set of principals:
866: .Pp
867: .Dl $ ssh-keygen -s ca_key -I key_id -n user1,user2 user_key.pub
1.127 naddy 868: .Dl "$ ssh-keygen -s ca_key -I key_id -h -n host.domain host_key.pub"
1.84 djm 869: .Pp
870: Additional limitations on the validity and use of user certificates may
1.94 jmc 871: be specified through certificate options.
1.93 djm 872: A certificate option may disable features of the SSH session, may be
1.84 djm 873: valid only when presented from particular source addresses or may
874: force the use of a specific command.
1.93 djm 875: For a list of valid certificate options, see the documentation for the
1.84 djm 876: .Fl O
877: option above.
878: .Pp
879: Finally, certificates may be defined with a validity lifetime.
880: The
881: .Fl V
882: option allows specification of certificate start and end times.
883: A certificate that is presented at a time outside this range will not be
884: considered valid.
1.110 jmc 885: By default, certificates are valid from
886: .Ux
887: Epoch to the distant future.
1.84 djm 888: .Pp
889: For certificates to be used for user or host authentication, the CA
890: public key must be trusted by
891: .Xr sshd 8
892: or
893: .Xr ssh 1 .
894: Please refer to those manual pages for details.
1.111 djm 895: .Sh KEY REVOCATION LISTS
896: .Nm
897: is able to manage OpenSSH format Key Revocation Lists (KRLs).
898: These binary files specify keys or certificates to be revoked using a
1.119 tedu 899: compact format, taking as little as one bit per certificate if they are being
1.111 djm 900: revoked by serial number.
901: .Pp
902: KRLs may be generated using the
903: .Fl k
904: flag.
1.114 jmc 905: This option reads one or more files from the command line and generates a new
1.111 djm 906: KRL.
907: The files may either contain a KRL specification (see below) or public keys,
908: listed one per line.
909: Plain public keys are revoked by listing their hash or contents in the KRL and
910: certificates revoked by serial number or key ID (if the serial is zero or
911: not available).
912: .Pp
913: Revoking keys using a KRL specification offers explicit control over the
914: types of record used to revoke keys and may be used to directly revoke
915: certificates by serial number or key ID without having the complete original
916: certificate on hand.
917: A KRL specification consists of lines containing one of the following directives
918: followed by a colon and some directive-specific information.
919: .Bl -tag -width Ds
1.115 jmc 920: .It Cm serial : Ar serial_number Ns Op - Ns Ar serial_number
1.111 djm 921: Revokes a certificate with the specified serial number.
1.112 jmc 922: Serial numbers are 64-bit values, not including zero and may be expressed
1.111 djm 923: in decimal, hex or octal.
924: If two serial numbers are specified separated by a hyphen, then the range
925: of serial numbers including and between each is revoked.
926: The CA key must have been specified on the
927: .Nm
1.114 jmc 928: command line using the
1.111 djm 929: .Fl s
930: option.
931: .It Cm id : Ar key_id
932: Revokes a certificate with the specified key ID string.
933: The CA key must have been specified on the
934: .Nm
1.114 jmc 935: command line using the
1.111 djm 936: .Fl s
937: option.
938: .It Cm key : Ar public_key
939: Revokes the specified key.
1.112 jmc 940: If a certificate is listed, then it is revoked as a plain public key.
1.111 djm 941: .It Cm sha1 : Ar public_key
1.149 djm 942: Revokes the specified key by including its SHA1 hash in the KRL.
943: .It Cm sha256 : Ar public_key
944: Revokes the specified key by including its SHA256 hash in the KRL.
945: KRLs that revoke keys by SHA256 hash are not supported by OpenSSH versions
946: prior to 7.9.
947: .It Cm hash : Ar fingerprint
1.150 djm 948: Revokes a key using a fingerprint hash, as obtained from a
1.149 djm 949: .Xr sshd 8
950: authentication log message or the
951: .Nm
952: .Fl l
953: flag.
954: Only SHA256 fingerprints are supported here and resultant KRLs are
955: not supported by OpenSSH versions prior to 7.9.
1.111 djm 956: .El
957: .Pp
958: KRLs may be updated using the
959: .Fl u
960: flag in addition to
961: .Fl k .
1.114 jmc 962: When this option is specified, keys listed via the command line are merged into
1.111 djm 963: the KRL, adding to those already there.
964: .Pp
965: It is also possible, given a KRL, to test whether it revokes a particular key
966: (or keys).
967: The
968: .Fl Q
1.128 jmc 969: flag will query an existing KRL, testing each key specified on the command line.
1.114 jmc 970: If any key listed on the command line has been revoked (or an error encountered)
1.111 djm 971: then
972: .Nm
973: will exit with a non-zero exit status.
974: A zero exit status will only be returned if no key was revoked.
1.163 djm 975: .Sh ALLOWED SIGNERS
976: When verifying signatures,
977: .Nm
978: uses a simple list of identities and keys to determine whether a signature
979: comes from an authorized source.
980: This "allowed signers" file uses a format patterned after the
981: AUTHORIZED_KEYS FILE FORMAT described in
1.165 jmc 982: .Xr sshd 8 .
1.163 djm 983: Each line of the file contains the following space-separated fields:
984: principals, options, keytype, base64-encoded key.
985: Empty lines and lines starting with a
986: .Ql #
987: are ignored as comments.
988: .Pp
989: The principals field is a pattern-list (See PATTERNS in
990: .Xr ssh_config 5 )
991: consisting of one or more comma-separated USER@DOMAIN identity patterns
992: that are accepted for signing.
993: When verifying, the identity presented via the
994: .Fl I option
995: must match a principals pattern in order for the corresponding key to be
996: considered acceptable for verification.
997: .Pp
998: The options (if present) consist of comma-separated option specifications.
999: No spaces are permitted, except within double quotes.
1000: The following option specifications are supported (note that option keywords
1001: are case-insensitive):
1002: .Bl -tag -width Ds
1003: .It Cm cert-authority
1004: Indicates that this key is accepted as a certificate authority (CA) and
1005: that certificates signed by this CA may be accepted for verification.
1006: .It Cm namespaces="namespace-list"
1007: Specifies a pattern-list of namespaces that are accepted for this key.
1.164 djm 1008: If this option is present, the signature namespace embedded in the
1.163 djm 1009: signature object and presented on the verification command-line must
1010: match the specified list before the key will be considered acceptable.
1011: .El
1012: .Pp
1013: When verifying signatures made by certificates, the expected principal
1014: name must match both the principals pattern in the allowed signers file and
1015: the principals embedded in the certificate itself.
1016: .Pp
1017: An example allowed signers file:
1018: .Bd -literal -offset 3n
1019: # Comments allowed at start of line
1020: user1@example.com,user2@example.com ssh-rsa AAAAX1...
1021: # A certificate authority, trusted for all principals in a domain.
1022: *@example.com cert-authority ssh-ed25519 AAAB4...
1023: # A key that is accepted only for file signing.
1024: user2@example.com namespaces="file" ssh-ed25519 AAA41...
1025: .Ed
1.2 deraadt 1026: .Sh FILES
1.100 naddy 1027: .Bl -tag -width Ds -compact
1.68 djm 1028: .It Pa ~/.ssh/id_dsa
1.100 naddy 1029: .It Pa ~/.ssh/id_ecdsa
1.118 naddy 1030: .It Pa ~/.ssh/id_ed25519
1.100 naddy 1031: .It Pa ~/.ssh/id_rsa
1.141 naddy 1032: Contains the DSA, ECDSA, Ed25519 or RSA
1.118 naddy 1033: authentication identity of the user.
1.15 deraadt 1034: This file should not be readable by anyone but the user.
1035: It is possible to
1036: specify a passphrase when generating the key; that passphrase will be
1.80 dtucker 1037: used to encrypt the private part of this file using 128-bit AES.
1.15 deraadt 1038: This file is not automatically accessed by
1039: .Nm
1040: but it is offered as the default file for the private key.
1.46 markus 1041: .Xr ssh 1
1.15 deraadt 1042: will read this file when a login attempt is made.
1.100 naddy 1043: .Pp
1.68 djm 1044: .It Pa ~/.ssh/id_dsa.pub
1.100 naddy 1045: .It Pa ~/.ssh/id_ecdsa.pub
1.118 naddy 1046: .It Pa ~/.ssh/id_ed25519.pub
1.68 djm 1047: .It Pa ~/.ssh/id_rsa.pub
1.141 naddy 1048: Contains the DSA, ECDSA, Ed25519 or RSA
1.118 naddy 1049: public key for authentication.
1.15 deraadt 1050: The contents of this file should be added to
1.68 djm 1051: .Pa ~/.ssh/authorized_keys
1.15 deraadt 1052: on all machines
1.49 deraadt 1053: where the user wishes to log in using public key authentication.
1.12 aaron 1054: There is no need to keep the contents of this file secret.
1.100 naddy 1055: .Pp
1.60 djm 1056: .It Pa /etc/moduli
1057: Contains Diffie-Hellman groups used for DH-GEX.
1058: The file format is described in
1059: .Xr moduli 5 .
1.19 aaron 1060: .El
1.2 deraadt 1061: .Sh SEE ALSO
1062: .Xr ssh 1 ,
1063: .Xr ssh-add 1 ,
1.8 ericj 1064: .Xr ssh-agent 1 ,
1.60 djm 1065: .Xr moduli 5 ,
1.30 itojun 1066: .Xr sshd 8
1.37 markus 1067: .Rs
1.73 markus 1068: .%R RFC 4716
1069: .%T "The Secure Shell (SSH) Public Key File Format"
1070: .%D 2006
1.37 markus 1071: .Re
1.59 jmc 1072: .Sh AUTHORS
1073: OpenSSH is a derivative of the original and free
1074: ssh 1.2.12 release by Tatu Ylonen.
1075: Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos,
1076: Theo de Raadt and Dug Song
1077: removed many bugs, re-added newer features and
1078: created OpenSSH.
1079: Markus Friedl contributed the support for SSH
1080: protocol versions 1.5 and 2.0.