blob: 059c1b0341e8436b53876275cb13e1bdb3a8ac7b [file] [log] [blame]
djm@openbsd.org6ec74572020-04-03 02:26:56 +00001.\" $OpenBSD: ssh-keygen.1,v 1.203 2020/04/03 02:26:56 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.org6ec74572020-04-03 02:26:56 +000038.Dd $Mdocdate: April 3 2020 $
Damien Miller32aa1441999-10-29 09:15:49 +100039.Dt SSH-KEYGEN 1
40.Os
41.Sh NAME
42.Nm ssh-keygen
jmc@openbsd.org483cc722019-11-30 07:07:59 +000043.Nd OpenSSH authentication key utility
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
djm@openbsd.org97dc5d12019-11-18 04:50:45 +000051.Op Fl t Cm dsa | ecdsa | ecdsa-sk | ed25519 | ed25519-sk | rsa
jmc@openbsd.org69189742019-10-03 17:07:50 +000052.Op Fl N Ar new_passphrase
naddy@openbsd.org0d005d62020-01-14 15:07:30 +000053.Op Fl O Ar option
naddy@openbsd.orgaa4c6402019-11-07 08:38:38 +000054.Op Fl w Ar provider
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
djm@openbsd.org90399712020-01-02 22:40:09 +000095.Fl K
96.Op Fl w Ar provider
97.Nm ssh-keygen
Damien Miller4b42d7f2005-03-01 21:48:35 +110098.Fl R Ar hostname
99.Op Fl f Ar known_hosts_file
100.Nm ssh-keygen
Damien Miller37876e92003-05-15 10:19:46 +1000101.Fl r Ar hostname
Damien Miller37876e92003-05-15 10:19:46 +1000102.Op Fl g
jmc@openbsd.org6c91d422019-09-29 16:31:57 +0000103.Op Fl f Ar input_keyfile
Darren Tucker019cefe2003-08-02 22:40:07 +1000104.Nm ssh-keygen
djm@openbsd.org3e60d182019-12-30 03:30:09 +0000105.Fl M Cm generate
106.Op Fl O Ar option
naddy@openbsd.org0d005d62020-01-14 15:07:30 +0000107.Ar output_file
Darren Tucker019cefe2003-08-02 22:40:07 +1000108.Nm ssh-keygen
djm@openbsd.org3e60d182019-12-30 03:30:09 +0000109.Fl M Cm screen
naddy@openbsd.org0d005d62020-01-14 15:07:30 +0000110.Op Fl f Ar input_file
djm@openbsd.org3e60d182019-12-30 03:30:09 +0000111.Op Fl O Ar option
naddy@openbsd.org0d005d62020-01-14 15:07:30 +0000112.Ar output_file
Damien Miller0a80ca12010-02-27 07:55:05 +1100113.Nm ssh-keygen
Damien Miller0a80ca12010-02-27 07:55:05 +1100114.Fl I Ar certificate_identity
jmc@openbsd.org69189742019-10-03 17:07:50 +0000115.Fl s Ar ca_key
jmc@openbsd.org6c91d422019-09-29 16:31:57 +0000116.Op Fl hU
djm@openbsd.orga98339e2017-06-28 01:09:22 +0000117.Op Fl D Ar pkcs11_provider
Damien Miller0a80ca12010-02-27 07:55:05 +1100118.Op Fl n Ar principals
Damien Miller4e270b02010-04-16 15:56:21 +1000119.Op Fl O Ar option
Damien Miller0a80ca12010-02-27 07:55:05 +1100120.Op Fl V Ar validity_interval
Damien Miller4e270b02010-04-16 15:56:21 +1000121.Op Fl z Ar serial_number
Damien Miller0a80ca12010-02-27 07:55:05 +1100122.Ar
Damien Millerf2b70ca2010-03-05 07:39:35 +1100123.Nm ssh-keygen
Damien Millerf2b70ca2010-03-05 07:39:35 +1100124.Fl L
125.Op Fl f Ar input_keyfile
Damien Miller58f1baf2011-05-05 14:06:15 +1000126.Nm ssh-keygen
127.Fl A
djm@openbsd.org853edbe2017-07-07 03:53:12 +0000128.Op Fl f Ar prefix_path
Damien Millerf3747bf2013-01-18 11:44:04 +1100129.Nm ssh-keygen
130.Fl k
131.Fl f Ar krl_file
132.Op Fl u
Damien Millerac5542b2013-01-20 22:33:02 +1100133.Op Fl s Ar ca_public
134.Op Fl z Ar version_number
Damien Millerf3747bf2013-01-18 11:44:04 +1100135.Ar
136.Nm ssh-keygen
137.Fl Q
djm@openbsd.org6ec74572020-04-03 02:26:56 +0000138.Op Fl l
Damien Millerf3747bf2013-01-18 11:44:04 +1100139.Fl f Ar krl_file
140.Ar
djm@openbsd.org2a9c9f72019-09-03 08:34:19 +0000141.Nm ssh-keygen
djm@openbsd.org72a8bea2020-01-23 23:31:52 +0000142.Fl Y Cm find-principals
djm@openbsd.org56cffcc2020-01-23 02:43:48 +0000143.Fl s Ar signature_file
144.Fl f Ar allowed_signers_file
145.Nm ssh-keygen
jmc@openbsd.org69189742019-10-03 17:07:50 +0000146.Fl Y Cm check-novalidate
147.Fl n Ar namespace
148.Fl s Ar signature_file
149.Nm ssh-keygen
djm@openbsd.org2a9c9f72019-09-03 08:34:19 +0000150.Fl Y Cm sign
151.Fl f Ar key_file
152.Fl n Ar namespace
153.Ar
154.Nm ssh-keygen
155.Fl Y Cm verify
djm@openbsd.org8aa2aa32019-09-16 03:23:02 +0000156.Fl f Ar allowed_signers_file
jmc@openbsd.org69189742019-10-03 17:07:50 +0000157.Fl I Ar signer_identity
djm@openbsd.org2a9c9f72019-09-03 08:34:19 +0000158.Fl n Ar namespace
159.Fl s Ar signature_file
160.Op Fl r Ar revocation_file
Damien Miller22c77262000-04-13 12:26:34 +1000161.Sh DESCRIPTION
Damien Miller32aa1441999-10-29 09:15:49 +1000162.Nm
Ben Lindstrom5a707822001-04-22 17:15:46 +0000163generates, manages and converts authentication keys for
Damien Miller32aa1441999-10-29 09:15:49 +1000164.Xr ssh 1 .
Damien Millere247cc42000-05-07 12:03:14 +1000165.Nm
jmc@openbsd.org2b6f7992017-05-03 06:32:02 +0000166can create keys for use by SSH protocol version 2.
jmc@openbsd.orga685ae82016-02-17 07:38:19 +0000167.Pp
Damien Millerfbf486b2003-05-23 18:44:23 +1000168The type of key to be generated is specified with the
Damien Miller0bc1bd82000-11-13 22:57:25 +1100169.Fl t
Damien Millera41c8b12002-01-22 23:05:08 +1100170option.
Damien Millerf14be5c2005-11-05 15:15:49 +1100171If invoked without any arguments,
172.Nm
naddy@openbsd.org2e9c3242017-05-05 10:41:58 +0000173will generate an RSA key.
Damien Millere247cc42000-05-07 12:03:14 +1000174.Pp
Darren Tucker019cefe2003-08-02 22:40:07 +1000175.Nm
176is also used to generate groups for use in Diffie-Hellman group
177exchange (DH-GEX).
178See the
179.Sx MODULI GENERATION
180section for details.
181.Pp
Damien Millerf3747bf2013-01-18 11:44:04 +1100182Finally,
183.Nm
184can be used to generate and update Key Revocation Lists, and to test whether
Damien Millerac5542b2013-01-20 22:33:02 +1100185given keys have been revoked by one.
186See the
Damien Millerf3747bf2013-01-18 11:44:04 +1100187.Sx KEY REVOCATION LISTS
188section for details.
189.Pp
Damien Miller32aa1441999-10-29 09:15:49 +1000190Normally each user wishing to use SSH
Damien Millereb8b60e2010-08-31 22:41:14 +1000191with public key authentication runs this once to create the authentication
Damien Miller32aa1441999-10-29 09:15:49 +1000192key in
Damien Miller8ba0ead2013-12-18 17:46:27 +1100193.Pa ~/.ssh/id_dsa ,
Damien Millereb8b60e2010-08-31 22:41:14 +1000194.Pa ~/.ssh/id_ecdsa ,
naddy@openbsd.orgaa4c6402019-11-07 08:38:38 +0000195.Pa ~/.ssh/id_ecdsa_sk ,
naddy@openbsd.orgf0edda82019-11-18 23:16:49 +0000196.Pa ~/.ssh/id_ed25519 ,
197.Pa ~/.ssh/id_ed25519_sk
Damien Millere247cc42000-05-07 12:03:14 +1000198or
Damien Miller167ea5d2005-05-26 12:04:02 +1000199.Pa ~/.ssh/id_rsa .
Damien Millere247cc42000-05-07 12:03:14 +1000200Additionally, the system administrator may use this to generate host keys,
201as seen in
202.Pa /etc/rc .
Damien Miller32aa1441999-10-29 09:15:49 +1000203.Pp
204Normally this program generates the key and asks for a file in which
Damien Miller450a7a12000-03-26 13:04:51 +1000205to store the private key.
206The public key is stored in a file with the same name but
Damien Miller32aa1441999-10-29 09:15:49 +1000207.Dq .pub
Damien Miller450a7a12000-03-26 13:04:51 +1000208appended.
209The program also asks for a passphrase.
210The passphrase may be empty to indicate no passphrase
Ben Lindstrombf555ba2001-01-18 02:04:35 +0000211(host keys must have an empty passphrase), or it may be a string of
Damien Miller450a7a12000-03-26 13:04:51 +1000212arbitrary length.
Ben Lindstrom4e366d52001-12-06 16:43:21 +0000213A passphrase is similar to a password, except it can be a phrase with a
214series of words, punctuation, numbers, whitespace, or any string of
215characters you want.
216Good passphrases are 10-30 characters long, are
Damien Miller32aa1441999-10-29 09:15:49 +1000217not simple sentences or otherwise easily guessable (English
Ben Lindstrom2a097a42001-06-09 01:13:40 +0000218prose has only 1-2 bits of entropy per character, and provides very bad
Ben Lindstrom4e366d52001-12-06 16:43:21 +0000219passphrases), and contain a mix of upper and lowercase letters,
220numbers, and non-alphanumeric characters.
Damien Miller450a7a12000-03-26 13:04:51 +1000221The passphrase can be changed later by using the
Damien Miller32aa1441999-10-29 09:15:49 +1000222.Fl p
223option.
224.Pp
Damien Miller450a7a12000-03-26 13:04:51 +1000225There is no way to recover a lost passphrase.
Damien Miller085c90f2011-05-05 14:15:33 +1000226If the passphrase is lost or forgotten, a new key must be generated
227and the corresponding public key copied to other machines.
Damien Miller32aa1441999-10-29 09:15:49 +1000228.Pp
djm@openbsd.orgc45616a2019-01-22 11:00:15 +0000229.Nm
230will by default write keys in an OpenSSH-specific format.
231This format is preferred as it offers better protection for
232keys at rest as well as allowing storage of key comments within
233the private key file itself.
234The key comment may be useful to help identify the key.
Damien Miller450a7a12000-03-26 13:04:51 +1000235The comment is initialized to
Damien Miller32aa1441999-10-29 09:15:49 +1000236.Dq user@host
237when the key is created, but can be changed using the
238.Fl c
239option.
240.Pp
djm@openbsd.orgc45616a2019-01-22 11:00:15 +0000241It is still possible for
242.Nm
243to write the previously-used PEM format private keys using the
244.Fl m
245flag.
246This may be used when generating new keys, and existing new-format
247keys may be converted using this option in conjunction with the
248.Fl p
249(change passphrase) flag.
250.Pp
Damien Millere247cc42000-05-07 12:03:14 +1000251After a key is generated, instructions below detail where the keys
252should be placed to be activated.
253.Pp
Damien Miller32aa1441999-10-29 09:15:49 +1000254The options are as follows:
255.Bl -tag -width Ds
Damien Miller58f1baf2011-05-05 14:06:15 +1000256.It Fl A
djm@openbsd.org97dc5d12019-11-18 04:50:45 +0000257For each of the key types (rsa, dsa, ecdsa and ed25519)
Damien Miller8ba0ead2013-12-18 17:46:27 +1100258for which host keys
Damien Miller58f1baf2011-05-05 14:06:15 +1000259do not exist, generate the host keys with the default key file path,
260an empty passphrase, default bits for the key type, and default comment.
jmc@openbsd.orgdc44dd32017-07-08 18:32:54 +0000261If
djm@openbsd.org853edbe2017-07-07 03:53:12 +0000262.Fl f
jmc@openbsd.orgdc44dd32017-07-08 18:32:54 +0000263has also been specified, its argument is used as a prefix to the
djm@openbsd.org853edbe2017-07-07 03:53:12 +0000264default path for the resulting host key files.
Damien Miller3ca1eb32011-05-05 14:13:50 +1000265This is used by
Damien Miller58f1baf2011-05-05 14:06:15 +1000266.Pa /etc/rc
267to generate new host keys.
Damien Miller4f752cf2013-12-18 17:45:35 +1100268.It Fl a Ar rounds
jmc@openbsd.org3b44bf32019-09-27 20:03:24 +0000269When saving a private key, this option specifies the number of KDF
djm@openbsd.orged7bd5d2018-08-08 01:16:01 +0000270(key derivation function) rounds used.
Damien Miller4f752cf2013-12-18 17:45:35 +1100271Higher numbers result in slower passphrase verification and increased
272resistance to brute-force password cracking (should the keys be stolen).
Damien Miller265d3092005-03-02 12:05:06 +1100273.It Fl B
274Show the bubblebabble digest of specified private or public key file.
Damien Miller32aa1441999-10-29 09:15:49 +1000275.It Fl b Ar bits
Damien Miller450a7a12000-03-26 13:04:51 +1000276Specifies the number of bits in the key to create.
dtucker@openbsd.orgd7c6e382019-04-19 05:47:44 +0000277For RSA keys, the minimum size is 1024 bits and the default is 3072 bits.
278Generally, 3072 bits is considered sufficient.
Darren Tucker9f647332005-11-28 16:41:46 +1100279DSA keys must be exactly 1024 bits as specified by FIPS 186-2.
Damien Millerad210322011-05-05 14:15:54 +1000280For ECDSA keys, the
281.Fl b
Damien Miller6232a162011-09-22 21:36:00 +1000282flag determines the key length by selecting from one of three elliptic
Damien Millerad210322011-05-05 14:15:54 +1000283curve sizes: 256, 384 or 521 bits.
284Attempting to use bit lengths other than these three values for ECDSA keys
285will fail.
naddy@openbsd.orgf0edda82019-11-18 23:16:49 +0000286ECDSA-SK, Ed25519 and Ed25519-SK keys have a fixed length and the
Damien Miller8ba0ead2013-12-18 17:46:27 +1100287.Fl b
288flag will be ignored.
Damien Miller265d3092005-03-02 12:05:06 +1100289.It Fl C Ar comment
290Provides a new comment.
Damien Miller32aa1441999-10-29 09:15:49 +1000291.It Fl c
292Requests changing the comment in the private and public key files.
293The program will prompt for the file containing the private keys, for
Ben Lindstromaafff9c2001-05-06 03:01:02 +0000294the passphrase if the key has one, and for the new comment.
Damien Miller7ea845e2010-02-12 09:21:02 +1100295.It Fl D Ar pkcs11
naddy@openbsd.orgc13b7452019-03-05 16:17:12 +0000296Download the public keys provided by the PKCS#11 shared library
Damien Millera7618442010-02-12 09:26:02 +1100297.Ar pkcs11 .
Damien Miller757f34e2010-08-05 13:05:31 +1000298When used in combination with
299.Fl s ,
300this option indicates that a CA key resides in a PKCS#11 token (see the
301.Sx CERTIFICATES
302section for details).
djm@openbsd.org56d1c832014-12-21 22:27:55 +0000303.It Fl E Ar fingerprint_hash
304Specifies the hash algorithm used when displaying key fingerprints.
305Valid options are:
306.Dq md5
307and
308.Dq sha256 .
309The default is
310.Dq sha256 .
Ben Lindstrom5a707822001-04-22 17:15:46 +0000311.It Fl e
Ben Lindstrom46c264f2001-04-24 16:56:58 +0000312This option will read a private or public OpenSSH key file and
djm@openbsd.org180b5202019-01-22 11:19:42 +0000313print to stdout a public key in one of the formats specified by the
Damien Miller44b25042010-07-02 13:35:01 +1000314.Fl m
315option.
316The default export format is
317.Dq RFC4716 .
Damien Millerea727282010-07-02 13:35:34 +1000318This option allows exporting OpenSSH keys for use by other programs, including
Damien Miller44b25042010-07-02 13:35:01 +1000319several commercial SSH implementations.
djm@openbsd.org737e4ed2018-12-07 03:32:26 +0000320.It Fl F Ar hostname | [hostname]:port
Damien Miller265d3092005-03-02 12:05:06 +1100321Search for the specified
322.Ar hostname
djm@openbsd.org737e4ed2018-12-07 03:32:26 +0000323(with optional port number)
Damien Miller265d3092005-03-02 12:05:06 +1100324in a
325.Pa known_hosts
326file, listing any occurrences found.
327This option is useful to find hashed host names or addresses and may also be
328used in conjunction with the
329.Fl H
330option to print found keys in a hashed format.
331.It Fl f Ar filename
332Specifies the filename of the key file.
Damien Miller37876e92003-05-15 10:19:46 +1000333.It Fl g
Darren Tucker0b42e6d2004-08-13 21:22:40 +1000334Use generic DNS format when printing fingerprint resource records using the
Darren Tucker6e370372004-08-13 21:23:25 +1000335.Fl r
Darren Tucker0b42e6d2004-08-13 21:22:40 +1000336command.
Damien Miller265d3092005-03-02 12:05:06 +1100337.It Fl H
338Hash a
339.Pa known_hosts
Darren Tuckerda1adbc2005-03-14 23:15:58 +1100340file.
341This replaces all hostnames and addresses with hashed representations
342within the specified file; the original content is moved to a file with
343a .old suffix.
Damien Miller265d3092005-03-02 12:05:06 +1100344These hashes may be used normally by
345.Nm ssh
346and
347.Nm sshd ,
348but they do not reveal identifying information should the file's contents
349be disclosed.
350This option will not modify existing hashed hostnames and is therefore safe
351to use on files that mix hashed and non-hashed names.
Damien Miller0a80ca12010-02-27 07:55:05 +1100352.It Fl h
353When signing a key, create a host certificate instead of a user
354certificate.
355Please see the
356.Sx CERTIFICATES
357section for details.
Damien Miller15f5b562010-03-03 10:25:21 +1100358.It Fl I Ar certificate_identity
Damien Miller0a80ca12010-02-27 07:55:05 +1100359Specify the key identity when signing a public key.
360Please see the
361.Sx CERTIFICATES
362section for details.
Ben Lindstrom5a707822001-04-22 17:15:46 +0000363.It Fl i
364This option will read an unencrypted private (or public) key file
Damien Miller44b25042010-07-02 13:35:01 +1000365in the format specified by the
366.Fl m
367option and print an OpenSSH compatible private
Ben Lindstrom5a707822001-04-22 17:15:46 +0000368(or public) key to stdout.
Damien Miller43b156c2014-04-20 13:23:03 +1000369This option allows importing keys from other software, including several
370commercial SSH implementations.
371The default import format is
372.Dq RFC4716 .
jmc@openbsd.orgc593cc52020-01-03 07:33:33 +0000373.It Fl K
djm@openbsd.org90399712020-01-02 22:40:09 +0000374Download resident keys from a FIDO authenticator.
375Public and private key files will be written to the current directory for
376each downloaded key.
377.It Fl k
Damien Millerf3747bf2013-01-18 11:44:04 +1100378Generate a KRL file.
379In this mode,
380.Nm
381will generate a KRL file at the location specified via the
382.Fl f
Damien Miller881a7a22013-01-20 22:34:46 +1100383flag that revokes every key or certificate presented on the command line.
Damien Millerf3747bf2013-01-18 11:44:04 +1100384Keys/certificates to be revoked may be specified by public key file or
385using the format described in the
386.Sx KEY REVOCATION LISTS
387section.
Damien Millerf2b70ca2010-03-05 07:39:35 +1100388.It Fl L
djm@openbsd.org94bc0b72015-11-13 04:34:15 +0000389Prints the contents of one or more certificates.
Damien Miller10f6f6b1999-11-17 17:29:08 +1100390.It Fl l
Darren Tucker35c45532008-06-13 04:43:15 +1000391Show fingerprint of specified public key file.
Damien Millereb5fec62001-11-12 10:52:44 +1100392For RSA and DSA keys
393.Nm
Darren Tuckerf09e8252008-06-13 05:18:03 +1000394tries to find the matching public key file and prints its fingerprint.
395If combined with
396.Fl v ,
jmc@openbsd.org92838842016-05-03 18:38:12 +0000397a visual ASCII art representation of the key is supplied with the
djm@openbsd.orgcdcd9412016-05-03 14:54:08 +0000398fingerprint.
djm@openbsd.org3e60d182019-12-30 03:30:09 +0000399.It Fl M Cm generate
400Generate candidate Diffie-Hellman Group Exchange (DH-GEX) parameters for
401eventual use by the
402.Sq diffie-hellman-group-exchange-*
403key exchange methods.
404The numbers generated by this operation must be further screened before
405use.
406See the
407.Sx MODULI GENERATION
408section for more information.
409.It Fl M Cm screen
410Screen candidate parameters for Diffie-Hellman Group Exchange.
411This will accept a list of candidate numbers and test that they are
412safe (Sophie Germain) primes with acceptable group generators.
413The results of this operation may be added to the
414.Pa /etc/moduli
415file.
416See the
417.Sx MODULI GENERATION
418section for more information.
Damien Miller44b25042010-07-02 13:35:01 +1000419.It Fl m Ar key_format
djm@openbsd.orgecd2f332019-01-22 11:40:42 +0000420Specify a key format for key generation, the
Damien Miller44b25042010-07-02 13:35:01 +1000421.Fl i
djm@openbsd.orgecd2f332019-01-22 11:40:42 +0000422(import),
Damien Miller44b25042010-07-02 13:35:01 +1000423.Fl e
djm@openbsd.orgecd2f332019-01-22 11:40:42 +0000424(export) conversion options, and the
425.Fl p
426change passphrase operation.
427The latter may be used to convert between OpenSSH private key and PEM
428private key formats.
Damien Miller44b25042010-07-02 13:35:01 +1000429The supported key formats are:
430.Dq RFC4716
Damien Millerea727282010-07-02 13:35:34 +1000431(RFC 4716/SSH2 public or private key),
Damien Miller44b25042010-07-02 13:35:01 +1000432.Dq PKCS8
djm@openbsd.orgeb0d8e72019-07-15 13:16:29 +0000433(PKCS8 public or private key)
Damien Miller44b25042010-07-02 13:35:01 +1000434or
435.Dq PEM
436(PEM public key).
djm@openbsd.orgeb0d8e72019-07-15 13:16:29 +0000437By default OpenSSH will write newly-generated private keys in its own
438format, but when converting public keys for export the default format is
Damien Miller44b25042010-07-02 13:35:01 +1000439.Dq RFC4716 .
djm@openbsd.orged7bd5d2018-08-08 01:16:01 +0000440Setting a format of
441.Dq PEM
442when generating or updating a supported private key type will cause the
443key to be stored in the legacy PEM private key format.
Damien Miller265d3092005-03-02 12:05:06 +1100444.It Fl N Ar new_passphrase
445Provides the new passphrase.
Damien Miller0a80ca12010-02-27 07:55:05 +1100446.It Fl n Ar principals
447Specify one or more principals (user or host names) to be included in
448a certificate when signing a key.
449Multiple principals may be specified, separated by commas.
450Please see the
451.Sx CERTIFICATES
452section for details.
Damien Miller4e270b02010-04-16 15:56:21 +1000453.It Fl O Ar option
djm@openbsd.org3e60d182019-12-30 03:30:09 +0000454Specify a key/value option.
455These are specific to the operation that
456.Nm
457has been requested to perform.
458.Pp
459When signing certificates, one of the options listed in the
Damien Miller0a80ca12010-02-27 07:55:05 +1100460.Sx CERTIFICATES
djm@openbsd.org3e60d182019-12-30 03:30:09 +0000461section may be specified here.
462.Pp
463When performing moduli generation or screening, one of the options
464listed in the
465.Sx MODULI GENERATION
466section may be specified.
467.Pp
jmc@openbsd.orgcd534762020-01-06 07:43:28 +0000468When generating a key that will be hosted on a FIDO authenticator,
469this flag may be used to specify key-specific options.
470Those supported at present are:
471.Bl -tag -width Ds
472.It Cm application
473Override the default FIDO application/origin string of
djm@openbsd.orgc312ca02020-01-06 02:00:46 +0000474.Dq ssh: .
jmc@openbsd.orgcd534762020-01-06 07:43:28 +0000475This may be useful when generating host or domain-specific resident keys.
djm@openbsd.orgd596b1d2020-02-04 09:58:04 +0000476The specified application string must begin with
477.Dq ssh: .
jmc@openbsd.org072f3b82020-02-03 08:15:37 +0000478.It Cm challenge Ns = Ns Ar path
jmc@openbsd.org0facae72020-02-02 07:36:50 +0000479Specifies a path to a challenge string that will be passed to the
480FIDO token during key generation.
jmc@openbsd.org072f3b82020-02-03 08:15:37 +0000481The challenge string may be used as part of an out-of-band
482protocol for key enrollment
483(a random challenge is used by default).
jmc@openbsd.orgcd534762020-01-06 07:43:28 +0000484.It Cm device
485Explicitly specify a
djm@openbsd.orgc312ca02020-01-06 02:00:46 +0000486.Xr fido 4
487device to use, rather than letting the token middleware select one.
jmc@openbsd.orgcd534762020-01-06 07:43:28 +0000488.It Cm no-touch-required
489Indicate that the generated private key should not require touch
djm@openbsd.org3093d122019-12-30 09:49:52 +0000490events (user presence) when making signatures.
491Note that
492.Xr sshd 8
493will refuse such signatures by default, unless overridden via
494an authorized_keys option.
jmc@openbsd.orgcd534762020-01-06 07:43:28 +0000495.It Cm resident
496Indicate that the key should be stored on the FIDO authenticator itself.
djm@openbsd.org3093d122019-12-30 09:49:52 +0000497Resident keys may be supported on FIDO2 tokens and typically require that
498a PIN be set on the token prior to generation.
499Resident keys may be loaded off the token using
500.Xr ssh-add 1 .
jmc@openbsd.orgcd534762020-01-06 07:43:28 +0000501.It Cm user
502A username to be associated with a resident key,
djm@openbsd.orgc312ca02020-01-06 02:00:46 +0000503overriding the empty default username.
504Specifying a username may be useful when generating multiple resident keys
505for the same application name.
jmc@openbsd.org072f3b82020-02-03 08:15:37 +0000506.It Cm write-attestation Ns = Ns Ar path
djm@openbsd.org24c0f752020-01-28 08:01:34 +0000507May be used at key generation time to record the attestation certificate
508returned from FIDO tokens during key generation.
509By default this information is discarded.
jmc@openbsd.orgcd534762020-01-06 07:43:28 +0000510.El
djm@openbsd.org3093d122019-12-30 09:49:52 +0000511.Pp
512The
513.Fl O
514option may be specified multiple times.
Damien Miller265d3092005-03-02 12:05:06 +1100515.It Fl P Ar passphrase
516Provides the (old) passphrase.
Damien Miller32aa1441999-10-29 09:15:49 +1000517.It Fl p
518Requests changing the passphrase of a private key file instead of
Damien Miller450a7a12000-03-26 13:04:51 +1000519creating a new private key.
520The program will prompt for the file
Damien Miller32aa1441999-10-29 09:15:49 +1000521containing the private key, for the old passphrase, and twice for the
522new passphrase.
Damien Miller072fdcd2013-01-20 22:34:04 +1100523.It Fl Q
524Test whether keys have been revoked in a KRL.
djm@openbsd.org6ec74572020-04-03 02:26:56 +0000525If the
526.Fl l
527option is also specified then the contents of the KRL will be printed.
Damien Miller32aa1441999-10-29 09:15:49 +1000528.It Fl q
529Silence
530.Nm ssh-keygen .
djm@openbsd.org63bba572018-12-07 03:33:18 +0000531.It Fl R Ar hostname | [hostname]:port
djm@openbsd.org737e4ed2018-12-07 03:32:26 +0000532Removes all keys belonging to the specified
Damien Miller4b42d7f2005-03-01 21:48:35 +1100533.Ar hostname
djm@openbsd.org737e4ed2018-12-07 03:32:26 +0000534(with optional port number)
Damien Miller4c9c6fd2005-03-02 12:03:43 +1100535from a
Damien Miller4b42d7f2005-03-01 21:48:35 +1100536.Pa known_hosts
537file.
Damien Miller4c9c6fd2005-03-02 12:03:43 +1100538This option is useful to delete hashed hosts (see the
Damien Miller4b42d7f2005-03-01 21:48:35 +1100539.Fl H
540option above).
Damien Miller265d3092005-03-02 12:05:06 +1100541.It Fl r Ar hostname
542Print the SSHFP fingerprint resource record named
543.Ar hostname
544for the specified public key file.
Damien Miller0a80ca12010-02-27 07:55:05 +1100545.It Fl s Ar ca_key
546Certify (sign) a public key using the specified CA key.
547Please see the
548.Sx CERTIFICATES
549section for details.
Damien Millerf3747bf2013-01-18 11:44:04 +1100550.Pp
551When generating a KRL,
552.Fl s
Damien Millerac5542b2013-01-20 22:33:02 +1100553specifies a path to a CA public key file used to revoke certificates directly
Damien Millerf3747bf2013-01-18 11:44:04 +1100554by key ID or serial number.
555See the
556.Sx KEY REVOCATION LISTS
557section for details.
djm@openbsd.org97dc5d12019-11-18 04:50:45 +0000558.It Fl t Cm dsa | ecdsa | ecdsa-sk | ed25519 | ed25519-sk | rsa
Damien Miller265d3092005-03-02 12:05:06 +1100559Specifies the type of key to create.
560The possible values are
Damien Miller6186bbc2010-09-24 22:00:54 +1000561.Dq dsa ,
Damien Miller8ba0ead2013-12-18 17:46:27 +1100562.Dq ecdsa ,
naddy@openbsd.orgaa4c6402019-11-07 08:38:38 +0000563.Dq ecdsa-sk ,
Damien Miller8ba0ead2013-12-18 17:46:27 +1100564.Dq ed25519 ,
djm@openbsd.org97dc5d12019-11-18 04:50:45 +0000565.Dq ed25519-sk ,
Damien Miller265d3092005-03-02 12:05:06 +1100566or
jmc@openbsd.orgf10c0d32017-05-02 17:04:09 +0000567.Dq rsa .
djm@openbsd.org476e3552019-05-20 00:20:35 +0000568.Pp
569This flag may also be used to specify the desired signature type when
jmc@openbsd.org85ceb0e2019-05-20 06:01:59 +0000570signing certificates using an RSA CA key.
djm@openbsd.org476e3552019-05-20 00:20:35 +0000571The available RSA signature variants are
572.Dq ssh-rsa
573(SHA1 signatures, not recommended),
jmc@openbsd.org85ceb0e2019-05-20 06:01:59 +0000574.Dq rsa-sha2-256 ,
575and
djm@openbsd.org476e3552019-05-20 00:20:35 +0000576.Dq rsa-sha2-512
577(the default).
djm@openbsd.orga98339e2017-06-28 01:09:22 +0000578.It Fl U
579When used in combination with
580.Fl s ,
581this option indicates that a CA key resides in a
582.Xr ssh-agent 1 .
583See the
584.Sx CERTIFICATES
585section for more information.
Damien Millerac5542b2013-01-20 22:33:02 +1100586.It Fl u
587Update a KRL.
588When specified with
589.Fl k ,
Damien Miller881a7a22013-01-20 22:34:46 +1100590keys listed via the command line are added to the existing KRL rather than
Damien Millerac5542b2013-01-20 22:33:02 +1100591a new KRL being created.
Damien Miller0a80ca12010-02-27 07:55:05 +1100592.It Fl V Ar validity_interval
593Specify a validity interval when signing a certificate.
594A validity interval may consist of a single time, indicating that the
595certificate is valid beginning now and expiring at that time, or may consist
596of two times separated by a colon to indicate an explicit time interval.
djm@openbsd.org@openbsd.orgd52131a2017-11-03 05:14:04 +0000597.Pp
598The start time may be specified as the string
599.Dq always
600to indicate the certificate has no specified start time,
djm@openbsd.orgbf0fbf22018-03-12 00:52:01 +0000601a date in YYYYMMDD format, a time in YYYYMMDDHHMM[SS] format,
djm@openbsd.org@openbsd.orgd52131a2017-11-03 05:14:04 +0000602a relative time (to the current time) consisting of a minus sign followed by
603an interval in the format described in the
Damien Millerfecfd112013-07-18 16:11:50 +1000604TIME FORMATS section of
Damien Miller77497e12010-03-22 05:50:51 +1100605.Xr sshd_config 5 .
djm@openbsd.org@openbsd.orgd52131a2017-11-03 05:14:04 +0000606.Pp
djm@openbsd.orgbf0fbf22018-03-12 00:52:01 +0000607The end time may be specified as a YYYYMMDD date, a YYYYMMDDHHMM[SS] time,
djm@openbsd.org@openbsd.orgd52131a2017-11-03 05:14:04 +0000608a relative time starting with a plus character or the string
609.Dq forever
dtucker@openbsd.org7eb903f2020-02-24 04:27:58 +0000610to indicate that the certificate has no expiry date.
Damien Miller0a80ca12010-02-27 07:55:05 +1100611.Pp
612For example:
613.Dq +52w1d
614(valid from now to 52 weeks and one day from now),
615.Dq -4w:+4w
616(valid from four weeks ago to four weeks from now),
617.Dq 20100101123000:20110101123000
618(valid from 12:30 PM, January 1st, 2010 to 12:30 PM, January 1st, 2011),
619.Dq -1d:20110101
620(valid from yesterday to midnight, January 1st, 2011).
djm@openbsd.org@openbsd.orgd52131a2017-11-03 05:14:04 +0000621.Dq -1m:forever
622(valid from one minute ago and never expiring).
Darren Tucker06930c72003-12-31 11:34:51 +1100623.It Fl v
624Verbose mode.
625Causes
626.Nm
627to print debugging messages about its progress.
628This is helpful for debugging moduli generation.
629Multiple
630.Fl v
631options increase the verbosity.
632The maximum is 3.
naddy@openbsd.orgaa4c6402019-11-07 08:38:38 +0000633.It Fl w Ar provider
naddy@openbsd.org141df482019-12-21 20:22:34 +0000634Specifies a path to a library that will be used when creating
635FIDO authenticator-hosted keys, overriding the default of using
636the internal USB HID support.
djm@openbsd.org72a8bea2020-01-23 23:31:52 +0000637.It Fl Y Cm find-principals
638Find the principal(s) associated with the public key of a signature,
djm@openbsd.org56cffcc2020-01-23 02:43:48 +0000639provided using the
640.Fl s
641flag in an authorized signers file provided using the
642.Fl f
643flag.
644The format of the allowed signers file is documented in the
645.Sx ALLOWED SIGNERS
jmc@openbsd.org5533c2f2020-01-23 07:16:38 +0000646section below.
djm@openbsd.org72a8bea2020-01-23 23:31:52 +0000647If one or more matching principals are found, they are returned on
648standard output.
jmc@openbsd.org20ccd852019-12-27 08:28:44 +0000649.It Fl Y Cm check-novalidate
650Checks that a signature generated using
651.Nm
652.Fl Y Cm sign
653has a valid structure.
654This does not validate if a signature comes from an authorized signer.
655When testing a signature,
656.Nm
657accepts a message on standard input and a signature namespace using
658.Fl n .
659A file containing the corresponding signature must also be supplied using the
660.Fl s
661flag.
662Successful testing of the signature is signalled by
663.Nm
664returning a zero exit status.
jmc@openbsd.orgf23d91f2019-09-05 05:47:23 +0000665.It Fl Y Cm sign
djm@openbsd.org2a9c9f72019-09-03 08:34:19 +0000666Cryptographically sign a file or some data using a SSH key.
667When signing,
668.Nm
669accepts zero or more files to sign on the command-line - if no files
670are specified then
671.Nm
672will sign data presented on standard input.
673Signatures are written to the path of the input file with
674.Dq .sig
675appended, or to standard output if the message to be signed was read from
676standard input.
677.Pp
678The key used for signing is specified using the
679.Fl f
680option and may refer to either a private key, or a public key with the private
681half available via
682.Xr ssh-agent 1 .
683An additional signature namespace, used to prevent signature confusion across
684different domains of use (e.g. file signing vs email signing) must be provided
685via the
686.Fl n
687flag.
688Namespaces are arbitrary strings, and may include:
689.Dq file
690for file signing,
691.Dq email
692for email signing.
693For custom uses, it is recommended to use names following a
694NAMESPACE@YOUR.DOMAIN pattern to generate unambiguous namespaces.
jmc@openbsd.orgf23d91f2019-09-05 05:47:23 +0000695.It Fl Y Cm verify
djm@openbsd.org2a9c9f72019-09-03 08:34:19 +0000696Request to verify a signature generated using
697.Nm
jmc@openbsd.orgf23d91f2019-09-05 05:47:23 +0000698.Fl Y Cm sign
djm@openbsd.org2a9c9f72019-09-03 08:34:19 +0000699as described above.
700When verifying a signature,
701.Nm
702accepts a message on standard input and a signature namespace using
703.Fl n .
704A file containing the corresponding signature must also be supplied using the
705.Fl s
706flag, along with the identity of the signer using
707.Fl I
708and a list of allowed signers via the
709.Fl f
710flag.
711The format of the allowed signers file is documented in the
712.Sx ALLOWED SIGNERS
713section below.
714A file containing revoked keys can be passed using the
715.Fl r
jmc@openbsd.orgdb1e6f62019-09-04 05:56:54 +0000716flag.
717The revocation file may be a KRL or a one-per-line list of public keys.
djm@openbsd.org2a9c9f72019-09-03 08:34:19 +0000718Successful verification by an authorized signer is signalled by
719.Nm
jmc@openbsd.org70fc9a62019-10-22 08:50:35 +0000720returning a zero exit status.
jmc@openbsd.org5b6c9542019-12-27 08:25:07 +0000721.It Fl y
722This option will read a private
723OpenSSH format file and print an OpenSSH public key to stdout.
Damien Miller4e270b02010-04-16 15:56:21 +1000724.It Fl z Ar serial_number
725Specifies a serial number to be embedded in the certificate to distinguish
726this certificate from others from the same CA.
djm@openbsd.orgbe063942019-01-23 04:51:02 +0000727If the
728.Ar serial_number
729is prefixed with a
730.Sq +
731character, then the serial number will be incremented for each certificate
732signed on a single command-line.
Damien Miller4e270b02010-04-16 15:56:21 +1000733The default serial number is zero.
Damien Millerf3747bf2013-01-18 11:44:04 +1100734.Pp
735When generating a KRL, the
736.Fl z
737flag is used to specify a KRL version number.
Damien Miller32aa1441999-10-29 09:15:49 +1000738.El
Darren Tucker019cefe2003-08-02 22:40:07 +1000739.Sh MODULI GENERATION
740.Nm
741may be used to generate groups for the Diffie-Hellman Group Exchange
742(DH-GEX) protocol.
743Generating these groups is a two-step process: first, candidate
744primes are generated using a fast, but memory intensive process.
745These candidate primes are then tested for suitability (a CPU-intensive
746process).
747.Pp
748Generation of primes is performed using the
djm@openbsd.org3e60d182019-12-30 03:30:09 +0000749.Fl M Cm generate
Darren Tucker019cefe2003-08-02 22:40:07 +1000750option.
751The desired length of the primes may be specified by the
djm@openbsd.org3e60d182019-12-30 03:30:09 +0000752.Fl O Cm bits
Darren Tucker019cefe2003-08-02 22:40:07 +1000753option.
754For example:
755.Pp
djm@openbsd.org3e60d182019-12-30 03:30:09 +0000756.Dl # ssh-keygen -M generate -O bits=2048 moduli-2048.candidates
Darren Tucker019cefe2003-08-02 22:40:07 +1000757.Pp
758By default, the search for primes begins at a random point in the
759desired length range.
760This may be overridden using the
djm@openbsd.org3e60d182019-12-30 03:30:09 +0000761.Fl O Cm start
Darren Tucker019cefe2003-08-02 22:40:07 +1000762option, which specifies a different start point (in hex).
763.Pp
Damien Millerdfceafe2012-07-06 13:44:19 +1000764Once a set of candidates have been generated, they must be screened for
Darren Tucker019cefe2003-08-02 22:40:07 +1000765suitability.
766This may be performed using the
djm@openbsd.org3e60d182019-12-30 03:30:09 +0000767.Fl M Cm screen
Darren Tucker019cefe2003-08-02 22:40:07 +1000768option.
769In this mode
770.Nm
771will read candidates from standard input (or a file specified using the
772.Fl f
773option).
774For example:
775.Pp
djm@openbsd.org3e60d182019-12-30 03:30:09 +0000776.Dl # ssh-keygen -M screen -f moduli-2048.candidates moduli-2048
Darren Tucker019cefe2003-08-02 22:40:07 +1000777.Pp
778By default, each candidate will be subjected to 100 primality tests.
779This may be overridden using the
djm@openbsd.org3e60d182019-12-30 03:30:09 +0000780.Fl O Cm prime-tests
Darren Tucker019cefe2003-08-02 22:40:07 +1000781option.
782The DH generator value will be chosen automatically for the
783prime under consideration.
784If a specific generator is desired, it may be requested using the
djm@openbsd.org3e60d182019-12-30 03:30:09 +0000785.Fl O Cm generator
Darren Tucker019cefe2003-08-02 22:40:07 +1000786option.
Damien Miller265d3092005-03-02 12:05:06 +1100787Valid generator values are 2, 3, and 5.
Darren Tucker019cefe2003-08-02 22:40:07 +1000788.Pp
789Screened DH groups may be installed in
790.Pa /etc/moduli .
791It is important that this file contains moduli of a range of bit lengths and
792that both ends of a connection share common moduli.
djm@openbsd.org3e60d182019-12-30 03:30:09 +0000793.Pp
794A number of options are available for moduli generation and screening via the
795.Fl O
796flag:
jmc@openbsd.org3b1382f2019-12-30 16:10:00 +0000797.Bl -tag -width Ds
djm@openbsd.org3e60d182019-12-30 03:30:09 +0000798.It Ic lines Ns = Ns Ar number
799Exit after screening the specified number of lines while performing DH
800candidate screening.
djm@openbsd.org3e60d182019-12-30 03:30:09 +0000801.It Ic start-line Ns = Ns Ar line-number
802Start screening at the specified line number while performing DH candidate
803screening.
djm@openbsd.org3e60d182019-12-30 03:30:09 +0000804.It Ic checkpoint Ns = Ns Ar filename
805Write the last line processed to the specified file while performing DH
806candidate screening.
807This will be used to skip lines in the input file that have already been
808processed if the job is restarted.
djm@openbsd.org3e60d182019-12-30 03:30:09 +0000809.It Ic memory Ns = Ns Ar mbytes
810Specify the amount of memory to use (in megabytes) when generating
811candidate moduli for DH-GEX.
djm@openbsd.org3e60d182019-12-30 03:30:09 +0000812.It Ic start Ns = Ns Ar hex-value
813Specify start point (in hex) when generating candidate moduli for DH-GEX.
djm@openbsd.org3e60d182019-12-30 03:30:09 +0000814.It Ic generator Ns = Ns Ar value
815Specify desired generator (in decimal) when testing candidate moduli for DH-GEX.
816.El
Damien Miller0a80ca12010-02-27 07:55:05 +1100817.Sh CERTIFICATES
818.Nm
819supports signing of keys to produce certificates that may be used for
820user or host authentication.
821Certificates consist of a public key, some identity information, zero or
Damien Miller1f181422010-04-18 08:08:03 +1000822more principal (user or host) names and a set of options that
Damien Miller0a80ca12010-02-27 07:55:05 +1100823are signed by a Certification Authority (CA) key.
824Clients or servers may then trust only the CA key and verify its signature
825on a certificate rather than trusting many user/host keys.
826Note that OpenSSH certificates are a different, and much simpler, format to
827the X.509 certificates used in
828.Xr ssl 8 .
829.Pp
830.Nm
831supports two types of certificates: user and host.
832User certificates authenticate users to servers, whereas host certificates
Damien Miller15f5b562010-03-03 10:25:21 +1100833authenticate server hosts to users.
834To generate a user certificate:
Damien Miller0a80ca12010-02-27 07:55:05 +1100835.Pp
836.Dl $ ssh-keygen -s /path/to/ca_key -I key_id /path/to/user_key.pub
837.Pp
838The resultant certificate will be placed in
Damien Miller1b61a282010-03-22 05:55:06 +1100839.Pa /path/to/user_key-cert.pub .
Damien Miller0a80ca12010-02-27 07:55:05 +1100840A host certificate requires the
841.Fl h
842option:
843.Pp
844.Dl $ ssh-keygen -s /path/to/ca_key -I key_id -h /path/to/host_key.pub
845.Pp
846The host certificate will be output to
Damien Miller1b61a282010-03-22 05:55:06 +1100847.Pa /path/to/host_key-cert.pub .
Damien Miller757f34e2010-08-05 13:05:31 +1000848.Pp
849It is possible to sign using a CA key stored in a PKCS#11 token by
850providing the token library using
851.Fl D
852and identifying the CA key by providing its public half as an argument
853to
854.Fl s :
855.Pp
naddy@openbsd.org05291e52015-08-20 19:20:06 +0000856.Dl $ ssh-keygen -s ca_key.pub -D libpkcs11.so -I key_id user_key.pub
Damien Miller757f34e2010-08-05 13:05:31 +1000857.Pp
djm@openbsd.orga98339e2017-06-28 01:09:22 +0000858Similarly, it is possible for the CA key to be hosted in a
859.Xr ssh-agent 1 .
860This is indicated by the
861.Fl U
862flag and, again, the CA key must be identified by its public half.
863.Pp
864.Dl $ ssh-keygen -Us ca_key.pub -I key_id user_key.pub
865.Pp
Damien Miller757f34e2010-08-05 13:05:31 +1000866In all cases,
Damien Miller0a80ca12010-02-27 07:55:05 +1100867.Ar key_id
868is a "key identifier" that is logged by the server when the certificate
869is used for authentication.
870.Pp
871Certificates may be limited to be valid for a set of principal (user/host)
872names.
873By default, generated certificates are valid for all users or hosts.
874To generate a certificate for a specified set of principals:
875.Pp
876.Dl $ ssh-keygen -s ca_key -I key_id -n user1,user2 user_key.pub
naddy@openbsd.org05291e52015-08-20 19:20:06 +0000877.Dl "$ ssh-keygen -s ca_key -I key_id -h -n host.domain host_key.pub"
Damien Miller0a80ca12010-02-27 07:55:05 +1100878.Pp
879Additional limitations on the validity and use of user certificates may
Damien Miller1f181422010-04-18 08:08:03 +1000880be specified through certificate options.
Damien Miller4e270b02010-04-16 15:56:21 +1000881A certificate option may disable features of the SSH session, may be
Damien Miller0a80ca12010-02-27 07:55:05 +1100882valid only when presented from particular source addresses or may
883force the use of a specific command.
djm@openbsd.org1e645fe2019-12-30 03:28:41 +0000884.Pp
885The options that are valid for user certificates are:
886.Pp
887.Bl -tag -width Ds -compact
888.It Ic clear
889Clear all enabled permissions.
890This is useful for clearing the default set of permissions so permissions may
891be added individually.
892.Pp
893.It Ic critical : Ns Ar name Ns Op Ns = Ns Ar contents
894.It Ic extension : Ns Ar name Ns Op Ns = Ns Ar contents
895Includes an arbitrary certificate critical option or extension.
896The specified
897.Ar name
898should include a domain suffix, e.g.\&
899.Dq name@example.com .
900If
901.Ar contents
902is specified then it is included as the contents of the extension/option
903encoded as a string, otherwise the extension/option is created with no
904contents (usually indicating a flag).
905Extensions may be ignored by a client or server that does not recognise them,
906whereas unknown critical options will cause the certificate to be refused.
907.Pp
908.It Ic force-command Ns = Ns Ar command
909Forces the execution of
910.Ar command
911instead of any shell or command specified by the user when
912the certificate is used for authentication.
913.Pp
914.It Ic no-agent-forwarding
915Disable
916.Xr ssh-agent 1
917forwarding (permitted by default).
918.Pp
919.It Ic no-port-forwarding
920Disable port forwarding (permitted by default).
921.Pp
922.It Ic no-pty
923Disable PTY allocation (permitted by default).
924.Pp
925.It Ic no-user-rc
926Disable execution of
927.Pa ~/.ssh/rc
928by
929.Xr sshd 8
930(permitted by default).
931.Pp
932.It Ic no-x11-forwarding
933Disable X11 forwarding (permitted by default).
934.Pp
935.It Ic permit-agent-forwarding
936Allows
937.Xr ssh-agent 1
938forwarding.
939.Pp
940.It Ic permit-port-forwarding
941Allows port forwarding.
942.Pp
943.It Ic permit-pty
944Allows PTY allocation.
945.Pp
946.It Ic permit-user-rc
947Allows execution of
948.Pa ~/.ssh/rc
949by
950.Xr sshd 8 .
951.Pp
952.It Ic permit-X11-forwarding
953Allows X11 forwarding.
954.Pp
955.It Ic no-touch-required
956Do not require signatures made using this key require demonstration
naddy@openbsd.orgb715fdc2020-01-18 21:16:43 +0000957of user presence (e.g. by having the user touch the authenticator).
naddy@openbsd.org84911da2020-01-18 15:45:41 +0000958This option only makes sense for the FIDO authenticator algorithms
djm@openbsd.org1e645fe2019-12-30 03:28:41 +0000959.Cm ecdsa-sk
960and
961.Cm ed25519-sk .
962.Pp
963.It Ic source-address Ns = Ns Ar address_list
964Restrict the source addresses from which the certificate is considered valid.
965The
966.Ar address_list
967is a comma-separated list of one or more address/netmask pairs in CIDR
968format.
969.El
970.Pp
971At present, no standard options are valid for host keys.
Damien Miller0a80ca12010-02-27 07:55:05 +1100972.Pp
973Finally, certificates may be defined with a validity lifetime.
974The
975.Fl V
976option allows specification of certificate start and end times.
977A certificate that is presented at a time outside this range will not be
978considered valid.
Darren Tucker3ee50c52012-09-06 21:18:11 +1000979By default, certificates are valid from
980.Ux
981Epoch to the distant future.
Damien Miller0a80ca12010-02-27 07:55:05 +1100982.Pp
983For certificates to be used for user or host authentication, the CA
984public key must be trusted by
985.Xr sshd 8
986or
987.Xr ssh 1 .
988Please refer to those manual pages for details.
Damien Millerf3747bf2013-01-18 11:44:04 +1100989.Sh KEY REVOCATION LISTS
990.Nm
991is able to manage OpenSSH format Key Revocation Lists (KRLs).
992These binary files specify keys or certificates to be revoked using a
Damien Miller13797712013-12-29 17:47:14 +1100993compact format, taking as little as one bit per certificate if they are being
Damien Millerf3747bf2013-01-18 11:44:04 +1100994revoked by serial number.
995.Pp
996KRLs may be generated using the
997.Fl k
998flag.
Damien Miller881a7a22013-01-20 22:34:46 +1100999This option reads one or more files from the command line and generates a new
Damien Millerf3747bf2013-01-18 11:44:04 +11001000KRL.
1001The files may either contain a KRL specification (see below) or public keys,
1002listed one per line.
1003Plain public keys are revoked by listing their hash or contents in the KRL and
1004certificates revoked by serial number or key ID (if the serial is zero or
1005not available).
1006.Pp
1007Revoking keys using a KRL specification offers explicit control over the
1008types of record used to revoke keys and may be used to directly revoke
1009certificates by serial number or key ID without having the complete original
1010certificate on hand.
1011A KRL specification consists of lines containing one of the following directives
1012followed by a colon and some directive-specific information.
1013.Bl -tag -width Ds
Damien Millera0a7ee82013-01-20 22:35:06 +11001014.It Cm serial : Ar serial_number Ns Op - Ns Ar serial_number
Damien Millerf3747bf2013-01-18 11:44:04 +11001015Revokes a certificate with the specified serial number.
Damien Millerac5542b2013-01-20 22:33:02 +11001016Serial numbers are 64-bit values, not including zero and may be expressed
Damien Millerf3747bf2013-01-18 11:44:04 +11001017in decimal, hex or octal.
1018If two serial numbers are specified separated by a hyphen, then the range
1019of serial numbers including and between each is revoked.
1020The CA key must have been specified on the
1021.Nm
Damien Miller881a7a22013-01-20 22:34:46 +11001022command line using the
Damien Millerf3747bf2013-01-18 11:44:04 +11001023.Fl s
1024option.
1025.It Cm id : Ar key_id
1026Revokes a certificate with the specified key ID string.
1027The CA key must have been specified on the
1028.Nm
Damien Miller881a7a22013-01-20 22:34:46 +11001029command line using the
Damien Millerf3747bf2013-01-18 11:44:04 +11001030.Fl s
1031option.
1032.It Cm key : Ar public_key
1033Revokes the specified key.
Damien Millerac5542b2013-01-20 22:33:02 +11001034If a certificate is listed, then it is revoked as a plain public key.
Damien Millerf3747bf2013-01-18 11:44:04 +11001035.It Cm sha1 : Ar public_key
djm@openbsd.org9405c622018-09-12 01:21:34 +00001036Revokes the specified key by including its SHA1 hash in the KRL.
1037.It Cm sha256 : Ar public_key
1038Revokes the specified key by including its SHA256 hash in the KRL.
1039KRLs that revoke keys by SHA256 hash are not supported by OpenSSH versions
1040prior to 7.9.
1041.It Cm hash : Ar fingerprint
djm@openbsd.orgf0fcd7e2018-09-12 06:18:59 +00001042Revokes a key using a fingerprint hash, as obtained from a
djm@openbsd.org9405c622018-09-12 01:21:34 +00001043.Xr sshd 8
1044authentication log message or the
1045.Nm
1046.Fl l
1047flag.
1048Only SHA256 fingerprints are supported here and resultant KRLs are
1049not supported by OpenSSH versions prior to 7.9.
Damien Millerf3747bf2013-01-18 11:44:04 +11001050.El
1051.Pp
1052KRLs may be updated using the
1053.Fl u
1054flag in addition to
1055.Fl k .
Damien Miller881a7a22013-01-20 22:34:46 +11001056When this option is specified, keys listed via the command line are merged into
Damien Millerf3747bf2013-01-18 11:44:04 +11001057the KRL, adding to those already there.
1058.Pp
1059It is also possible, given a KRL, to test whether it revokes a particular key
1060(or keys).
1061The
1062.Fl Q
jmc@openbsd.org8b290082015-11-05 09:48:05 +00001063flag will query an existing KRL, testing each key specified on the command line.
Damien Miller881a7a22013-01-20 22:34:46 +11001064If any key listed on the command line has been revoked (or an error encountered)
Damien Millerf3747bf2013-01-18 11:44:04 +11001065then
1066.Nm
1067will exit with a non-zero exit status.
1068A zero exit status will only be returned if no key was revoked.
djm@openbsd.org2a9c9f72019-09-03 08:34:19 +00001069.Sh ALLOWED SIGNERS
1070When verifying signatures,
1071.Nm
1072uses a simple list of identities and keys to determine whether a signature
1073comes from an authorized source.
1074This "allowed signers" file uses a format patterned after the
1075AUTHORIZED_KEYS FILE FORMAT described in
jmc@openbsd.orgdb1e6f62019-09-04 05:56:54 +00001076.Xr sshd 8 .
djm@openbsd.org2a9c9f72019-09-03 08:34:19 +00001077Each line of the file contains the following space-separated fields:
1078principals, options, keytype, base64-encoded key.
1079Empty lines and lines starting with a
1080.Ql #
1081are ignored as comments.
1082.Pp
1083The principals field is a pattern-list (See PATTERNS in
1084.Xr ssh_config 5 )
1085consisting of one or more comma-separated USER@DOMAIN identity patterns
1086that are accepted for signing.
1087When verifying, the identity presented via the
jmc@openbsd.org70fc9a62019-10-22 08:50:35 +00001088.Fl I
1089option must match a principals pattern in order for the corresponding key to be
djm@openbsd.org2a9c9f72019-09-03 08:34:19 +00001090considered acceptable for verification.
1091.Pp
1092The options (if present) consist of comma-separated option specifications.
1093No spaces are permitted, except within double quotes.
1094The following option specifications are supported (note that option keywords
1095are case-insensitive):
1096.Bl -tag -width Ds
1097.It Cm cert-authority
1098Indicates that this key is accepted as a certificate authority (CA) and
1099that certificates signed by this CA may be accepted for verification.
1100.It Cm namespaces="namespace-list"
1101Specifies a pattern-list of namespaces that are accepted for this key.
djm@openbsd.orgd637c4a2019-09-03 08:35:27 +00001102If this option is present, the signature namespace embedded in the
djm@openbsd.org2a9c9f72019-09-03 08:34:19 +00001103signature object and presented on the verification command-line must
1104match the specified list before the key will be considered acceptable.
1105.El
1106.Pp
1107When verifying signatures made by certificates, the expected principal
1108name must match both the principals pattern in the allowed signers file and
1109the principals embedded in the certificate itself.
1110.Pp
1111An example allowed signers file:
1112.Bd -literal -offset 3n
1113# Comments allowed at start of line
1114user1@example.com,user2@example.com ssh-rsa AAAAX1...
1115# A certificate authority, trusted for all principals in a domain.
1116*@example.com cert-authority ssh-ed25519 AAAB4...
1117# A key that is accepted only for file signing.
1118user2@example.com namespaces="file" ssh-ed25519 AAA41...
1119.Ed
naddy@openbsd.orgaa4c6402019-11-07 08:38:38 +00001120.Sh ENVIRONMENT
1121.Bl -tag -width Ds
1122.It Ev SSH_SK_PROVIDER
djm@openbsd.org963d7182020-02-07 03:57:31 +00001123Specifies a path to a library that will be used when loading any
1124FIDO authenticator-hosted keys, overriding the default of using
1125the built-in USB HID support.
naddy@openbsd.orgaa4c6402019-11-07 08:38:38 +00001126.El
Damien Miller32aa1441999-10-29 09:15:49 +10001127.Sh FILES
Damien Miller6186bbc2010-09-24 22:00:54 +10001128.Bl -tag -width Ds -compact
Damien Miller167ea5d2005-05-26 12:04:02 +10001129.It Pa ~/.ssh/id_dsa
Damien Miller6186bbc2010-09-24 22:00:54 +10001130.It Pa ~/.ssh/id_ecdsa
naddy@openbsd.orgaa4c6402019-11-07 08:38:38 +00001131.It Pa ~/.ssh/id_ecdsa_sk
Damien Miller8ba0ead2013-12-18 17:46:27 +11001132.It Pa ~/.ssh/id_ed25519
naddy@openbsd.orgf0edda82019-11-18 23:16:49 +00001133.It Pa ~/.ssh/id_ed25519_sk
Damien Miller167ea5d2005-05-26 12:04:02 +10001134.It Pa ~/.ssh/id_rsa
naddy@openbsd.org141df482019-12-21 20:22:34 +00001135Contains the DSA, ECDSA, authenticator-hosted ECDSA, Ed25519,
1136authenticator-hosted Ed25519 or RSA authentication identity of the user.
Ben Lindstrom18a82ac2001-04-11 15:59:35 +00001137This file should not be readable by anyone but the user.
1138It is possible to
1139specify a passphrase when generating the key; that passphrase will be
Darren Tucker199ee6f2009-10-24 11:50:17 +11001140used to encrypt the private part of this file using 128-bit AES.
Ben Lindstrom18a82ac2001-04-11 15:59:35 +00001141This file is not automatically accessed by
1142.Nm
1143but it is offered as the default file for the private key.
Ben Lindstrombda98b02001-07-04 03:35:24 +00001144.Xr ssh 1
Ben Lindstrom18a82ac2001-04-11 15:59:35 +00001145will read this file when a login attempt is made.
Damien Miller6186bbc2010-09-24 22:00:54 +10001146.Pp
1147.It Pa ~/.ssh/id_dsa.pub
1148.It Pa ~/.ssh/id_ecdsa.pub
naddy@openbsd.orgaa4c6402019-11-07 08:38:38 +00001149.It Pa ~/.ssh/id_ecdsa_sk.pub
Damien Miller8ba0ead2013-12-18 17:46:27 +11001150.It Pa ~/.ssh/id_ed25519.pub
naddy@openbsd.orgf0edda82019-11-18 23:16:49 +00001151.It Pa ~/.ssh/id_ed25519_sk.pub
Damien Miller167ea5d2005-05-26 12:04:02 +10001152.It Pa ~/.ssh/id_rsa.pub
naddy@openbsd.org141df482019-12-21 20:22:34 +00001153Contains the DSA, ECDSA, authenticator-hosted ECDSA, Ed25519,
1154authenticator-hosted Ed25519 or RSA public key for authentication.
Damien Millere247cc42000-05-07 12:03:14 +10001155The contents of this file should be added to
Damien Miller167ea5d2005-05-26 12:04:02 +10001156.Pa ~/.ssh/authorized_keys
Damien Millere247cc42000-05-07 12:03:14 +10001157on all machines
Ben Lindstrom594e2032001-09-12 18:35:30 +00001158where the user wishes to log in using public key authentication.
Damien Millere247cc42000-05-07 12:03:14 +10001159There is no need to keep the contents of this file secret.
Damien Miller6186bbc2010-09-24 22:00:54 +10001160.Pp
Darren Tucker019cefe2003-08-02 22:40:07 +10001161.It Pa /etc/moduli
1162Contains Diffie-Hellman groups used for DH-GEX.
1163The file format is described in
1164.Xr moduli 5 .
Damien Miller37023962000-07-11 17:31:38 +10001165.El
Damien Miller32aa1441999-10-29 09:15:49 +10001166.Sh SEE ALSO
1167.Xr ssh 1 ,
1168.Xr ssh-add 1 ,
Damien Miller2e8b1c81999-11-15 23:33:56 +11001169.Xr ssh-agent 1 ,
Darren Tucker019cefe2003-08-02 22:40:07 +10001170.Xr moduli 5 ,
Ben Lindstrom77788dc2001-02-10 23:10:33 +00001171.Xr sshd 8
Ben Lindstrom5a707822001-04-22 17:15:46 +00001172.Rs
Damien Millerc0367fb2007-01-05 16:25:46 +11001173.%R RFC 4716
1174.%T "The Secure Shell (SSH) Public Key File Format"
1175.%D 2006
Ben Lindstrom5a707822001-04-22 17:15:46 +00001176.Re
Damien Millerf1ce5052003-06-11 22:04:39 +10001177.Sh AUTHORS
1178OpenSSH is a derivative of the original and free
1179ssh 1.2.12 release by Tatu Ylonen.
1180Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos,
1181Theo de Raadt and Dug Song
1182removed many bugs, re-added newer features and
1183created OpenSSH.
1184Markus Friedl contributed the support for SSH
1185protocol versions 1.5 and 2.0.