blob: 980fdf9f0ddcdb09386b4173e747d477fbb7fa84 [file] [log] [blame]
djm@openbsd.org6bff9522019-11-14 21:27:29 +00001.\" $OpenBSD: ssh-keygen.1,v 1.174 2019/11/14 21:27:30 djm Exp $
Damien Miller32aa1441999-10-29 09:15:49 +10002.\"
Damien Miller32aa1441999-10-29 09:15:49 +10003.\" Author: Tatu Ylonen <ylo@cs.hut.fi>
Damien Miller32aa1441999-10-29 09:15:49 +10004.\" Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
5.\" All rights reserved
6.\"
Damien Millere4340be2000-09-16 13:29:08 +11007.\" 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".
Damien Miller32aa1441999-10-29 09:15:49 +100012.\"
Damien Millere4340be2000-09-16 13:29:08 +110013.\"
Ben Lindstrom92a2e382001-03-05 06:59:27 +000014.\" 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.
Damien Millere4340be2000-09-16 13:29:08 +110017.\"
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.
26.\"
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.
Damien Miller32aa1441999-10-29 09:15:49 +100037.\"
djm@openbsd.org6bff9522019-11-14 21:27:29 +000038.Dd $Mdocdate: November 14 2019 $
Damien Miller32aa1441999-10-29 09:15:49 +100039.Dt SSH-KEYGEN 1
40.Os
41.Sh NAME
42.Nm ssh-keygen
Ben Lindstrom5a707822001-04-22 17:15:46 +000043.Nd authentication key generation, management and conversion
Damien Miller32aa1441999-10-29 09:15:49 +100044.Sh SYNOPSIS
Damien Millerbad5e032010-07-16 13:59:59 +100045.Nm ssh-keygen
Damien Miller0bc1bd82000-11-13 22:57:25 +110046.Op Fl q
Damien Miller32aa1441999-10-29 09:15:49 +100047.Op Fl b Ar bits
Damien Miller32aa1441999-10-29 09:15:49 +100048.Op Fl C Ar comment
Damien Miller1a425f32000-09-02 10:08:09 +110049.Op Fl f Ar output_keyfile
djm@openbsd.orgecd2f332019-01-22 11:40:42 +000050.Op Fl m Ar format
naddy@openbsd.orgaa4c6402019-11-07 08:38:38 +000051.Op Fl t Cm dsa | ecdsa | ecdsa-sk | ed25519 | rsa
jmc@openbsd.org69189742019-10-03 17:07:50 +000052.Op Fl N Ar new_passphrase
naddy@openbsd.orgaa4c6402019-11-07 08:38:38 +000053.Op Fl w Ar provider
54.Op Fl x Ar flags
Damien Miller32aa1441999-10-29 09:15:49 +100055.Nm ssh-keygen
56.Fl p
Damien Miller10f6f6b1999-11-17 17:29:08 +110057.Op Fl f Ar keyfile
djm@openbsd.orgecd2f332019-01-22 11:40:42 +000058.Op Fl m Ar format
jmc@openbsd.org69189742019-10-03 17:07:50 +000059.Op Fl N Ar new_passphrase
60.Op Fl P Ar old_passphrase
Damien Miller32aa1441999-10-29 09:15:49 +100061.Nm ssh-keygen
Ben Lindstrom5a707822001-04-22 17:15:46 +000062.Fl i
Damien Miller1a425f32000-09-02 10:08:09 +110063.Op Fl f Ar input_keyfile
jmc@openbsd.org69189742019-10-03 17:07:50 +000064.Op Fl m Ar key_format
Damien Millere247cc42000-05-07 12:03:14 +100065.Nm ssh-keygen
Ben Lindstrom5a707822001-04-22 17:15:46 +000066.Fl e
Damien Miller1a425f32000-09-02 10:08:09 +110067.Op Fl f Ar input_keyfile
jmc@openbsd.org69189742019-10-03 17:07:50 +000068.Op Fl m Ar key_format
Damien Millere247cc42000-05-07 12:03:14 +100069.Nm ssh-keygen
70.Fl y
Damien Miller1a425f32000-09-02 10:08:09 +110071.Op Fl f Ar input_keyfile
Damien Millere247cc42000-05-07 12:03:14 +100072.Nm ssh-keygen
Damien Miller32aa1441999-10-29 09:15:49 +100073.Fl c
Damien Miller32aa1441999-10-29 09:15:49 +100074.Op Fl C Ar comment
Damien Miller10f6f6b1999-11-17 17:29:08 +110075.Op Fl f Ar keyfile
jmc@openbsd.org69189742019-10-03 17:07:50 +000076.Op Fl P Ar passphrase
Damien Miller10f6f6b1999-11-17 17:29:08 +110077.Nm ssh-keygen
78.Fl l
naddy@openbsd.org6288e3a2015-02-24 15:24:05 +000079.Op Fl v
djm@openbsd.org56d1c832014-12-21 22:27:55 +000080.Op Fl E Ar fingerprint_hash
Ben Lindstrom8fd372b2001-03-12 03:02:17 +000081.Op Fl f Ar input_keyfile
82.Nm ssh-keygen
83.Fl B
Damien Miller1a425f32000-09-02 10:08:09 +110084.Op Fl f Ar input_keyfile
Ben Lindstroma1ec4a92001-08-06 21:51:34 +000085.Nm ssh-keygen
Damien Miller048dc932010-02-12 09:22:04 +110086.Fl D Ar pkcs11
Ben Lindstroma1ec4a92001-08-06 21:51:34 +000087.Nm ssh-keygen
Damien Miller4b42d7f2005-03-01 21:48:35 +110088.Fl F Ar hostname
jmc@openbsd.org6c91d422019-09-29 16:31:57 +000089.Op Fl lv
Damien Miller4b42d7f2005-03-01 21:48:35 +110090.Op Fl f Ar known_hosts_file
91.Nm ssh-keygen
92.Fl H
93.Op Fl f Ar known_hosts_file
94.Nm ssh-keygen
95.Fl R Ar hostname
96.Op Fl f Ar known_hosts_file
97.Nm ssh-keygen
Damien Miller37876e92003-05-15 10:19:46 +100098.Fl r Ar hostname
Damien Miller37876e92003-05-15 10:19:46 +100099.Op Fl g
jmc@openbsd.org6c91d422019-09-29 16:31:57 +0000100.Op Fl f Ar input_keyfile
Darren Tucker019cefe2003-08-02 22:40:07 +1000101.Nm ssh-keygen
102.Fl G Ar output_file
Darren Tucker06930c72003-12-31 11:34:51 +1100103.Op Fl v
Darren Tucker019cefe2003-08-02 22:40:07 +1000104.Op Fl b Ar bits
105.Op Fl M Ar memory
106.Op Fl S Ar start_point
107.Nm ssh-keygen
Darren Tucker019cefe2003-08-02 22:40:07 +1000108.Fl f Ar input_file
jmc@openbsd.org69189742019-10-03 17:07:50 +0000109.Fl T Ar output_file
Darren Tucker06930c72003-12-31 11:34:51 +1100110.Op Fl v
Damien Miller4f752cf2013-12-18 17:45:35 +1100111.Op Fl a Ar rounds
Damien Millerdfceafe2012-07-06 13:44:19 +1000112.Op Fl J Ar num_lines
113.Op Fl j Ar start_line
Damien Miller390d0562011-10-18 16:05:19 +1100114.Op Fl K Ar checkpt
Darren Tucker019cefe2003-08-02 22:40:07 +1000115.Op Fl W Ar generator
Damien Miller0a80ca12010-02-27 07:55:05 +1100116.Nm ssh-keygen
Damien Miller0a80ca12010-02-27 07:55:05 +1100117.Fl I Ar certificate_identity
jmc@openbsd.org69189742019-10-03 17:07:50 +0000118.Fl s Ar ca_key
jmc@openbsd.org6c91d422019-09-29 16:31:57 +0000119.Op Fl hU
djm@openbsd.orga98339e2017-06-28 01:09:22 +0000120.Op Fl D Ar pkcs11_provider
Damien Miller0a80ca12010-02-27 07:55:05 +1100121.Op Fl n Ar principals
Damien Miller4e270b02010-04-16 15:56:21 +1000122.Op Fl O Ar option
Damien Miller0a80ca12010-02-27 07:55:05 +1100123.Op Fl V Ar validity_interval
Damien Miller4e270b02010-04-16 15:56:21 +1000124.Op Fl z Ar serial_number
Damien Miller0a80ca12010-02-27 07:55:05 +1100125.Ar
Damien Millerf2b70ca2010-03-05 07:39:35 +1100126.Nm ssh-keygen
Damien Millerf2b70ca2010-03-05 07:39:35 +1100127.Fl L
128.Op Fl f Ar input_keyfile
Damien Miller58f1baf2011-05-05 14:06:15 +1000129.Nm ssh-keygen
130.Fl A
djm@openbsd.org853edbe2017-07-07 03:53:12 +0000131.Op Fl f Ar prefix_path
Damien Millerf3747bf2013-01-18 11:44:04 +1100132.Nm ssh-keygen
133.Fl k
134.Fl f Ar krl_file
135.Op Fl u
Damien Millerac5542b2013-01-20 22:33:02 +1100136.Op Fl s Ar ca_public
137.Op Fl z Ar version_number
Damien Millerf3747bf2013-01-18 11:44:04 +1100138.Ar
139.Nm ssh-keygen
140.Fl Q
141.Fl f Ar krl_file
142.Ar
djm@openbsd.org2a9c9f72019-09-03 08:34:19 +0000143.Nm ssh-keygen
jmc@openbsd.org69189742019-10-03 17:07:50 +0000144.Fl Y Cm check-novalidate
145.Fl n Ar namespace
146.Fl s Ar signature_file
147.Nm ssh-keygen
djm@openbsd.org2a9c9f72019-09-03 08:34:19 +0000148.Fl Y Cm sign
149.Fl f Ar key_file
150.Fl n Ar namespace
151.Ar
152.Nm ssh-keygen
153.Fl Y Cm verify
djm@openbsd.org8aa2aa32019-09-16 03:23:02 +0000154.Fl f Ar allowed_signers_file
jmc@openbsd.org69189742019-10-03 17:07:50 +0000155.Fl I Ar signer_identity
djm@openbsd.org2a9c9f72019-09-03 08:34:19 +0000156.Fl n Ar namespace
157.Fl s Ar signature_file
158.Op Fl r Ar revocation_file
Damien Miller22c77262000-04-13 12:26:34 +1000159.Sh DESCRIPTION
Damien Miller32aa1441999-10-29 09:15:49 +1000160.Nm
Ben Lindstrom5a707822001-04-22 17:15:46 +0000161generates, manages and converts authentication keys for
Damien Miller32aa1441999-10-29 09:15:49 +1000162.Xr ssh 1 .
Damien Millere247cc42000-05-07 12:03:14 +1000163.Nm
jmc@openbsd.org2b6f7992017-05-03 06:32:02 +0000164can create keys for use by SSH protocol version 2.
jmc@openbsd.orga685ae82016-02-17 07:38:19 +0000165.Pp
Damien Millerfbf486b2003-05-23 18:44:23 +1000166The type of key to be generated is specified with the
Damien Miller0bc1bd82000-11-13 22:57:25 +1100167.Fl t
Damien Millera41c8b12002-01-22 23:05:08 +1100168option.
Damien Millerf14be5c2005-11-05 15:15:49 +1100169If invoked without any arguments,
170.Nm
naddy@openbsd.org2e9c3242017-05-05 10:41:58 +0000171will generate an RSA key.
Damien Millere247cc42000-05-07 12:03:14 +1000172.Pp
Darren Tucker019cefe2003-08-02 22:40:07 +1000173.Nm
174is also used to generate groups for use in Diffie-Hellman group
175exchange (DH-GEX).
176See the
177.Sx MODULI GENERATION
178section for details.
179.Pp
Damien Millerf3747bf2013-01-18 11:44:04 +1100180Finally,
181.Nm
182can be used to generate and update Key Revocation Lists, and to test whether
Damien Millerac5542b2013-01-20 22:33:02 +1100183given keys have been revoked by one.
184See the
Damien Millerf3747bf2013-01-18 11:44:04 +1100185.Sx KEY REVOCATION LISTS
186section for details.
187.Pp
Damien Miller32aa1441999-10-29 09:15:49 +1000188Normally each user wishing to use SSH
Damien Millereb8b60e2010-08-31 22:41:14 +1000189with public key authentication runs this once to create the authentication
Damien Miller32aa1441999-10-29 09:15:49 +1000190key in
Damien Miller8ba0ead2013-12-18 17:46:27 +1100191.Pa ~/.ssh/id_dsa ,
Damien Millereb8b60e2010-08-31 22:41:14 +1000192.Pa ~/.ssh/id_ecdsa ,
naddy@openbsd.orgaa4c6402019-11-07 08:38:38 +0000193.Pa ~/.ssh/id_ecdsa_sk ,
Damien Miller8ba0ead2013-12-18 17:46:27 +1100194.Pa ~/.ssh/id_ed25519
Damien Millere247cc42000-05-07 12:03:14 +1000195or
Damien Miller167ea5d2005-05-26 12:04:02 +1000196.Pa ~/.ssh/id_rsa .
Damien Millere247cc42000-05-07 12:03:14 +1000197Additionally, the system administrator may use this to generate host keys,
198as seen in
199.Pa /etc/rc .
Damien Miller32aa1441999-10-29 09:15:49 +1000200.Pp
201Normally this program generates the key and asks for a file in which
Damien Miller450a7a12000-03-26 13:04:51 +1000202to store the private key.
203The public key is stored in a file with the same name but
Damien Miller32aa1441999-10-29 09:15:49 +1000204.Dq .pub
Damien Miller450a7a12000-03-26 13:04:51 +1000205appended.
206The program also asks for a passphrase.
207The passphrase may be empty to indicate no passphrase
Ben Lindstrombf555ba2001-01-18 02:04:35 +0000208(host keys must have an empty passphrase), or it may be a string of
Damien Miller450a7a12000-03-26 13:04:51 +1000209arbitrary length.
Ben Lindstrom4e366d52001-12-06 16:43:21 +0000210A passphrase is similar to a password, except it can be a phrase with a
211series of words, punctuation, numbers, whitespace, or any string of
212characters you want.
213Good passphrases are 10-30 characters long, are
Damien Miller32aa1441999-10-29 09:15:49 +1000214not simple sentences or otherwise easily guessable (English
Ben Lindstrom2a097a42001-06-09 01:13:40 +0000215prose has only 1-2 bits of entropy per character, and provides very bad
Ben Lindstrom4e366d52001-12-06 16:43:21 +0000216passphrases), and contain a mix of upper and lowercase letters,
217numbers, and non-alphanumeric characters.
Damien Miller450a7a12000-03-26 13:04:51 +1000218The passphrase can be changed later by using the
Damien Miller32aa1441999-10-29 09:15:49 +1000219.Fl p
220option.
221.Pp
Damien Miller450a7a12000-03-26 13:04:51 +1000222There is no way to recover a lost passphrase.
Damien Miller085c90f2011-05-05 14:15:33 +1000223If the passphrase is lost or forgotten, a new key must be generated
224and the corresponding public key copied to other machines.
Damien Miller32aa1441999-10-29 09:15:49 +1000225.Pp
djm@openbsd.orgc45616a2019-01-22 11:00:15 +0000226.Nm
227will by default write keys in an OpenSSH-specific format.
228This format is preferred as it offers better protection for
229keys at rest as well as allowing storage of key comments within
230the private key file itself.
231The key comment may be useful to help identify the key.
Damien Miller450a7a12000-03-26 13:04:51 +1000232The comment is initialized to
Damien Miller32aa1441999-10-29 09:15:49 +1000233.Dq user@host
234when the key is created, but can be changed using the
235.Fl c
236option.
237.Pp
djm@openbsd.orgc45616a2019-01-22 11:00:15 +0000238It is still possible for
239.Nm
240to write the previously-used PEM format private keys using the
241.Fl m
242flag.
243This may be used when generating new keys, and existing new-format
244keys may be converted using this option in conjunction with the
245.Fl p
246(change passphrase) flag.
247.Pp
Damien Millere247cc42000-05-07 12:03:14 +1000248After a key is generated, instructions below detail where the keys
249should be placed to be activated.
250.Pp
Damien Miller32aa1441999-10-29 09:15:49 +1000251The options are as follows:
252.Bl -tag -width Ds
Damien Miller58f1baf2011-05-05 14:06:15 +1000253.It Fl A
naddy@openbsd.orgaa4c6402019-11-07 08:38:38 +0000254For each of the key types (rsa, dsa, ecdsa, ecdsa-sk and ed25519)
Damien Miller8ba0ead2013-12-18 17:46:27 +1100255for which host keys
Damien Miller58f1baf2011-05-05 14:06:15 +1000256do not exist, generate the host keys with the default key file path,
257an empty passphrase, default bits for the key type, and default comment.
jmc@openbsd.orgdc44dd32017-07-08 18:32:54 +0000258If
djm@openbsd.org853edbe2017-07-07 03:53:12 +0000259.Fl f
jmc@openbsd.orgdc44dd32017-07-08 18:32:54 +0000260has also been specified, its argument is used as a prefix to the
djm@openbsd.org853edbe2017-07-07 03:53:12 +0000261default path for the resulting host key files.
Damien Miller3ca1eb32011-05-05 14:13:50 +1000262This is used by
Damien Miller58f1baf2011-05-05 14:06:15 +1000263.Pa /etc/rc
264to generate new host keys.
Damien Miller4f752cf2013-12-18 17:45:35 +1100265.It Fl a Ar rounds
jmc@openbsd.org3b44bf32019-09-27 20:03:24 +0000266When saving a private key, this option specifies the number of KDF
djm@openbsd.orged7bd5d2018-08-08 01:16:01 +0000267(key derivation function) rounds used.
Damien Miller4f752cf2013-12-18 17:45:35 +1100268Higher numbers result in slower passphrase verification and increased
269resistance to brute-force password cracking (should the keys be stolen).
270.Pp
jmc@openbsd.org2b6f7992017-05-03 06:32:02 +0000271When screening DH-GEX candidates (using the
Darren Tucker019cefe2003-08-02 22:40:07 +1000272.Fl T
jmc@openbsd.org3b44bf32019-09-27 20:03:24 +0000273command),
274this option specifies the number of primality tests to perform.
Damien Miller265d3092005-03-02 12:05:06 +1100275.It Fl B
276Show the bubblebabble digest of specified private or public key file.
Damien Miller32aa1441999-10-29 09:15:49 +1000277.It Fl b Ar bits
Damien Miller450a7a12000-03-26 13:04:51 +1000278Specifies the number of bits in the key to create.
dtucker@openbsd.orgd7c6e382019-04-19 05:47:44 +0000279For RSA keys, the minimum size is 1024 bits and the default is 3072 bits.
280Generally, 3072 bits is considered sufficient.
Darren Tucker9f647332005-11-28 16:41:46 +1100281DSA keys must be exactly 1024 bits as specified by FIPS 186-2.
Damien Millerad210322011-05-05 14:15:54 +1000282For ECDSA keys, the
283.Fl b
Damien Miller6232a162011-09-22 21:36:00 +1000284flag determines the key length by selecting from one of three elliptic
Damien Millerad210322011-05-05 14:15:54 +1000285curve sizes: 256, 384 or 521 bits.
286Attempting to use bit lengths other than these three values for ECDSA keys
287will fail.
naddy@openbsd.orgaa4c6402019-11-07 08:38:38 +0000288ECDSA-SK and Ed25519 keys have a fixed length and the
Damien Miller8ba0ead2013-12-18 17:46:27 +1100289.Fl b
290flag will be ignored.
Damien Miller265d3092005-03-02 12:05:06 +1100291.It Fl C Ar comment
292Provides a new comment.
Damien Miller32aa1441999-10-29 09:15:49 +1000293.It Fl c
294Requests changing the comment in the private and public key files.
295The program will prompt for the file containing the private keys, for
Ben Lindstromaafff9c2001-05-06 03:01:02 +0000296the passphrase if the key has one, and for the new comment.
Damien Miller7ea845e2010-02-12 09:21:02 +1100297.It Fl D Ar pkcs11
naddy@openbsd.orgc13b7452019-03-05 16:17:12 +0000298Download the public keys provided by the PKCS#11 shared library
Damien Millera7618442010-02-12 09:26:02 +1100299.Ar pkcs11 .
Damien Miller757f34e2010-08-05 13:05:31 +1000300When used in combination with
301.Fl s ,
302this option indicates that a CA key resides in a PKCS#11 token (see the
303.Sx CERTIFICATES
304section for details).
djm@openbsd.org56d1c832014-12-21 22:27:55 +0000305.It Fl E Ar fingerprint_hash
306Specifies the hash algorithm used when displaying key fingerprints.
307Valid options are:
308.Dq md5
309and
310.Dq sha256 .
311The default is
312.Dq sha256 .
Ben Lindstrom5a707822001-04-22 17:15:46 +0000313.It Fl e
Ben Lindstrom46c264f2001-04-24 16:56:58 +0000314This option will read a private or public OpenSSH key file and
djm@openbsd.org180b5202019-01-22 11:19:42 +0000315print to stdout a public key in one of the formats specified by the
Damien Miller44b25042010-07-02 13:35:01 +1000316.Fl m
317option.
318The default export format is
319.Dq RFC4716 .
Damien Millerea727282010-07-02 13:35:34 +1000320This option allows exporting OpenSSH keys for use by other programs, including
Damien Miller44b25042010-07-02 13:35:01 +1000321several commercial SSH implementations.
djm@openbsd.org737e4ed2018-12-07 03:32:26 +0000322.It Fl F Ar hostname | [hostname]:port
Damien Miller265d3092005-03-02 12:05:06 +1100323Search for the specified
324.Ar hostname
djm@openbsd.org737e4ed2018-12-07 03:32:26 +0000325(with optional port number)
Damien Miller265d3092005-03-02 12:05:06 +1100326in a
327.Pa known_hosts
328file, listing any occurrences found.
329This option is useful to find hashed host names or addresses and may also be
330used in conjunction with the
331.Fl H
332option to print found keys in a hashed format.
333.It Fl f Ar filename
334Specifies the filename of the key file.
335.It Fl G Ar output_file
336Generate candidate primes for DH-GEX.
337These primes must be screened for
338safety (using the
339.Fl T
340option) before use.
Damien Miller37876e92003-05-15 10:19:46 +1000341.It Fl g
Darren Tucker0b42e6d2004-08-13 21:22:40 +1000342Use generic DNS format when printing fingerprint resource records using the
Darren Tucker6e370372004-08-13 21:23:25 +1000343.Fl r
Darren Tucker0b42e6d2004-08-13 21:22:40 +1000344command.
Damien Miller265d3092005-03-02 12:05:06 +1100345.It Fl H
346Hash a
347.Pa known_hosts
Darren Tuckerda1adbc2005-03-14 23:15:58 +1100348file.
349This replaces all hostnames and addresses with hashed representations
350within the specified file; the original content is moved to a file with
351a .old suffix.
Damien Miller265d3092005-03-02 12:05:06 +1100352These hashes may be used normally by
353.Nm ssh
354and
355.Nm sshd ,
356but they do not reveal identifying information should the file's contents
357be disclosed.
358This option will not modify existing hashed hostnames and is therefore safe
359to use on files that mix hashed and non-hashed names.
Damien Miller0a80ca12010-02-27 07:55:05 +1100360.It Fl h
361When signing a key, create a host certificate instead of a user
362certificate.
363Please see the
364.Sx CERTIFICATES
365section for details.
Damien Miller15f5b562010-03-03 10:25:21 +1100366.It Fl I Ar certificate_identity
Damien Miller0a80ca12010-02-27 07:55:05 +1100367Specify the key identity when signing a public key.
368Please see the
369.Sx CERTIFICATES
370section for details.
Ben Lindstrom5a707822001-04-22 17:15:46 +0000371.It Fl i
372This option will read an unencrypted private (or public) key file
Damien Miller44b25042010-07-02 13:35:01 +1000373in the format specified by the
374.Fl m
375option and print an OpenSSH compatible private
Ben Lindstrom5a707822001-04-22 17:15:46 +0000376(or public) key to stdout.
Damien Miller43b156c2014-04-20 13:23:03 +1000377This option allows importing keys from other software, including several
378commercial SSH implementations.
379The default import format is
380.Dq RFC4716 .
Damien Millerdfceafe2012-07-06 13:44:19 +1000381.It Fl J Ar num_lines
382Exit after screening the specified number of lines
383while performing DH candidate screening using the
384.Fl T
385option.
386.It Fl j Ar start_line
387Start screening at the specified line number
388while performing DH candidate screening using the
389.Fl T
390option.
Damien Miller390d0562011-10-18 16:05:19 +1100391.It Fl K Ar checkpt
392Write the last line processed to the file
393.Ar checkpt
394while performing DH candidate screening using the
395.Fl T
396option.
397This will be used to skip lines in the input file that have already been
398processed if the job is restarted.
Damien Millerf3747bf2013-01-18 11:44:04 +1100399.It Fl k
400Generate a KRL file.
401In this mode,
402.Nm
403will generate a KRL file at the location specified via the
404.Fl f
Damien Miller881a7a22013-01-20 22:34:46 +1100405flag that revokes every key or certificate presented on the command line.
Damien Millerf3747bf2013-01-18 11:44:04 +1100406Keys/certificates to be revoked may be specified by public key file or
407using the format described in the
408.Sx KEY REVOCATION LISTS
409section.
Damien Millerf2b70ca2010-03-05 07:39:35 +1100410.It Fl L
djm@openbsd.org94bc0b72015-11-13 04:34:15 +0000411Prints the contents of one or more certificates.
Damien Miller10f6f6b1999-11-17 17:29:08 +1100412.It Fl l
Darren Tucker35c45532008-06-13 04:43:15 +1000413Show fingerprint of specified public key file.
Damien Millereb5fec62001-11-12 10:52:44 +1100414For RSA and DSA keys
415.Nm
Darren Tuckerf09e8252008-06-13 05:18:03 +1000416tries to find the matching public key file and prints its fingerprint.
417If combined with
418.Fl v ,
jmc@openbsd.org92838842016-05-03 18:38:12 +0000419a visual ASCII art representation of the key is supplied with the
djm@openbsd.orgcdcd9412016-05-03 14:54:08 +0000420fingerprint.
Damien Millerea727282010-07-02 13:35:34 +1000421.It Fl M Ar memory
422Specify the amount of memory to use (in megabytes) when generating
423candidate moduli for DH-GEX.
Damien Miller44b25042010-07-02 13:35:01 +1000424.It Fl m Ar key_format
djm@openbsd.orgecd2f332019-01-22 11:40:42 +0000425Specify a key format for key generation, the
Damien Miller44b25042010-07-02 13:35:01 +1000426.Fl i
djm@openbsd.orgecd2f332019-01-22 11:40:42 +0000427(import),
Damien Miller44b25042010-07-02 13:35:01 +1000428.Fl e
djm@openbsd.orgecd2f332019-01-22 11:40:42 +0000429(export) conversion options, and the
430.Fl p
431change passphrase operation.
432The latter may be used to convert between OpenSSH private key and PEM
433private key formats.
Damien Miller44b25042010-07-02 13:35:01 +1000434The supported key formats are:
435.Dq RFC4716
Damien Millerea727282010-07-02 13:35:34 +1000436(RFC 4716/SSH2 public or private key),
Damien Miller44b25042010-07-02 13:35:01 +1000437.Dq PKCS8
djm@openbsd.orgeb0d8e72019-07-15 13:16:29 +0000438(PKCS8 public or private key)
Damien Miller44b25042010-07-02 13:35:01 +1000439or
440.Dq PEM
441(PEM public key).
djm@openbsd.orgeb0d8e72019-07-15 13:16:29 +0000442By default OpenSSH will write newly-generated private keys in its own
443format, but when converting public keys for export the default format is
Damien Miller44b25042010-07-02 13:35:01 +1000444.Dq RFC4716 .
djm@openbsd.orged7bd5d2018-08-08 01:16:01 +0000445Setting a format of
446.Dq PEM
447when generating or updating a supported private key type will cause the
448key to be stored in the legacy PEM private key format.
Damien Miller265d3092005-03-02 12:05:06 +1100449.It Fl N Ar new_passphrase
450Provides the new passphrase.
Damien Miller0a80ca12010-02-27 07:55:05 +1100451.It Fl n Ar principals
452Specify one or more principals (user or host names) to be included in
453a certificate when signing a key.
454Multiple principals may be specified, separated by commas.
455Please see the
456.Sx CERTIFICATES
457section for details.
Damien Miller4e270b02010-04-16 15:56:21 +1000458.It Fl O Ar option
459Specify a certificate option when signing a key.
Damien Miller0a80ca12010-02-27 07:55:05 +1100460This option may be specified multiple times.
jmc@openbsd.org6b848972017-05-02 07:13:31 +0000461See also the
Damien Miller0a80ca12010-02-27 07:55:05 +1100462.Sx CERTIFICATES
jmc@openbsd.org6b848972017-05-02 07:13:31 +0000463section for further details.
djm@openbsd.org130283d2018-01-25 03:34:43 +0000464.Pp
465At present, no standard options are valid for host keys.
Damien Miller4e270b02010-04-16 15:56:21 +1000466The options that are valid for user certificates are:
jmc@openbsd.org6b848972017-05-02 07:13:31 +0000467.Pp
468.Bl -tag -width Ds -compact
Damien Millerc59e2442010-03-22 05:50:31 +1100469.It Ic clear
470Clear all enabled permissions.
471This is useful for clearing the default set of permissions so permissions may
472be added individually.
jmc@openbsd.org6b848972017-05-02 07:13:31 +0000473.Pp
jmc@openbsd.orgd4084cd2017-04-29 06:06:01 +0000474.It Ic critical : Ns Ar name Ns Op Ns = Ns Ar contents
jmc@openbsd.org6b848972017-05-02 07:13:31 +0000475.It Ic extension : Ns Ar name Ns Op Ns = Ns Ar contents
476Includes an arbitrary certificate critical option or extension.
477The specified
djm@openbsd.org249516e2017-04-29 04:12:25 +0000478.Ar name
jmc@openbsd.orgd4084cd2017-04-29 06:06:01 +0000479should include a domain suffix, e.g.\&
djm@openbsd.org249516e2017-04-29 04:12:25 +0000480.Dq name@example.com .
jmc@openbsd.orgd4084cd2017-04-29 06:06:01 +0000481If
djm@openbsd.org249516e2017-04-29 04:12:25 +0000482.Ar contents
483is specified then it is included as the contents of the extension/option
484encoded as a string, otherwise the extension/option is created with no
485contents (usually indicating a flag).
486Extensions may be ignored by a client or server that does not recognise them,
487whereas unknown critical options will cause the certificate to be refused.
jmc@openbsd.org6b848972017-05-02 07:13:31 +0000488.Pp
489.It Ic force-command Ns = Ns Ar command
490Forces the execution of
491.Ar command
492instead of any shell or command specified by the user when
493the certificate is used for authentication.
494.Pp
495.It Ic no-agent-forwarding
496Disable
497.Xr ssh-agent 1
498forwarding (permitted by default).
499.Pp
500.It Ic no-port-forwarding
501Disable port forwarding (permitted by default).
502.Pp
503.It Ic no-pty
504Disable PTY allocation (permitted by default).
505.Pp
506.It Ic no-user-rc
507Disable execution of
508.Pa ~/.ssh/rc
509by
510.Xr sshd 8
511(permitted by default).
512.Pp
513.It Ic no-x11-forwarding
514Disable X11 forwarding (permitted by default).
515.Pp
516.It Ic permit-agent-forwarding
517Allows
518.Xr ssh-agent 1
519forwarding.
520.Pp
521.It Ic permit-port-forwarding
522Allows port forwarding.
523.Pp
524.It Ic permit-pty
525Allows PTY allocation.
526.Pp
527.It Ic permit-user-rc
528Allows execution of
529.Pa ~/.ssh/rc
530by
531.Xr sshd 8 .
532.Pp
djm@openbsd.org130283d2018-01-25 03:34:43 +0000533.It Ic permit-X11-forwarding
jmc@openbsd.org6b848972017-05-02 07:13:31 +0000534Allows X11 forwarding.
535.Pp
536.It Ic source-address Ns = Ns Ar address_list
537Restrict the source addresses from which the certificate is considered valid.
538The
539.Ar address_list
540is a comma-separated list of one or more address/netmask pairs in CIDR
541format.
542.El
Damien Miller265d3092005-03-02 12:05:06 +1100543.It Fl P Ar passphrase
544Provides the (old) passphrase.
Damien Miller32aa1441999-10-29 09:15:49 +1000545.It Fl p
546Requests changing the passphrase of a private key file instead of
Damien Miller450a7a12000-03-26 13:04:51 +1000547creating a new private key.
548The program will prompt for the file
Damien Miller32aa1441999-10-29 09:15:49 +1000549containing the private key, for the old passphrase, and twice for the
550new passphrase.
Damien Miller072fdcd2013-01-20 22:34:04 +1100551.It Fl Q
552Test whether keys have been revoked in a KRL.
Damien Miller32aa1441999-10-29 09:15:49 +1000553.It Fl q
554Silence
555.Nm ssh-keygen .
djm@openbsd.org63bba572018-12-07 03:33:18 +0000556.It Fl R Ar hostname | [hostname]:port
djm@openbsd.org737e4ed2018-12-07 03:32:26 +0000557Removes all keys belonging to the specified
Damien Miller4b42d7f2005-03-01 21:48:35 +1100558.Ar hostname
djm@openbsd.org737e4ed2018-12-07 03:32:26 +0000559(with optional port number)
Damien Miller4c9c6fd2005-03-02 12:03:43 +1100560from a
Damien Miller4b42d7f2005-03-01 21:48:35 +1100561.Pa known_hosts
562file.
Damien Miller4c9c6fd2005-03-02 12:03:43 +1100563This option is useful to delete hashed hosts (see the
Damien Miller4b42d7f2005-03-01 21:48:35 +1100564.Fl H
565option above).
Damien Miller265d3092005-03-02 12:05:06 +1100566.It Fl r Ar hostname
567Print the SSHFP fingerprint resource record named
568.Ar hostname
569for the specified public key file.
Darren Tucker019cefe2003-08-02 22:40:07 +1000570.It Fl S Ar start
571Specify start point (in hex) when generating candidate moduli for DH-GEX.
Damien Miller0a80ca12010-02-27 07:55:05 +1100572.It Fl s Ar ca_key
573Certify (sign) a public key using the specified CA key.
574Please see the
575.Sx CERTIFICATES
576section for details.
Damien Millerf3747bf2013-01-18 11:44:04 +1100577.Pp
578When generating a KRL,
579.Fl s
Damien Millerac5542b2013-01-20 22:33:02 +1100580specifies a path to a CA public key file used to revoke certificates directly
Damien Millerf3747bf2013-01-18 11:44:04 +1100581by key ID or serial number.
582See the
583.Sx KEY REVOCATION LISTS
584section for details.
Darren Tucker019cefe2003-08-02 22:40:07 +1000585.It Fl T Ar output_file
586Test DH group exchange candidate primes (generated using the
587.Fl G
588option) for safety.
naddy@openbsd.orgaa4c6402019-11-07 08:38:38 +0000589.It Fl t Cm dsa | ecdsa | ecdsa-sk | ed25519 | rsa
Damien Miller265d3092005-03-02 12:05:06 +1100590Specifies the type of key to create.
591The possible values are
Damien Miller6186bbc2010-09-24 22:00:54 +1000592.Dq dsa ,
Damien Miller8ba0ead2013-12-18 17:46:27 +1100593.Dq ecdsa ,
naddy@openbsd.orgaa4c6402019-11-07 08:38:38 +0000594.Dq ecdsa-sk ,
Damien Miller8ba0ead2013-12-18 17:46:27 +1100595.Dq ed25519 ,
Damien Miller265d3092005-03-02 12:05:06 +1100596or
jmc@openbsd.orgf10c0d32017-05-02 17:04:09 +0000597.Dq rsa .
djm@openbsd.org476e3552019-05-20 00:20:35 +0000598.Pp
599This flag may also be used to specify the desired signature type when
jmc@openbsd.org85ceb0e2019-05-20 06:01:59 +0000600signing certificates using an RSA CA key.
djm@openbsd.org476e3552019-05-20 00:20:35 +0000601The available RSA signature variants are
602.Dq ssh-rsa
603(SHA1 signatures, not recommended),
jmc@openbsd.org85ceb0e2019-05-20 06:01:59 +0000604.Dq rsa-sha2-256 ,
605and
djm@openbsd.org476e3552019-05-20 00:20:35 +0000606.Dq rsa-sha2-512
607(the default).
djm@openbsd.orga98339e2017-06-28 01:09:22 +0000608.It Fl U
609When used in combination with
610.Fl s ,
611this option indicates that a CA key resides in a
612.Xr ssh-agent 1 .
613See the
614.Sx CERTIFICATES
615section for more information.
Damien Millerac5542b2013-01-20 22:33:02 +1100616.It Fl u
617Update a KRL.
618When specified with
619.Fl k ,
Damien Miller881a7a22013-01-20 22:34:46 +1100620keys listed via the command line are added to the existing KRL rather than
Damien Millerac5542b2013-01-20 22:33:02 +1100621a new KRL being created.
Damien Miller0a80ca12010-02-27 07:55:05 +1100622.It Fl V Ar validity_interval
623Specify a validity interval when signing a certificate.
624A validity interval may consist of a single time, indicating that the
625certificate is valid beginning now and expiring at that time, or may consist
626of two times separated by a colon to indicate an explicit time interval.
djm@openbsd.org@openbsd.orgd52131a2017-11-03 05:14:04 +0000627.Pp
628The start time may be specified as the string
629.Dq always
630to indicate the certificate has no specified start time,
djm@openbsd.orgbf0fbf22018-03-12 00:52:01 +0000631a date in YYYYMMDD format, a time in YYYYMMDDHHMM[SS] format,
djm@openbsd.org@openbsd.orgd52131a2017-11-03 05:14:04 +0000632a relative time (to the current time) consisting of a minus sign followed by
633an interval in the format described in the
Damien Millerfecfd112013-07-18 16:11:50 +1000634TIME FORMATS section of
Damien Miller77497e12010-03-22 05:50:51 +1100635.Xr sshd_config 5 .
djm@openbsd.org@openbsd.orgd52131a2017-11-03 05:14:04 +0000636.Pp
djm@openbsd.orgbf0fbf22018-03-12 00:52:01 +0000637The end time may be specified as a YYYYMMDD date, a YYYYMMDDHHMM[SS] time,
djm@openbsd.org@openbsd.orgd52131a2017-11-03 05:14:04 +0000638a relative time starting with a plus character or the string
639.Dq forever
640to indicate that the certificate has no expirty date.
Damien Miller0a80ca12010-02-27 07:55:05 +1100641.Pp
642For example:
643.Dq +52w1d
644(valid from now to 52 weeks and one day from now),
645.Dq -4w:+4w
646(valid from four weeks ago to four weeks from now),
647.Dq 20100101123000:20110101123000
648(valid from 12:30 PM, January 1st, 2010 to 12:30 PM, January 1st, 2011),
649.Dq -1d:20110101
650(valid from yesterday to midnight, January 1st, 2011).
djm@openbsd.org@openbsd.orgd52131a2017-11-03 05:14:04 +0000651.Dq -1m:forever
652(valid from one minute ago and never expiring).
Darren Tucker06930c72003-12-31 11:34:51 +1100653.It Fl v
654Verbose mode.
655Causes
656.Nm
657to print debugging messages about its progress.
658This is helpful for debugging moduli generation.
659Multiple
660.Fl v
661options increase the verbosity.
662The maximum is 3.
Damien Miller265d3092005-03-02 12:05:06 +1100663.It Fl W Ar generator
664Specify desired generator when testing candidate moduli for DH-GEX.
naddy@openbsd.orgaa4c6402019-11-07 08:38:38 +0000665.It Fl w Ar provider
666Specifies a path to a security key provider library that will be used when
djm@openbsd.org6bff9522019-11-14 21:27:29 +0000667creating any security key-hosted keys, overriding the default of the
668internal support for USB HID keys.
naddy@openbsd.orgaa4c6402019-11-07 08:38:38 +0000669.It Fl x Ar flags
670Specifies the security key flags to use when enrolling a security key-hosted
671key.
Damien Miller265d3092005-03-02 12:05:06 +1100672.It Fl y
673This option will read a private
674OpenSSH format file and print an OpenSSH public key to stdout.
jmc@openbsd.orgf23d91f2019-09-05 05:47:23 +0000675.It Fl Y Cm sign
djm@openbsd.org2a9c9f72019-09-03 08:34:19 +0000676Cryptographically sign a file or some data using a SSH key.
677When signing,
678.Nm
679accepts zero or more files to sign on the command-line - if no files
680are specified then
681.Nm
682will sign data presented on standard input.
683Signatures are written to the path of the input file with
684.Dq .sig
685appended, or to standard output if the message to be signed was read from
686standard input.
687.Pp
688The key used for signing is specified using the
689.Fl f
690option and may refer to either a private key, or a public key with the private
691half available via
692.Xr ssh-agent 1 .
693An additional signature namespace, used to prevent signature confusion across
694different domains of use (e.g. file signing vs email signing) must be provided
695via the
696.Fl n
697flag.
698Namespaces are arbitrary strings, and may include:
699.Dq file
700for file signing,
701.Dq email
702for email signing.
703For custom uses, it is recommended to use names following a
704NAMESPACE@YOUR.DOMAIN pattern to generate unambiguous namespaces.
jmc@openbsd.orgf23d91f2019-09-05 05:47:23 +0000705.It Fl Y Cm verify
djm@openbsd.org2a9c9f72019-09-03 08:34:19 +0000706Request to verify a signature generated using
707.Nm
jmc@openbsd.orgf23d91f2019-09-05 05:47:23 +0000708.Fl Y Cm sign
djm@openbsd.org2a9c9f72019-09-03 08:34:19 +0000709as described above.
710When verifying a signature,
711.Nm
712accepts a message on standard input and a signature namespace using
713.Fl n .
714A file containing the corresponding signature must also be supplied using the
715.Fl s
716flag, along with the identity of the signer using
717.Fl I
718and a list of allowed signers via the
719.Fl f
720flag.
721The format of the allowed signers file is documented in the
722.Sx ALLOWED SIGNERS
723section below.
724A file containing revoked keys can be passed using the
725.Fl r
jmc@openbsd.orgdb1e6f62019-09-04 05:56:54 +0000726flag.
727The revocation file may be a KRL or a one-per-line list of public keys.
djm@openbsd.org2a9c9f72019-09-03 08:34:19 +0000728Successful verification by an authorized signer is signalled by
729.Nm
jmc@openbsd.org70fc9a62019-10-22 08:50:35 +0000730returning a zero exit status.
djm@openbsd.org8aa2aa32019-09-16 03:23:02 +0000731.It Fl Y Cm check-novalidate
732Checks that a signature generated using
733.Nm
734.Fl Y Cm sign
735has a valid structure.
736This does not validate if a signature comes from an authorized signer.
737When testing a signature,
738.Nm
739accepts a message on standard input and a signature namespace using
740.Fl n .
741A file containing the corresponding signature must also be supplied using the
742.Fl s
jmc@openbsd.org90d4b252019-09-20 18:50:58 +0000743flag.
744Successful testing of the signature is signalled by
djm@openbsd.org8aa2aa32019-09-16 03:23:02 +0000745.Nm
djm@openbsd.org2a9c9f72019-09-03 08:34:19 +0000746returning a zero exit status.
Damien Miller4e270b02010-04-16 15:56:21 +1000747.It Fl z Ar serial_number
748Specifies a serial number to be embedded in the certificate to distinguish
749this certificate from others from the same CA.
djm@openbsd.orgbe063942019-01-23 04:51:02 +0000750If the
751.Ar serial_number
752is prefixed with a
753.Sq +
754character, then the serial number will be incremented for each certificate
755signed on a single command-line.
Damien Miller4e270b02010-04-16 15:56:21 +1000756The default serial number is zero.
Damien Millerf3747bf2013-01-18 11:44:04 +1100757.Pp
758When generating a KRL, the
759.Fl z
760flag is used to specify a KRL version number.
Damien Miller32aa1441999-10-29 09:15:49 +1000761.El
Darren Tucker019cefe2003-08-02 22:40:07 +1000762.Sh MODULI GENERATION
763.Nm
764may be used to generate groups for the Diffie-Hellman Group Exchange
765(DH-GEX) protocol.
766Generating these groups is a two-step process: first, candidate
767primes are generated using a fast, but memory intensive process.
768These candidate primes are then tested for suitability (a CPU-intensive
769process).
770.Pp
771Generation of primes is performed using the
772.Fl G
773option.
774The desired length of the primes may be specified by the
775.Fl b
776option.
777For example:
778.Pp
Damien Miller265d3092005-03-02 12:05:06 +1100779.Dl # ssh-keygen -G moduli-2048.candidates -b 2048
Darren Tucker019cefe2003-08-02 22:40:07 +1000780.Pp
781By default, the search for primes begins at a random point in the
782desired length range.
783This may be overridden using the
784.Fl S
785option, which specifies a different start point (in hex).
786.Pp
Damien Millerdfceafe2012-07-06 13:44:19 +1000787Once a set of candidates have been generated, they must be screened for
Darren Tucker019cefe2003-08-02 22:40:07 +1000788suitability.
789This may be performed using the
790.Fl T
791option.
792In this mode
793.Nm
794will read candidates from standard input (or a file specified using the
795.Fl f
796option).
797For example:
798.Pp
Damien Miller265d3092005-03-02 12:05:06 +1100799.Dl # ssh-keygen -T moduli-2048 -f moduli-2048.candidates
Darren Tucker019cefe2003-08-02 22:40:07 +1000800.Pp
801By default, each candidate will be subjected to 100 primality tests.
802This may be overridden using the
803.Fl a
804option.
805The DH generator value will be chosen automatically for the
806prime under consideration.
807If a specific generator is desired, it may be requested using the
808.Fl W
809option.
Damien Miller265d3092005-03-02 12:05:06 +1100810Valid generator values are 2, 3, and 5.
Darren Tucker019cefe2003-08-02 22:40:07 +1000811.Pp
812Screened DH groups may be installed in
813.Pa /etc/moduli .
814It is important that this file contains moduli of a range of bit lengths and
815that both ends of a connection share common moduli.
Damien Miller0a80ca12010-02-27 07:55:05 +1100816.Sh CERTIFICATES
817.Nm
818supports signing of keys to produce certificates that may be used for
819user or host authentication.
820Certificates consist of a public key, some identity information, zero or
Damien Miller1f181422010-04-18 08:08:03 +1000821more principal (user or host) names and a set of options that
Damien Miller0a80ca12010-02-27 07:55:05 +1100822are signed by a Certification Authority (CA) key.
823Clients or servers may then trust only the CA key and verify its signature
824on a certificate rather than trusting many user/host keys.
825Note that OpenSSH certificates are a different, and much simpler, format to
826the X.509 certificates used in
827.Xr ssl 8 .
828.Pp
829.Nm
830supports two types of certificates: user and host.
831User certificates authenticate users to servers, whereas host certificates
Damien Miller15f5b562010-03-03 10:25:21 +1100832authenticate server hosts to users.
833To generate a user certificate:
Damien Miller0a80ca12010-02-27 07:55:05 +1100834.Pp
835.Dl $ ssh-keygen -s /path/to/ca_key -I key_id /path/to/user_key.pub
836.Pp
837The resultant certificate will be placed in
Damien Miller1b61a282010-03-22 05:55:06 +1100838.Pa /path/to/user_key-cert.pub .
Damien Miller0a80ca12010-02-27 07:55:05 +1100839A host certificate requires the
840.Fl h
841option:
842.Pp
843.Dl $ ssh-keygen -s /path/to/ca_key -I key_id -h /path/to/host_key.pub
844.Pp
845The host certificate will be output to
Damien Miller1b61a282010-03-22 05:55:06 +1100846.Pa /path/to/host_key-cert.pub .
Damien Miller757f34e2010-08-05 13:05:31 +1000847.Pp
848It is possible to sign using a CA key stored in a PKCS#11 token by
849providing the token library using
850.Fl D
851and identifying the CA key by providing its public half as an argument
852to
853.Fl s :
854.Pp
naddy@openbsd.org05291e52015-08-20 19:20:06 +0000855.Dl $ ssh-keygen -s ca_key.pub -D libpkcs11.so -I key_id user_key.pub
Damien Miller757f34e2010-08-05 13:05:31 +1000856.Pp
djm@openbsd.orga98339e2017-06-28 01:09:22 +0000857Similarly, it is possible for the CA key to be hosted in a
858.Xr ssh-agent 1 .
859This is indicated by the
860.Fl U
861flag and, again, the CA key must be identified by its public half.
862.Pp
863.Dl $ ssh-keygen -Us ca_key.pub -I key_id user_key.pub
864.Pp
Damien Miller757f34e2010-08-05 13:05:31 +1000865In all cases,
Damien Miller0a80ca12010-02-27 07:55:05 +1100866.Ar key_id
867is a "key identifier" that is logged by the server when the certificate
868is used for authentication.
869.Pp
870Certificates may be limited to be valid for a set of principal (user/host)
871names.
872By default, generated certificates are valid for all users or hosts.
873To generate a certificate for a specified set of principals:
874.Pp
875.Dl $ ssh-keygen -s ca_key -I key_id -n user1,user2 user_key.pub
naddy@openbsd.org05291e52015-08-20 19:20:06 +0000876.Dl "$ ssh-keygen -s ca_key -I key_id -h -n host.domain host_key.pub"
Damien Miller0a80ca12010-02-27 07:55:05 +1100877.Pp
878Additional limitations on the validity and use of user certificates may
Damien Miller1f181422010-04-18 08:08:03 +1000879be specified through certificate options.
Damien Miller4e270b02010-04-16 15:56:21 +1000880A certificate option may disable features of the SSH session, may be
Damien Miller0a80ca12010-02-27 07:55:05 +1100881valid only when presented from particular source addresses or may
882force the use of a specific command.
Damien Miller4e270b02010-04-16 15:56:21 +1000883For a list of valid certificate options, see the documentation for the
Damien Miller0a80ca12010-02-27 07:55:05 +1100884.Fl O
885option above.
886.Pp
887Finally, certificates may be defined with a validity lifetime.
888The
889.Fl V
890option allows specification of certificate start and end times.
891A certificate that is presented at a time outside this range will not be
892considered valid.
Darren Tucker3ee50c52012-09-06 21:18:11 +1000893By default, certificates are valid from
894.Ux
895Epoch to the distant future.
Damien Miller0a80ca12010-02-27 07:55:05 +1100896.Pp
897For certificates to be used for user or host authentication, the CA
898public key must be trusted by
899.Xr sshd 8
900or
901.Xr ssh 1 .
902Please refer to those manual pages for details.
Damien Millerf3747bf2013-01-18 11:44:04 +1100903.Sh KEY REVOCATION LISTS
904.Nm
905is able to manage OpenSSH format Key Revocation Lists (KRLs).
906These binary files specify keys or certificates to be revoked using a
Damien Miller13797712013-12-29 17:47:14 +1100907compact format, taking as little as one bit per certificate if they are being
Damien Millerf3747bf2013-01-18 11:44:04 +1100908revoked by serial number.
909.Pp
910KRLs may be generated using the
911.Fl k
912flag.
Damien Miller881a7a22013-01-20 22:34:46 +1100913This option reads one or more files from the command line and generates a new
Damien Millerf3747bf2013-01-18 11:44:04 +1100914KRL.
915The files may either contain a KRL specification (see below) or public keys,
916listed one per line.
917Plain public keys are revoked by listing their hash or contents in the KRL and
918certificates revoked by serial number or key ID (if the serial is zero or
919not available).
920.Pp
921Revoking keys using a KRL specification offers explicit control over the
922types of record used to revoke keys and may be used to directly revoke
923certificates by serial number or key ID without having the complete original
924certificate on hand.
925A KRL specification consists of lines containing one of the following directives
926followed by a colon and some directive-specific information.
927.Bl -tag -width Ds
Damien Millera0a7ee82013-01-20 22:35:06 +1100928.It Cm serial : Ar serial_number Ns Op - Ns Ar serial_number
Damien Millerf3747bf2013-01-18 11:44:04 +1100929Revokes a certificate with the specified serial number.
Damien Millerac5542b2013-01-20 22:33:02 +1100930Serial numbers are 64-bit values, not including zero and may be expressed
Damien Millerf3747bf2013-01-18 11:44:04 +1100931in decimal, hex or octal.
932If two serial numbers are specified separated by a hyphen, then the range
933of serial numbers including and between each is revoked.
934The CA key must have been specified on the
935.Nm
Damien Miller881a7a22013-01-20 22:34:46 +1100936command line using the
Damien Millerf3747bf2013-01-18 11:44:04 +1100937.Fl s
938option.
939.It Cm id : Ar key_id
940Revokes a certificate with the specified key ID string.
941The CA key must have been specified on the
942.Nm
Damien Miller881a7a22013-01-20 22:34:46 +1100943command line using the
Damien Millerf3747bf2013-01-18 11:44:04 +1100944.Fl s
945option.
946.It Cm key : Ar public_key
947Revokes the specified key.
Damien Millerac5542b2013-01-20 22:33:02 +1100948If a certificate is listed, then it is revoked as a plain public key.
Damien Millerf3747bf2013-01-18 11:44:04 +1100949.It Cm sha1 : Ar public_key
djm@openbsd.org9405c622018-09-12 01:21:34 +0000950Revokes the specified key by including its SHA1 hash in the KRL.
951.It Cm sha256 : Ar public_key
952Revokes the specified key by including its SHA256 hash in the KRL.
953KRLs that revoke keys by SHA256 hash are not supported by OpenSSH versions
954prior to 7.9.
955.It Cm hash : Ar fingerprint
djm@openbsd.orgf0fcd7e2018-09-12 06:18:59 +0000956Revokes a key using a fingerprint hash, as obtained from a
djm@openbsd.org9405c622018-09-12 01:21:34 +0000957.Xr sshd 8
958authentication log message or the
959.Nm
960.Fl l
961flag.
962Only SHA256 fingerprints are supported here and resultant KRLs are
963not supported by OpenSSH versions prior to 7.9.
Damien Millerf3747bf2013-01-18 11:44:04 +1100964.El
965.Pp
966KRLs may be updated using the
967.Fl u
968flag in addition to
969.Fl k .
Damien Miller881a7a22013-01-20 22:34:46 +1100970When this option is specified, keys listed via the command line are merged into
Damien Millerf3747bf2013-01-18 11:44:04 +1100971the KRL, adding to those already there.
972.Pp
973It is also possible, given a KRL, to test whether it revokes a particular key
974(or keys).
975The
976.Fl Q
jmc@openbsd.org8b290082015-11-05 09:48:05 +0000977flag will query an existing KRL, testing each key specified on the command line.
Damien Miller881a7a22013-01-20 22:34:46 +1100978If any key listed on the command line has been revoked (or an error encountered)
Damien Millerf3747bf2013-01-18 11:44:04 +1100979then
980.Nm
981will exit with a non-zero exit status.
982A zero exit status will only be returned if no key was revoked.
djm@openbsd.org2a9c9f72019-09-03 08:34:19 +0000983.Sh ALLOWED SIGNERS
984When verifying signatures,
985.Nm
986uses a simple list of identities and keys to determine whether a signature
987comes from an authorized source.
988This "allowed signers" file uses a format patterned after the
989AUTHORIZED_KEYS FILE FORMAT described in
jmc@openbsd.orgdb1e6f62019-09-04 05:56:54 +0000990.Xr sshd 8 .
djm@openbsd.org2a9c9f72019-09-03 08:34:19 +0000991Each line of the file contains the following space-separated fields:
992principals, options, keytype, base64-encoded key.
993Empty lines and lines starting with a
994.Ql #
995are ignored as comments.
996.Pp
997The principals field is a pattern-list (See PATTERNS in
998.Xr ssh_config 5 )
999consisting of one or more comma-separated USER@DOMAIN identity patterns
1000that are accepted for signing.
1001When verifying, the identity presented via the
jmc@openbsd.org70fc9a62019-10-22 08:50:35 +00001002.Fl I
1003option must match a principals pattern in order for the corresponding key to be
djm@openbsd.org2a9c9f72019-09-03 08:34:19 +00001004considered acceptable for verification.
1005.Pp
1006The options (if present) consist of comma-separated option specifications.
1007No spaces are permitted, except within double quotes.
1008The following option specifications are supported (note that option keywords
1009are case-insensitive):
1010.Bl -tag -width Ds
1011.It Cm cert-authority
1012Indicates that this key is accepted as a certificate authority (CA) and
1013that certificates signed by this CA may be accepted for verification.
1014.It Cm namespaces="namespace-list"
1015Specifies a pattern-list of namespaces that are accepted for this key.
djm@openbsd.orgd637c4a2019-09-03 08:35:27 +00001016If this option is present, the signature namespace embedded in the
djm@openbsd.org2a9c9f72019-09-03 08:34:19 +00001017signature object and presented on the verification command-line must
1018match the specified list before the key will be considered acceptable.
1019.El
1020.Pp
1021When verifying signatures made by certificates, the expected principal
1022name must match both the principals pattern in the allowed signers file and
1023the principals embedded in the certificate itself.
1024.Pp
1025An example allowed signers file:
1026.Bd -literal -offset 3n
1027# Comments allowed at start of line
1028user1@example.com,user2@example.com ssh-rsa AAAAX1...
1029# A certificate authority, trusted for all principals in a domain.
1030*@example.com cert-authority ssh-ed25519 AAAB4...
1031# A key that is accepted only for file signing.
1032user2@example.com namespaces="file" ssh-ed25519 AAA41...
1033.Ed
naddy@openbsd.orgaa4c6402019-11-07 08:38:38 +00001034.Sh ENVIRONMENT
1035.Bl -tag -width Ds
1036.It Ev SSH_SK_PROVIDER
1037Specifies the path to a security key provider library used to interact with
1038hardware security keys.
1039.El
Damien Miller32aa1441999-10-29 09:15:49 +10001040.Sh FILES
Damien Miller6186bbc2010-09-24 22:00:54 +10001041.Bl -tag -width Ds -compact
Damien Miller167ea5d2005-05-26 12:04:02 +10001042.It Pa ~/.ssh/id_dsa
Damien Miller6186bbc2010-09-24 22:00:54 +10001043.It Pa ~/.ssh/id_ecdsa
naddy@openbsd.orgaa4c6402019-11-07 08:38:38 +00001044.It Pa ~/.ssh/id_ecdsa_sk
Damien Miller8ba0ead2013-12-18 17:46:27 +11001045.It Pa ~/.ssh/id_ed25519
Damien Miller167ea5d2005-05-26 12:04:02 +10001046.It Pa ~/.ssh/id_rsa
naddy@openbsd.orgaa4c6402019-11-07 08:38:38 +00001047Contains the DSA, ECDSA, security key-hosted ECDSA, Ed25519 or RSA
Damien Miller8ba0ead2013-12-18 17:46:27 +11001048authentication identity of the user.
Ben Lindstrom18a82ac2001-04-11 15:59:35 +00001049This file should not be readable by anyone but the user.
1050It is possible to
1051specify a passphrase when generating the key; that passphrase will be
Darren Tucker199ee6f2009-10-24 11:50:17 +11001052used to encrypt the private part of this file using 128-bit AES.
Ben Lindstrom18a82ac2001-04-11 15:59:35 +00001053This file is not automatically accessed by
1054.Nm
1055but it is offered as the default file for the private key.
Ben Lindstrombda98b02001-07-04 03:35:24 +00001056.Xr ssh 1
Ben Lindstrom18a82ac2001-04-11 15:59:35 +00001057will read this file when a login attempt is made.
Damien Miller6186bbc2010-09-24 22:00:54 +10001058.Pp
1059.It Pa ~/.ssh/id_dsa.pub
1060.It Pa ~/.ssh/id_ecdsa.pub
naddy@openbsd.orgaa4c6402019-11-07 08:38:38 +00001061.It Pa ~/.ssh/id_ecdsa_sk.pub
Damien Miller8ba0ead2013-12-18 17:46:27 +11001062.It Pa ~/.ssh/id_ed25519.pub
Damien Miller167ea5d2005-05-26 12:04:02 +10001063.It Pa ~/.ssh/id_rsa.pub
naddy@openbsd.orgaa4c6402019-11-07 08:38:38 +00001064Contains the DSA, ECDSA, security key-hosted ECDSA, Ed25519 or RSA
Damien Miller8ba0ead2013-12-18 17:46:27 +11001065public key for authentication.
Damien Millere247cc42000-05-07 12:03:14 +10001066The contents of this file should be added to
Damien Miller167ea5d2005-05-26 12:04:02 +10001067.Pa ~/.ssh/authorized_keys
Damien Millere247cc42000-05-07 12:03:14 +10001068on all machines
Ben Lindstrom594e2032001-09-12 18:35:30 +00001069where the user wishes to log in using public key authentication.
Damien Millere247cc42000-05-07 12:03:14 +10001070There is no need to keep the contents of this file secret.
Damien Miller6186bbc2010-09-24 22:00:54 +10001071.Pp
Darren Tucker019cefe2003-08-02 22:40:07 +10001072.It Pa /etc/moduli
1073Contains Diffie-Hellman groups used for DH-GEX.
1074The file format is described in
1075.Xr moduli 5 .
Damien Miller37023962000-07-11 17:31:38 +10001076.El
Damien Miller32aa1441999-10-29 09:15:49 +10001077.Sh SEE ALSO
1078.Xr ssh 1 ,
1079.Xr ssh-add 1 ,
Damien Miller2e8b1c81999-11-15 23:33:56 +11001080.Xr ssh-agent 1 ,
Darren Tucker019cefe2003-08-02 22:40:07 +10001081.Xr moduli 5 ,
Ben Lindstrom77788dc2001-02-10 23:10:33 +00001082.Xr sshd 8
Ben Lindstrom5a707822001-04-22 17:15:46 +00001083.Rs
Damien Millerc0367fb2007-01-05 16:25:46 +11001084.%R RFC 4716
1085.%T "The Secure Shell (SSH) Public Key File Format"
1086.%D 2006
Ben Lindstrom5a707822001-04-22 17:15:46 +00001087.Re
Damien Millerf1ce5052003-06-11 22:04:39 +10001088.Sh AUTHORS
1089OpenSSH is a derivative of the original and free
1090ssh 1.2.12 release by Tatu Ylonen.
1091Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos,
1092Theo de Raadt and Dug Song
1093removed many bugs, re-added newer features and
1094created OpenSSH.
1095Markus Friedl contributed the support for SSH
1096protocol versions 1.5 and 2.0.