xref: /netbsd-src/crypto/external/bsd/openssh/dist/ssh-keygen.1 (revision 1580a27b92f58fcdcb23fdfbc04a7c2b54a0b7c8)
1.\"	$NetBSD: ssh-keygen.1,v 1.20 2017/10/07 19:39:19 christos Exp $
2.\"	$OpenBSD: ssh-keygen.1,v 1.144 2017/07/08 18:32:54 jmc 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 July 8 2017
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.
431The options that are valid for user certificates are:
432.Pp
433.Bl -tag -width Ds -compact
434.It Ic clear
435Clear all enabled permissions.
436This is useful for clearing the default set of permissions so permissions may
437be added individually.
438.Pp
439.It Ic critical : Ns Ar name Ns Op Ns = Ns Ar contents
440.It Ic extension : Ns Ar name Ns Op Ns = Ns Ar contents
441Includes an arbitrary certificate critical option or extension.
442The specified
443.Ar name
444should include a domain suffix, e.g.\&
445.Dq name@example.com .
446If
447.Ar contents
448is specified then it is included as the contents of the extension/option
449encoded as a string, otherwise the extension/option is created with no
450contents (usually indicating a flag).
451Extensions may be ignored by a client or server that does not recognise them,
452whereas unknown critical options will cause the certificate to be refused.
453.Pp
454At present, no standard options are valid for host keys.
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.
593The start time may be specified as a date in YYYYMMDD format, a time
594in YYYYMMDDHHMMSS format or a relative time (to the current time) consisting
595of a minus sign followed by a relative time in the format described in the
596TIME FORMATS section of
597.Xr sshd_config 5 .
598The end time may be specified as a YYYYMMDD date, a YYYYMMDDHHMMSS time or
599a relative time starting with a plus character.
600.Pp
601For example:
602.Dq +52w1d
603(valid from now to 52 weeks and one day from now),
604.Dq -4w:+4w
605(valid from four weeks ago to four weeks from now),
606.Dq 20100101123000:20110101123000
607(valid from 12:30 PM, January 1st, 2010 to 12:30 PM, January 1st, 2011),
608.Dq -1d:20110101
609(valid from yesterday to midnight, January 1st, 2011).
610.It Fl v
611Verbose mode.
612Causes
613.Nm
614to print debugging messages about its progress.
615This is helpful for debugging moduli generation.
616Multiple
617.Fl v
618options increase the verbosity.
619The maximum is 3.
620.It Fl W Ar generator
621Specify desired generator when testing candidate moduli for DH-GEX.
622.It Fl y
623This option will read a private
624OpenSSH format file and print an OpenSSH public key to stdout.
625.It Fl z Ar serial_number
626Specifies a serial number to be embedded in the certificate to distinguish
627this certificate from others from the same CA.
628The default serial number is zero.
629.Pp
630When generating a KRL, the
631.Fl z
632flag is used to specify a KRL version number.
633.El
634.Sh MODULI GENERATION
635.Nm
636may be used to generate groups for the Diffie-Hellman Group Exchange
637(DH-GEX) protocol.
638Generating these groups is a two-step process: first, candidate
639primes are generated using a fast, but memory intensive process.
640These candidate primes are then tested for suitability (a CPU-intensive
641process).
642.Pp
643Generation of primes is performed using the
644.Fl G
645option.
646The desired length of the primes may be specified by the
647.Fl b
648option.
649For example:
650.Pp
651.Dl # ssh-keygen -G moduli-2048.candidates -b 2048
652.Pp
653By default, the search for primes begins at a random point in the
654desired length range.
655This may be overridden using the
656.Fl S
657option, which specifies a different start point (in hex).
658.Pp
659Once a set of candidates have been generated, they must be screened for
660suitability.
661This may be performed using the
662.Fl T
663option.
664In this mode
665.Nm
666will read candidates from standard input (or a file specified using the
667.Fl f
668option).
669For example:
670.Pp
671.Dl # ssh-keygen -T moduli-2048 -f moduli-2048.candidates
672.Pp
673By default, each candidate will be subjected to 100 primality tests.
674This may be overridden using the
675.Fl a
676option.
677The DH generator value will be chosen automatically for the
678prime under consideration.
679If a specific generator is desired, it may be requested using the
680.Fl W
681option.
682Valid generator values are 2, 3, and 5.
683.Pp
684Screened DH groups may be installed in
685.Pa /etc/moduli .
686It is important that this file contains moduli of a range of bit lengths and
687that both ends of a connection share common moduli.
688.Sh CERTIFICATES
689.Nm
690supports signing of keys to produce certificates that may be used for
691user or host authentication.
692Certificates consist of a public key, some identity information, zero or
693more principal (user or host) names and a set of options that
694are signed by a Certification Authority (CA) key.
695Clients or servers may then trust only the CA key and verify its signature
696on a certificate rather than trusting many user/host keys.
697Note that OpenSSH certificates are a different, and much simpler, format to
698the X.509 certificates used in
699.Xr ssl 8 .
700.Pp
701.Nm
702supports two types of certificates: user and host.
703User certificates authenticate users to servers, whereas host certificates
704authenticate server hosts to users.
705To generate a user certificate:
706.Pp
707.Dl $ ssh-keygen -s /path/to/ca_key -I key_id /path/to/user_key.pub
708.Pp
709The resultant certificate will be placed in
710.Pa /path/to/user_key-cert.pub .
711A host certificate requires the
712.Fl h
713option:
714.Pp
715.Dl $ ssh-keygen -s /path/to/ca_key -I key_id -h /path/to/host_key.pub
716.Pp
717The host certificate will be output to
718.Pa /path/to/host_key-cert.pub .
719.Pp
720It is possible to sign using a CA key stored in a PKCS#11 token by
721providing the token library using
722.Fl D
723and identifying the CA key by providing its public half as an argument
724to
725.Fl s :
726.Pp
727.Dl $ ssh-keygen -s ca_key.pub -D libpkcs11.so -I key_id user_key.pub
728.Pp
729Similarly, it is possible for the CA key to be hosted in a
730.Xr ssh-agent 1 .
731This is indicated by the
732.Fl U
733flag and, again, the CA key must be identified by its public half.
734.Pp
735.Dl $ ssh-keygen -Us ca_key.pub -I key_id user_key.pub
736.Pp
737In all cases,
738.Ar key_id
739is a "key identifier" that is logged by the server when the certificate
740is used for authentication.
741.Pp
742Certificates may be limited to be valid for a set of principal (user/host)
743names.
744By default, generated certificates are valid for all users or hosts.
745To generate a certificate for a specified set of principals:
746.Pp
747.Dl $ ssh-keygen -s ca_key -I key_id -n user1,user2 user_key.pub
748.Dl "$ ssh-keygen -s ca_key -I key_id -h -n host.domain host_key.pub"
749.Pp
750Additional limitations on the validity and use of user certificates may
751be specified through certificate options.
752A certificate option may disable features of the SSH session, may be
753valid only when presented from particular source addresses or may
754force the use of a specific command.
755For a list of valid certificate options, see the documentation for the
756.Fl O
757option above.
758.Pp
759Finally, certificates may be defined with a validity lifetime.
760The
761.Fl V
762option allows specification of certificate start and end times.
763A certificate that is presented at a time outside this range will not be
764considered valid.
765By default, certificates are valid from
766.Ux
767Epoch to the distant future.
768.Pp
769For certificates to be used for user or host authentication, the CA
770public key must be trusted by
771.Xr sshd 8
772or
773.Xr ssh 1 .
774Please refer to those manual pages for details.
775.Sh KEY REVOCATION LISTS
776.Nm
777is able to manage OpenSSH format Key Revocation Lists (KRLs).
778These binary files specify keys or certificates to be revoked using a
779compact format, taking as little as one bit per certificate if they are being
780revoked by serial number.
781.Pp
782KRLs may be generated using the
783.Fl k
784flag.
785This option reads one or more files from the command line and generates a new
786KRL.
787The files may either contain a KRL specification (see below) or public keys,
788listed one per line.
789Plain public keys are revoked by listing their hash or contents in the KRL and
790certificates revoked by serial number or key ID (if the serial is zero or
791not available).
792.Pp
793Revoking keys using a KRL specification offers explicit control over the
794types of record used to revoke keys and may be used to directly revoke
795certificates by serial number or key ID without having the complete original
796certificate on hand.
797A KRL specification consists of lines containing one of the following directives
798followed by a colon and some directive-specific information.
799.Bl -tag -width Ds
800.It Cm serial : Ar serial_number Ns Op - Ns Ar serial_number
801Revokes a certificate with the specified serial number.
802Serial numbers are 64-bit values, not including zero and may be expressed
803in decimal, hex or octal.
804If two serial numbers are specified separated by a hyphen, then the range
805of serial numbers including and between each is revoked.
806The CA key must have been specified on the
807.Nm
808command line using the
809.Fl s
810option.
811.It Cm id : Ar key_id
812Revokes a certificate with the specified key ID string.
813The CA key must have been specified on the
814.Nm
815command line using the
816.Fl s
817option.
818.It Cm key : Ar public_key
819Revokes the specified key.
820If a certificate is listed, then it is revoked as a plain public key.
821.It Cm sha1 : Ar public_key
822Revokes the specified key by its SHA1 hash.
823.El
824.Pp
825KRLs may be updated using the
826.Fl u
827flag in addition to
828.Fl k .
829When this option is specified, keys listed via the command line are merged into
830the KRL, adding to those already there.
831.Pp
832It is also possible, given a KRL, to test whether it revokes a particular key
833(or keys).
834The
835.Fl Q
836flag will query an existing KRL, testing each key specified on the command line.
837If any key listed on the command line has been revoked (or an error encountered)
838then
839.Nm
840will exit with a non-zero exit status.
841A zero exit status will only be returned if no key was revoked.
842.Sh FILES
843.Bl -tag -width Ds -compact
844.It Pa ~/.ssh/id_dsa
845.It Pa ~/.ssh/id_ecdsa
846.It Pa ~/.ssh/id_ed25519
847.It Pa ~/.ssh/id_rsa
848Contains the DSA, ECDSA, Ed25519 or RSA
849authentication identity of the user.
850This file should not be readable by anyone but the user.
851It is possible to
852specify a passphrase when generating the key; that passphrase will be
853used to encrypt the private part of this file using 128-bit AES.
854This file is not automatically accessed by
855.Nm
856but it is offered as the default file for the private key.
857.Xr ssh 1
858will read this file when a login attempt is made.
859.Pp
860.It Pa ~/.ssh/id_dsa.pub
861.It Pa ~/.ssh/id_ecdsa.pub
862.It Pa ~/.ssh/id_ed25519.pub
863.It Pa ~/.ssh/id_rsa.pub
864Contains the DSA, ECDSA, Ed25519 or RSA
865public key for authentication.
866The contents of this file should be added to
867.Pa ~/.ssh/authorized_keys
868on all machines
869where the user wishes to log in using public key authentication.
870There is no need to keep the contents of this file secret.
871.Pp
872.It Pa /etc/moduli
873Contains Diffie-Hellman groups used for DH-GEX.
874The file format is described in
875.Xr moduli 5 .
876.El
877.Sh SEE ALSO
878.Xr ssh 1 ,
879.Xr ssh-add 1 ,
880.Xr ssh-agent 1 ,
881.Xr moduli 5 ,
882.Xr sshd 8
883.Rs
884.%R RFC 4716
885.%T "The Secure Shell (SSH) Public Key File Format"
886.%D 2006
887.Re
888.Sh AUTHORS
889OpenSSH is a derivative of the original and free
890ssh 1.2.12 release by Tatu Ylonen.
891Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos,
892Theo de Raadt and Dug Song
893removed many bugs, re-added newer features and
894created OpenSSH.
895Markus Friedl contributed the support for SSH
896protocol versions 1.5 and 2.0.
897