Annotation of src/usr.bin/ssh/ssh-keygen.1, Revision 1.124
1.124 ! djm 1: .\" $OpenBSD: ssh-keygen.1,v 1.123 2014/08/30 15:33:50 sobrado 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.124 ! djm 38: .Dd $Mdocdate: August 30 2014 $
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.121 deraadt 49: .Op Fl t Cm dsa | ecdsa | ed25519 | rsa | rsa1
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.2 deraadt 53: .Nm ssh-keygen
54: .Fl p
55: .Op Fl P Ar old_passphrase
56: .Op Fl N Ar new_passphrase
1.9 markus 57: .Op Fl f Ar keyfile
1.2 deraadt 58: .Nm ssh-keygen
1.37 markus 59: .Fl i
1.95 djm 60: .Op Fl m Ar key_format
1.20 markus 61: .Op Fl f Ar input_keyfile
1.16 deraadt 62: .Nm ssh-keygen
1.37 markus 63: .Fl e
1.95 djm 64: .Op Fl m Ar key_format
1.20 markus 65: .Op Fl f Ar input_keyfile
1.16 deraadt 66: .Nm ssh-keygen
1.17 markus 67: .Fl y
1.20 markus 68: .Op Fl f Ar input_keyfile
1.17 markus 69: .Nm ssh-keygen
1.2 deraadt 70: .Fl c
71: .Op Fl P Ar passphrase
72: .Op Fl C Ar comment
1.9 markus 73: .Op Fl f Ar keyfile
74: .Nm ssh-keygen
75: .Fl l
1.124 ! djm 76: .Op Fl E Ar fingerprint_hash
1.35 markus 77: .Op Fl f Ar input_keyfile
78: .Nm ssh-keygen
79: .Fl B
1.20 markus 80: .Op Fl f Ar input_keyfile
1.48 jakob 81: .Nm ssh-keygen
1.82 jmc 82: .Fl D Ar pkcs11
1.48 jakob 83: .Nm ssh-keygen
1.64 djm 84: .Fl F Ar hostname
85: .Op Fl f Ar known_hosts_file
1.79 sthen 86: .Op Fl l
1.64 djm 87: .Nm ssh-keygen
88: .Fl H
89: .Op Fl f Ar known_hosts_file
90: .Nm ssh-keygen
91: .Fl R Ar hostname
92: .Op Fl f Ar known_hosts_file
1.57 jakob 93: .Nm ssh-keygen
94: .Fl r Ar hostname
95: .Op Fl f Ar input_keyfile
96: .Op Fl g
1.60 djm 97: .Nm ssh-keygen
98: .Fl G Ar output_file
1.61 djm 99: .Op Fl v
1.60 djm 100: .Op Fl b Ar bits
101: .Op Fl M Ar memory
102: .Op Fl S Ar start_point
103: .Nm ssh-keygen
104: .Fl T Ar output_file
105: .Fl f Ar input_file
1.61 djm 106: .Op Fl v
1.117 djm 107: .Op Fl a Ar rounds
1.109 dtucker 108: .Op Fl J Ar num_lines
109: .Op Fl j Ar start_line
1.108 dtucker 110: .Op Fl K Ar checkpt
1.60 djm 111: .Op Fl W Ar generator
1.84 djm 112: .Nm ssh-keygen
113: .Fl s Ar ca_key
114: .Fl I Ar certificate_identity
115: .Op Fl h
116: .Op Fl n Ar principals
1.93 djm 117: .Op Fl O Ar option
1.84 djm 118: .Op Fl V Ar validity_interval
1.93 djm 119: .Op Fl z Ar serial_number
1.84 djm 120: .Ar
1.86 djm 121: .Nm ssh-keygen
122: .Fl L
123: .Op Fl f Ar input_keyfile
1.102 stevesk 124: .Nm ssh-keygen
125: .Fl A
1.111 djm 126: .Nm ssh-keygen
127: .Fl k
128: .Fl f Ar krl_file
129: .Op Fl u
1.112 jmc 130: .Op Fl s Ar ca_public
131: .Op Fl z Ar version_number
1.111 djm 132: .Ar
133: .Nm ssh-keygen
134: .Fl Q
135: .Fl f Ar krl_file
136: .Ar
1.85 jmc 137: .Ek
1.13 aaron 138: .Sh DESCRIPTION
1.2 deraadt 139: .Nm
1.37 markus 140: generates, manages and converts authentication keys for
1.2 deraadt 141: .Xr ssh 1 .
1.15 deraadt 142: .Nm
1.118 naddy 143: can create RSA keys for use by SSH protocol version 1 and
1.123 sobrado 144: DSA, ECDSA, Ed25519 or RSA keys for use by SSH protocol version 2.
1.58 jmc 145: The type of key to be generated is specified with the
1.25 markus 146: .Fl t
1.52 djm 147: option.
1.70 djm 148: If invoked without any arguments,
149: .Nm
1.71 jmc 150: will generate an RSA key for use in SSH protocol 2 connections.
1.15 deraadt 151: .Pp
1.60 djm 152: .Nm
153: is also used to generate groups for use in Diffie-Hellman group
154: exchange (DH-GEX).
155: See the
156: .Sx MODULI GENERATION
157: section for details.
158: .Pp
1.111 djm 159: Finally,
160: .Nm
161: can be used to generate and update Key Revocation Lists, and to test whether
1.112 jmc 162: given keys have been revoked by one.
163: See the
1.111 djm 164: .Sx KEY REVOCATION LISTS
165: section for details.
166: .Pp
1.2 deraadt 167: Normally each user wishing to use SSH
1.99 djm 168: with public key authentication runs this once to create the authentication
1.1 deraadt 169: key in
1.68 djm 170: .Pa ~/.ssh/identity ,
1.118 naddy 171: .Pa ~/.ssh/id_dsa ,
1.99 djm 172: .Pa ~/.ssh/id_ecdsa ,
1.118 naddy 173: .Pa ~/.ssh/id_ed25519
1.15 deraadt 174: or
1.68 djm 175: .Pa ~/.ssh/id_rsa .
1.15 deraadt 176: Additionally, the system administrator may use this to generate host keys,
177: as seen in
178: .Pa /etc/rc .
1.2 deraadt 179: .Pp
1.1 deraadt 180: Normally this program generates the key and asks for a file in which
1.12 aaron 181: to store the private key.
182: The public key is stored in a file with the same name but
1.2 deraadt 183: .Dq .pub
1.12 aaron 184: appended.
185: The program also asks for a passphrase.
186: The passphrase may be empty to indicate no passphrase
1.26 markus 187: (host keys must have an empty passphrase), or it may be a string of
1.12 aaron 188: arbitrary length.
1.51 stevesk 189: A passphrase is similar to a password, except it can be a phrase with a
190: series of words, punctuation, numbers, whitespace, or any string of
191: characters you want.
192: Good passphrases are 10-30 characters long, are
1.1 deraadt 193: not simple sentences or otherwise easily guessable (English
1.42 markus 194: prose has only 1-2 bits of entropy per character, and provides very bad
1.51 stevesk 195: passphrases), and contain a mix of upper and lowercase letters,
196: numbers, and non-alphanumeric characters.
1.12 aaron 197: The passphrase can be changed later by using the
1.2 deraadt 198: .Fl p
1.1 deraadt 199: option.
1.2 deraadt 200: .Pp
1.12 aaron 201: There is no way to recover a lost passphrase.
1.105 djm 202: If the passphrase is lost or forgotten, a new key must be generated
203: and the corresponding public key copied to other machines.
1.2 deraadt 204: .Pp
1.37 markus 205: For RSA1 keys,
206: there is also a comment field in the key file that is only for
1.12 aaron 207: convenience to the user to help identify the key.
208: The comment can tell what the key is for, or whatever is useful.
209: The comment is initialized to
1.2 deraadt 210: .Dq user@host
211: when the key is created, but can be changed using the
212: .Fl c
1.1 deraadt 213: option.
1.2 deraadt 214: .Pp
1.15 deraadt 215: After a key is generated, instructions below detail where the keys
216: should be placed to be activated.
217: .Pp
1.2 deraadt 218: The options are as follows:
219: .Bl -tag -width Ds
1.102 stevesk 220: .It Fl A
1.118 naddy 221: For each of the key types (rsa1, rsa, dsa, ecdsa and ed25519)
222: for which host keys
1.102 stevesk 223: do not exist, generate the host keys with the default key file path,
224: an empty passphrase, default bits for the key type, and default comment.
1.104 jmc 225: This is used by
1.102 stevesk 226: .Pa /etc/rc
227: to generate new host keys.
1.117 djm 228: .It Fl a Ar rounds
229: When saving a new-format private key (i.e. an ed25519 key or any SSH protocol
230: 2 key when the
231: .Fl o
232: flag is set), this option specifies the number of KDF (key derivation function)
233: rounds used.
234: Higher numbers result in slower passphrase verification and increased
235: resistance to brute-force password cracking (should the keys be stolen).
236: .Pp
237: When screening DH-GEX candidates (
238: using the
1.60 djm 239: .Fl T
1.117 djm 240: command).
241: This option specifies the number of primality tests to perform.
1.66 jmc 242: .It Fl B
243: Show the bubblebabble digest of specified private or public key file.
1.2 deraadt 244: .It Fl b Ar bits
1.12 aaron 245: Specifies the number of bits in the key to create.
1.72 dtucker 246: For RSA keys, the minimum size is 768 bits and the default is 2048 bits.
1.69 djm 247: Generally, 2048 bits is considered sufficient.
1.72 dtucker 248: DSA keys must be exactly 1024 bits as specified by FIPS 186-2.
1.106 djm 249: For ECDSA keys, the
250: .Fl b
1.107 deraadt 251: flag determines the key length by selecting from one of three elliptic
1.106 djm 252: curve sizes: 256, 384 or 521 bits.
253: Attempting to use bit lengths other than these three values for ECDSA keys
254: will fail.
1.123 sobrado 255: Ed25519 keys have a fixed length and the
1.118 naddy 256: .Fl b
257: flag will be ignored.
1.66 jmc 258: .It Fl C Ar comment
259: Provides a new comment.
1.2 deraadt 260: .It Fl c
1.1 deraadt 261: Requests changing the comment in the private and public key files.
1.50 markus 262: This operation is only supported for RSA1 keys.
1.1 deraadt 263: The program will prompt for the file containing the private keys, for
1.41 stevesk 264: the passphrase if the key has one, and for the new comment.
1.81 markus 265: .It Fl D Ar pkcs11
1.83 markus 266: Download the RSA public keys provided by the PKCS#11 shared library
267: .Ar pkcs11 .
1.98 djm 268: When used in combination with
269: .Fl s ,
270: this option indicates that a CA key resides in a PKCS#11 token (see the
271: .Sx CERTIFICATES
272: section for details).
1.124 ! djm 273: .It Fl E Ar fingerprint_hash
! 274: Specifies the hash algorithm used when displaying key fingerprints.
! 275: Valid options are:
! 276: .Dq md5
! 277: and
! 278: .Dq sha256 .
! 279: The default is
! 280: .Dq sha256 .
1.37 markus 281: .It Fl e
1.40 markus 282: This option will read a private or public OpenSSH key file and
1.95 djm 283: print to stdout the key in one of the formats specified by the
284: .Fl m
285: option.
286: The default export format is
287: .Dq RFC4716 .
1.96 jmc 288: This option allows exporting OpenSSH keys for use by other programs, including
1.95 djm 289: several commercial SSH implementations.
1.66 jmc 290: .It Fl F Ar hostname
291: Search for the specified
292: .Ar hostname
293: in a
294: .Pa known_hosts
295: file, listing any occurrences found.
296: This option is useful to find hashed host names or addresses and may also be
297: used in conjunction with the
298: .Fl H
299: option to print found keys in a hashed format.
300: .It Fl f Ar filename
301: Specifies the filename of the key file.
302: .It Fl G Ar output_file
303: Generate candidate primes for DH-GEX.
304: These primes must be screened for
305: safety (using the
306: .Fl T
307: option) before use.
1.57 jakob 308: .It Fl g
1.62 jakob 309: Use generic DNS format when printing fingerprint resource records using the
1.63 jmc 310: .Fl r
1.62 jakob 311: command.
1.66 jmc 312: .It Fl H
313: Hash a
314: .Pa known_hosts
1.67 dtucker 315: file.
316: This replaces all hostnames and addresses with hashed representations
317: within the specified file; the original content is moved to a file with
318: a .old suffix.
1.66 jmc 319: These hashes may be used normally by
320: .Nm ssh
321: and
322: .Nm sshd ,
323: but they do not reveal identifying information should the file's contents
324: be disclosed.
325: This option will not modify existing hashed hostnames and is therefore safe
326: to use on files that mix hashed and non-hashed names.
1.84 djm 327: .It Fl h
328: When signing a key, create a host certificate instead of a user
329: certificate.
330: Please see the
331: .Sx CERTIFICATES
332: section for details.
1.85 jmc 333: .It Fl I Ar certificate_identity
1.84 djm 334: Specify the key identity when signing a public key.
335: Please see the
336: .Sx CERTIFICATES
337: section for details.
1.37 markus 338: .It Fl i
339: This option will read an unencrypted private (or public) key file
1.95 djm 340: in the format specified by the
341: .Fl m
342: option and print an OpenSSH compatible private
1.37 markus 343: (or public) key to stdout.
1.122 jmc 344: This option allows importing keys from other software, including several
345: commercial SSH implementations.
346: The default import format is
347: .Dq RFC4716 .
1.109 dtucker 348: .It Fl J Ar num_lines
349: Exit after screening the specified number of lines
350: while performing DH candidate screening using the
351: .Fl T
352: option.
353: .It Fl j Ar start_line
354: Start screening at the specified line number
355: while performing DH candidate screening using the
356: .Fl T
357: option.
1.108 dtucker 358: .It Fl K Ar checkpt
359: Write the last line processed to the file
360: .Ar checkpt
361: while performing DH candidate screening using the
362: .Fl T
363: option.
364: This will be used to skip lines in the input file that have already been
365: processed if the job is restarted.
1.111 djm 366: .It Fl k
367: Generate a KRL file.
368: In this mode,
369: .Nm
370: will generate a KRL file at the location specified via the
371: .Fl f
1.114 jmc 372: flag that revokes every key or certificate presented on the command line.
1.111 djm 373: Keys/certificates to be revoked may be specified by public key file or
374: using the format described in the
375: .Sx KEY REVOCATION LISTS
376: section.
1.86 djm 377: .It Fl L
378: Prints the contents of a certificate.
1.9 markus 379: .It Fl l
1.77 grunk 380: Show fingerprint of specified public key file.
1.50 markus 381: Private RSA1 keys are also supported.
382: For RSA and DSA keys
383: .Nm
1.78 jmc 384: tries to find the matching public key file and prints its fingerprint.
385: If combined with
386: .Fl v ,
387: an ASCII art representation of the key is supplied with the fingerprint.
1.96 jmc 388: .It Fl M Ar memory
389: Specify the amount of memory to use (in megabytes) when generating
390: candidate moduli for DH-GEX.
1.95 djm 391: .It Fl m Ar key_format
392: Specify a key format for the
393: .Fl i
394: (import) or
395: .Fl e
1.96 jmc 396: (export) conversion options.
1.95 djm 397: The supported key formats are:
398: .Dq RFC4716
1.96 jmc 399: (RFC 4716/SSH2 public or private key),
1.95 djm 400: .Dq PKCS8
401: (PEM PKCS8 public key)
402: or
403: .Dq PEM
404: (PEM public key).
405: The default conversion format is
406: .Dq RFC4716 .
1.66 jmc 407: .It Fl N Ar new_passphrase
408: Provides the new passphrase.
1.84 djm 409: .It Fl n Ar principals
410: Specify one or more principals (user or host names) to be included in
411: a certificate when signing a key.
412: Multiple principals may be specified, separated by commas.
413: Please see the
414: .Sx CERTIFICATES
415: section for details.
1.93 djm 416: .It Fl O Ar option
417: Specify a certificate option when signing a key.
1.84 djm 418: This option may be specified multiple times.
419: Please see the
420: .Sx CERTIFICATES
421: section for details.
1.93 djm 422: The options that are valid for user certificates are:
1.84 djm 423: .Bl -tag -width Ds
1.89 jmc 424: .It Ic clear
425: Clear all enabled permissions.
426: This is useful for clearing the default set of permissions so permissions may
427: be added individually.
428: .It Ic force-command Ns = Ns Ar command
429: Forces the execution of
430: .Ar command
431: instead of any shell or command specified by the user when
432: the certificate is used for authentication.
1.84 djm 433: .It Ic no-agent-forwarding
434: Disable
435: .Xr ssh-agent 1
1.85 jmc 436: forwarding (permitted by default).
1.84 djm 437: .It Ic no-port-forwarding
1.85 jmc 438: Disable port forwarding (permitted by default).
1.84 djm 439: .It Ic no-pty
1.85 jmc 440: Disable PTY allocation (permitted by default).
1.84 djm 441: .It Ic no-user-rc
442: Disable execution of
443: .Pa ~/.ssh/rc
444: by
1.85 jmc 445: .Xr sshd 8
446: (permitted by default).
1.89 jmc 447: .It Ic no-x11-forwarding
448: Disable X11 forwarding (permitted by default).
1.88 djm 449: .It Ic permit-agent-forwarding
450: Allows
451: .Xr ssh-agent 1
452: forwarding.
1.84 djm 453: .It Ic permit-port-forwarding
454: Allows port forwarding.
455: .It Ic permit-pty
456: Allows PTY allocation.
457: .It Ic permit-user-rc
458: Allows execution of
459: .Pa ~/.ssh/rc
460: by
461: .Xr sshd 8 .
1.89 jmc 462: .It Ic permit-x11-forwarding
463: Allows X11 forwarding.
464: .It Ic source-address Ns = Ns Ar address_list
1.90 jmc 465: Restrict the source addresses from which the certificate is considered valid.
1.84 djm 466: The
467: .Ar address_list
468: is a comma-separated list of one or more address/netmask pairs in CIDR
469: format.
470: .El
471: .Pp
1.93 djm 472: At present, no options are valid for host keys.
1.117 djm 473: .It Fl o
474: Causes
475: .Nm
476: to save SSH protocol 2 private keys using the new OpenSSH format rather than
477: the more compatible PEM format.
478: The new format has increased resistance to brute-force password cracking
479: but is not supported by versions of OpenSSH prior to 6.5.
480: Ed25519 keys always use the new private key format.
1.66 jmc 481: .It Fl P Ar passphrase
482: Provides the (old) passphrase.
1.2 deraadt 483: .It Fl p
1.1 deraadt 484: Requests changing the passphrase of a private key file instead of
1.12 aaron 485: creating a new private key.
486: The program will prompt for the file
1.1 deraadt 487: containing the private key, for the old passphrase, and twice for the
488: new passphrase.
1.113 jmc 489: .It Fl Q
490: Test whether keys have been revoked in a KRL.
1.5 aaron 491: .It Fl q
492: Silence
493: .Nm ssh-keygen .
1.64 djm 494: .It Fl R Ar hostname
495: Removes all keys belonging to
496: .Ar hostname
1.65 jmc 497: from a
1.64 djm 498: .Pa known_hosts
499: file.
1.65 jmc 500: This option is useful to delete hashed hosts (see the
1.64 djm 501: .Fl H
502: option above).
1.66 jmc 503: .It Fl r Ar hostname
504: Print the SSHFP fingerprint resource record named
505: .Ar hostname
506: for the specified public key file.
1.60 djm 507: .It Fl S Ar start
508: Specify start point (in hex) when generating candidate moduli for DH-GEX.
1.84 djm 509: .It Fl s Ar ca_key
510: Certify (sign) a public key using the specified CA key.
511: Please see the
512: .Sx CERTIFICATES
513: section for details.
1.111 djm 514: .Pp
515: When generating a KRL,
516: .Fl s
1.112 jmc 517: specifies a path to a CA public key file used to revoke certificates directly
1.111 djm 518: by key ID or serial number.
519: See the
520: .Sx KEY REVOCATION LISTS
521: section for details.
1.60 djm 522: .It Fl T Ar output_file
523: Test DH group exchange candidate primes (generated using the
524: .Fl G
525: option) for safety.
1.121 deraadt 526: .It Fl t Cm dsa | ecdsa | ed25519 | rsa | rsa1
1.66 jmc 527: Specifies the type of key to create.
528: The possible values are
529: .Dq rsa1
530: for protocol version 1 and
1.100 naddy 531: .Dq dsa ,
1.118 naddy 532: .Dq ecdsa ,
533: .Dq ed25519 ,
1.100 naddy 534: or
1.66 jmc 535: .Dq rsa
536: for protocol version 2.
1.112 jmc 537: .It Fl u
538: Update a KRL.
539: When specified with
540: .Fl k ,
1.114 jmc 541: keys listed via the command line are added to the existing KRL rather than
1.112 jmc 542: a new KRL being created.
1.84 djm 543: .It Fl V Ar validity_interval
544: Specify a validity interval when signing a certificate.
545: A validity interval may consist of a single time, indicating that the
546: certificate is valid beginning now and expiring at that time, or may consist
547: of two times separated by a colon to indicate an explicit time interval.
548: The start time may be specified as a date in YYYYMMDD format, a time
549: in YYYYMMDDHHMMSS format or a relative time (to the current time) consisting
550: of a minus sign followed by a relative time in the format described in the
1.116 jmc 551: TIME FORMATS section of
1.90 jmc 552: .Xr sshd_config 5 .
1.84 djm 553: The end time may be specified as a YYYYMMDD date, a YYYYMMDDHHMMSS time or
554: a relative time starting with a plus character.
555: .Pp
556: For example:
557: .Dq +52w1d
558: (valid from now to 52 weeks and one day from now),
559: .Dq -4w:+4w
560: (valid from four weeks ago to four weeks from now),
561: .Dq 20100101123000:20110101123000
562: (valid from 12:30 PM, January 1st, 2010 to 12:30 PM, January 1st, 2011),
563: .Dq -1d:20110101
564: (valid from yesterday to midnight, January 1st, 2011).
1.61 djm 565: .It Fl v
566: Verbose mode.
567: Causes
568: .Nm
569: to print debugging messages about its progress.
570: This is helpful for debugging moduli generation.
571: Multiple
572: .Fl v
573: options increase the verbosity.
574: The maximum is 3.
1.66 jmc 575: .It Fl W Ar generator
576: Specify desired generator when testing candidate moduli for DH-GEX.
577: .It Fl y
578: This option will read a private
579: OpenSSH format file and print an OpenSSH public key to stdout.
1.93 djm 580: .It Fl z Ar serial_number
581: Specifies a serial number to be embedded in the certificate to distinguish
582: this certificate from others from the same CA.
583: The default serial number is zero.
1.111 djm 584: .Pp
585: When generating a KRL, the
586: .Fl z
587: flag is used to specify a KRL version number.
1.2 deraadt 588: .El
1.60 djm 589: .Sh MODULI GENERATION
590: .Nm
591: may be used to generate groups for the Diffie-Hellman Group Exchange
592: (DH-GEX) protocol.
593: Generating these groups is a two-step process: first, candidate
594: primes are generated using a fast, but memory intensive process.
595: These candidate primes are then tested for suitability (a CPU-intensive
596: process).
597: .Pp
598: Generation of primes is performed using the
599: .Fl G
600: option.
601: The desired length of the primes may be specified by the
602: .Fl b
603: option.
604: For example:
605: .Pp
1.66 jmc 606: .Dl # ssh-keygen -G moduli-2048.candidates -b 2048
1.60 djm 607: .Pp
608: By default, the search for primes begins at a random point in the
609: desired length range.
610: This may be overridden using the
611: .Fl S
612: option, which specifies a different start point (in hex).
613: .Pp
1.109 dtucker 614: Once a set of candidates have been generated, they must be screened for
1.60 djm 615: suitability.
616: This may be performed using the
617: .Fl T
618: option.
619: In this mode
620: .Nm
621: will read candidates from standard input (or a file specified using the
622: .Fl f
623: option).
624: For example:
625: .Pp
1.66 jmc 626: .Dl # ssh-keygen -T moduli-2048 -f moduli-2048.candidates
1.60 djm 627: .Pp
628: By default, each candidate will be subjected to 100 primality tests.
629: This may be overridden using the
630: .Fl a
631: option.
632: The DH generator value will be chosen automatically for the
633: prime under consideration.
634: If a specific generator is desired, it may be requested using the
635: .Fl W
636: option.
1.66 jmc 637: Valid generator values are 2, 3, and 5.
1.60 djm 638: .Pp
639: Screened DH groups may be installed in
640: .Pa /etc/moduli .
641: It is important that this file contains moduli of a range of bit lengths and
642: that both ends of a connection share common moduli.
1.84 djm 643: .Sh CERTIFICATES
644: .Nm
645: supports signing of keys to produce certificates that may be used for
646: user or host authentication.
647: Certificates consist of a public key, some identity information, zero or
1.94 jmc 648: more principal (user or host) names and a set of options that
1.84 djm 649: are signed by a Certification Authority (CA) key.
650: Clients or servers may then trust only the CA key and verify its signature
651: on a certificate rather than trusting many user/host keys.
652: Note that OpenSSH certificates are a different, and much simpler, format to
653: the X.509 certificates used in
654: .Xr ssl 8 .
655: .Pp
656: .Nm
657: supports two types of certificates: user and host.
658: User certificates authenticate users to servers, whereas host certificates
1.85 jmc 659: authenticate server hosts to users.
660: To generate a user certificate:
1.84 djm 661: .Pp
662: .Dl $ ssh-keygen -s /path/to/ca_key -I key_id /path/to/user_key.pub
663: .Pp
664: The resultant certificate will be placed in
1.91 djm 665: .Pa /path/to/user_key-cert.pub .
1.84 djm 666: A host certificate requires the
667: .Fl h
668: option:
669: .Pp
670: .Dl $ ssh-keygen -s /path/to/ca_key -I key_id -h /path/to/host_key.pub
671: .Pp
672: The host certificate will be output to
1.91 djm 673: .Pa /path/to/host_key-cert.pub .
1.98 djm 674: .Pp
675: It is possible to sign using a CA key stored in a PKCS#11 token by
676: providing the token library using
677: .Fl D
678: and identifying the CA key by providing its public half as an argument
679: to
680: .Fl s :
681: .Pp
682: .Dl $ ssh-keygen -s ca_key.pub -D libpkcs11.so -I key_id host_key.pub
683: .Pp
684: In all cases,
1.84 djm 685: .Ar key_id
686: is a "key identifier" that is logged by the server when the certificate
687: is used for authentication.
688: .Pp
689: Certificates may be limited to be valid for a set of principal (user/host)
690: names.
691: By default, generated certificates are valid for all users or hosts.
692: To generate a certificate for a specified set of principals:
693: .Pp
694: .Dl $ ssh-keygen -s ca_key -I key_id -n user1,user2 user_key.pub
1.92 jmc 695: .Dl "$ ssh-keygen -s ca_key -I key_id -h -n host.domain user_key.pub"
1.84 djm 696: .Pp
697: Additional limitations on the validity and use of user certificates may
1.94 jmc 698: be specified through certificate options.
1.93 djm 699: A certificate option may disable features of the SSH session, may be
1.84 djm 700: valid only when presented from particular source addresses or may
701: force the use of a specific command.
1.93 djm 702: For a list of valid certificate options, see the documentation for the
1.84 djm 703: .Fl O
704: option above.
705: .Pp
706: Finally, certificates may be defined with a validity lifetime.
707: The
708: .Fl V
709: option allows specification of certificate start and end times.
710: A certificate that is presented at a time outside this range will not be
711: considered valid.
1.110 jmc 712: By default, certificates are valid from
713: .Ux
714: Epoch to the distant future.
1.84 djm 715: .Pp
716: For certificates to be used for user or host authentication, the CA
717: public key must be trusted by
718: .Xr sshd 8
719: or
720: .Xr ssh 1 .
721: Please refer to those manual pages for details.
1.111 djm 722: .Sh KEY REVOCATION LISTS
723: .Nm
724: is able to manage OpenSSH format Key Revocation Lists (KRLs).
725: These binary files specify keys or certificates to be revoked using a
1.119 tedu 726: compact format, taking as little as one bit per certificate if they are being
1.111 djm 727: revoked by serial number.
728: .Pp
729: KRLs may be generated using the
730: .Fl k
731: flag.
1.114 jmc 732: This option reads one or more files from the command line and generates a new
1.111 djm 733: KRL.
734: The files may either contain a KRL specification (see below) or public keys,
735: listed one per line.
736: Plain public keys are revoked by listing their hash or contents in the KRL and
737: certificates revoked by serial number or key ID (if the serial is zero or
738: not available).
739: .Pp
740: Revoking keys using a KRL specification offers explicit control over the
741: types of record used to revoke keys and may be used to directly revoke
742: certificates by serial number or key ID without having the complete original
743: certificate on hand.
744: A KRL specification consists of lines containing one of the following directives
745: followed by a colon and some directive-specific information.
746: .Bl -tag -width Ds
1.115 jmc 747: .It Cm serial : Ar serial_number Ns Op - Ns Ar serial_number
1.111 djm 748: Revokes a certificate with the specified serial number.
1.112 jmc 749: Serial numbers are 64-bit values, not including zero and may be expressed
1.111 djm 750: in decimal, hex or octal.
751: If two serial numbers are specified separated by a hyphen, then the range
752: of serial numbers including and between each is revoked.
753: The CA key must have been specified on the
754: .Nm
1.114 jmc 755: command line using the
1.111 djm 756: .Fl s
757: option.
758: .It Cm id : Ar key_id
759: Revokes a certificate with the specified key ID string.
760: The CA key must have been specified on the
761: .Nm
1.114 jmc 762: command line using the
1.111 djm 763: .Fl s
764: option.
765: .It Cm key : Ar public_key
766: Revokes the specified key.
1.112 jmc 767: If a certificate is listed, then it is revoked as a plain public key.
1.111 djm 768: .It Cm sha1 : Ar public_key
769: Revokes the specified key by its SHA1 hash.
770: .El
771: .Pp
772: KRLs may be updated using the
773: .Fl u
774: flag in addition to
775: .Fl k .
1.114 jmc 776: When this option is specified, keys listed via the command line are merged into
1.111 djm 777: the KRL, adding to those already there.
778: .Pp
779: It is also possible, given a KRL, to test whether it revokes a particular key
780: (or keys).
781: The
782: .Fl Q
783: flag will query an existing KRL, testing each key specified on the commandline.
1.114 jmc 784: If any key listed on the command line has been revoked (or an error encountered)
1.111 djm 785: then
786: .Nm
787: will exit with a non-zero exit status.
788: A zero exit status will only be returned if no key was revoked.
1.2 deraadt 789: .Sh FILES
1.100 naddy 790: .Bl -tag -width Ds -compact
1.68 djm 791: .It Pa ~/.ssh/identity
1.36 itojun 792: Contains the protocol version 1 RSA authentication identity of the user.
1.12 aaron 793: This file should not be readable by anyone but the user.
794: It is possible to
1.1 deraadt 795: specify a passphrase when generating the key; that passphrase will be
1.100 naddy 796: used to encrypt the private part of this file using 3DES.
1.12 aaron 797: This file is not automatically accessed by
1.2 deraadt 798: .Nm
1.1 deraadt 799: but it is offered as the default file for the private key.
1.46 markus 800: .Xr ssh 1
1.15 deraadt 801: will read this file when a login attempt is made.
1.100 naddy 802: .Pp
1.68 djm 803: .It Pa ~/.ssh/identity.pub
1.36 itojun 804: Contains the protocol version 1 RSA public key for authentication.
1.12 aaron 805: The contents of this file should be added to
1.68 djm 806: .Pa ~/.ssh/authorized_keys
1.2 deraadt 807: on all machines
1.49 deraadt 808: where the user wishes to log in using RSA authentication.
1.15 deraadt 809: There is no need to keep the contents of this file secret.
1.100 naddy 810: .Pp
1.68 djm 811: .It Pa ~/.ssh/id_dsa
1.100 naddy 812: .It Pa ~/.ssh/id_ecdsa
1.118 naddy 813: .It Pa ~/.ssh/id_ed25519
1.100 naddy 814: .It Pa ~/.ssh/id_rsa
1.123 sobrado 815: Contains the protocol version 2 DSA, ECDSA, Ed25519 or RSA
1.118 naddy 816: authentication identity of the user.
1.15 deraadt 817: This file should not be readable by anyone but the user.
818: It is possible to
819: specify a passphrase when generating the key; that passphrase will be
1.80 dtucker 820: used to encrypt the private part of this file using 128-bit AES.
1.15 deraadt 821: This file is not automatically accessed by
822: .Nm
823: but it is offered as the default file for the private key.
1.46 markus 824: .Xr ssh 1
1.15 deraadt 825: will read this file when a login attempt is made.
1.100 naddy 826: .Pp
1.68 djm 827: .It Pa ~/.ssh/id_dsa.pub
1.100 naddy 828: .It Pa ~/.ssh/id_ecdsa.pub
1.118 naddy 829: .It Pa ~/.ssh/id_ed25519.pub
1.68 djm 830: .It Pa ~/.ssh/id_rsa.pub
1.123 sobrado 831: Contains the protocol version 2 DSA, ECDSA, Ed25519 or RSA
1.118 naddy 832: public key for authentication.
1.15 deraadt 833: The contents of this file should be added to
1.68 djm 834: .Pa ~/.ssh/authorized_keys
1.15 deraadt 835: on all machines
1.49 deraadt 836: where the user wishes to log in using public key authentication.
1.12 aaron 837: There is no need to keep the contents of this file secret.
1.100 naddy 838: .Pp
1.60 djm 839: .It Pa /etc/moduli
840: Contains Diffie-Hellman groups used for DH-GEX.
841: The file format is described in
842: .Xr moduli 5 .
1.19 aaron 843: .El
1.2 deraadt 844: .Sh SEE ALSO
845: .Xr ssh 1 ,
846: .Xr ssh-add 1 ,
1.8 ericj 847: .Xr ssh-agent 1 ,
1.60 djm 848: .Xr moduli 5 ,
1.30 itojun 849: .Xr sshd 8
1.37 markus 850: .Rs
1.73 markus 851: .%R RFC 4716
852: .%T "The Secure Shell (SSH) Public Key File Format"
853: .%D 2006
1.37 markus 854: .Re
1.59 jmc 855: .Sh AUTHORS
856: OpenSSH is a derivative of the original and free
857: ssh 1.2.12 release by Tatu Ylonen.
858: Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos,
859: Theo de Raadt and Dug Song
860: removed many bugs, re-added newer features and
861: created OpenSSH.
862: Markus Friedl contributed the support for SSH
863: protocol versions 1.5 and 2.0.