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