blob: 7af56429785f2796b8be823423e79ebbe51e32c4 [file] [log] [blame]
djm@openbsd.org963d7182020-02-07 03:57:31 +00001.\" $OpenBSD: ssh-keygen.1,v 1.201 2020/02/07 03:57:31 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.org963d7182020-02-07 03:57:31 +000038.Dd $Mdocdate: February 7 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
138.Fl f Ar krl_file
139.Ar
djm@openbsd.org2a9c9f72019-09-03 08:34:19 +0000140.Nm ssh-keygen
djm@openbsd.org72a8bea2020-01-23 23:31:52 +0000141.Fl Y Cm find-principals
djm@openbsd.org56cffcc2020-01-23 02:43:48 +0000142.Fl s Ar signature_file
143.Fl f Ar allowed_signers_file
144.Nm ssh-keygen
jmc@openbsd.org69189742019-10-03 17:07:50 +0000145.Fl Y Cm check-novalidate
146.Fl n Ar namespace
147.Fl s Ar signature_file
148.Nm ssh-keygen
djm@openbsd.org2a9c9f72019-09-03 08:34:19 +0000149.Fl Y Cm sign
150.Fl f Ar key_file
151.Fl n Ar namespace
152.Ar
153.Nm ssh-keygen
154.Fl Y Cm verify
djm@openbsd.org8aa2aa32019-09-16 03:23:02 +0000155.Fl f Ar allowed_signers_file
jmc@openbsd.org69189742019-10-03 17:07:50 +0000156.Fl I Ar signer_identity
djm@openbsd.org2a9c9f72019-09-03 08:34:19 +0000157.Fl n Ar namespace
158.Fl s Ar signature_file
159.Op Fl r Ar revocation_file
Damien Miller22c77262000-04-13 12:26:34 +1000160.Sh DESCRIPTION
Damien Miller32aa1441999-10-29 09:15:49 +1000161.Nm
Ben Lindstrom5a707822001-04-22 17:15:46 +0000162generates, manages and converts authentication keys for
Damien Miller32aa1441999-10-29 09:15:49 +1000163.Xr ssh 1 .
Damien Millere247cc42000-05-07 12:03:14 +1000164.Nm
jmc@openbsd.org2b6f7992017-05-03 06:32:02 +0000165can create keys for use by SSH protocol version 2.
jmc@openbsd.orga685ae82016-02-17 07:38:19 +0000166.Pp
Damien Millerfbf486b2003-05-23 18:44:23 +1000167The type of key to be generated is specified with the
Damien Miller0bc1bd82000-11-13 22:57:25 +1100168.Fl t
Damien Millera41c8b12002-01-22 23:05:08 +1100169option.
Damien Millerf14be5c2005-11-05 15:15:49 +1100170If invoked without any arguments,
171.Nm
naddy@openbsd.org2e9c3242017-05-05 10:41:58 +0000172will generate an RSA key.
Damien Millere247cc42000-05-07 12:03:14 +1000173.Pp
Darren Tucker019cefe2003-08-02 22:40:07 +1000174.Nm
175is also used to generate groups for use in Diffie-Hellman group
176exchange (DH-GEX).
177See the
178.Sx MODULI GENERATION
179section for details.
180.Pp
Damien Millerf3747bf2013-01-18 11:44:04 +1100181Finally,
182.Nm
183can be used to generate and update Key Revocation Lists, and to test whether
Damien Millerac5542b2013-01-20 22:33:02 +1100184given keys have been revoked by one.
185See the
Damien Millerf3747bf2013-01-18 11:44:04 +1100186.Sx KEY REVOCATION LISTS
187section for details.
188.Pp
Damien Miller32aa1441999-10-29 09:15:49 +1000189Normally each user wishing to use SSH
Damien Millereb8b60e2010-08-31 22:41:14 +1000190with public key authentication runs this once to create the authentication
Damien Miller32aa1441999-10-29 09:15:49 +1000191key in
Damien Miller8ba0ead2013-12-18 17:46:27 +1100192.Pa ~/.ssh/id_dsa ,
Damien Millereb8b60e2010-08-31 22:41:14 +1000193.Pa ~/.ssh/id_ecdsa ,
naddy@openbsd.orgaa4c6402019-11-07 08:38:38 +0000194.Pa ~/.ssh/id_ecdsa_sk ,
naddy@openbsd.orgf0edda82019-11-18 23:16:49 +0000195.Pa ~/.ssh/id_ed25519 ,
196.Pa ~/.ssh/id_ed25519_sk
Damien Millere247cc42000-05-07 12:03:14 +1000197or
Damien Miller167ea5d2005-05-26 12:04:02 +1000198.Pa ~/.ssh/id_rsa .
Damien Millere247cc42000-05-07 12:03:14 +1000199Additionally, the system administrator may use this to generate host keys,
200as seen in
201.Pa /etc/rc .
Damien Miller32aa1441999-10-29 09:15:49 +1000202.Pp
203Normally this program generates the key and asks for a file in which
Damien Miller450a7a12000-03-26 13:04:51 +1000204to store the private key.
205The public key is stored in a file with the same name but
Damien Miller32aa1441999-10-29 09:15:49 +1000206.Dq .pub
Damien Miller450a7a12000-03-26 13:04:51 +1000207appended.
208The program also asks for a passphrase.
209The passphrase may be empty to indicate no passphrase
Ben Lindstrombf555ba2001-01-18 02:04:35 +0000210(host keys must have an empty passphrase), or it may be a string of
Damien Miller450a7a12000-03-26 13:04:51 +1000211arbitrary length.
Ben Lindstrom4e366d52001-12-06 16:43:21 +0000212A passphrase is similar to a password, except it can be a phrase with a
213series of words, punctuation, numbers, whitespace, or any string of
214characters you want.
215Good passphrases are 10-30 characters long, are
Damien Miller32aa1441999-10-29 09:15:49 +1000216not simple sentences or otherwise easily guessable (English
Ben Lindstrom2a097a42001-06-09 01:13:40 +0000217prose has only 1-2 bits of entropy per character, and provides very bad
Ben Lindstrom4e366d52001-12-06 16:43:21 +0000218passphrases), and contain a mix of upper and lowercase letters,
219numbers, and non-alphanumeric characters.
Damien Miller450a7a12000-03-26 13:04:51 +1000220The passphrase can be changed later by using the
Damien Miller32aa1441999-10-29 09:15:49 +1000221.Fl p
222option.
223.Pp
Damien Miller450a7a12000-03-26 13:04:51 +1000224There is no way to recover a lost passphrase.
Damien Miller085c90f2011-05-05 14:15:33 +1000225If the passphrase is lost or forgotten, a new key must be generated
226and the corresponding public key copied to other machines.
Damien Miller32aa1441999-10-29 09:15:49 +1000227.Pp
djm@openbsd.orgc45616a2019-01-22 11:00:15 +0000228.Nm
229will by default write keys in an OpenSSH-specific format.
230This format is preferred as it offers better protection for
231keys at rest as well as allowing storage of key comments within
232the private key file itself.
233The key comment may be useful to help identify the key.
Damien Miller450a7a12000-03-26 13:04:51 +1000234The comment is initialized to
Damien Miller32aa1441999-10-29 09:15:49 +1000235.Dq user@host
236when the key is created, but can be changed using the
237.Fl c
238option.
239.Pp
djm@openbsd.orgc45616a2019-01-22 11:00:15 +0000240It is still possible for
241.Nm
242to write the previously-used PEM format private keys using the
243.Fl m
244flag.
245This may be used when generating new keys, and existing new-format
246keys may be converted using this option in conjunction with the
247.Fl p
248(change passphrase) flag.
249.Pp
Damien Millere247cc42000-05-07 12:03:14 +1000250After a key is generated, instructions below detail where the keys
251should be placed to be activated.
252.Pp
Damien Miller32aa1441999-10-29 09:15:49 +1000253The options are as follows:
254.Bl -tag -width Ds
Damien Miller58f1baf2011-05-05 14:06:15 +1000255.It Fl A
djm@openbsd.org97dc5d12019-11-18 04:50:45 +0000256For each of the key types (rsa, dsa, ecdsa and ed25519)
Damien Miller8ba0ead2013-12-18 17:46:27 +1100257for which host keys
Damien Miller58f1baf2011-05-05 14:06:15 +1000258do not exist, generate the host keys with the default key file path,
259an empty passphrase, default bits for the key type, and default comment.
jmc@openbsd.orgdc44dd32017-07-08 18:32:54 +0000260If
djm@openbsd.org853edbe2017-07-07 03:53:12 +0000261.Fl f
jmc@openbsd.orgdc44dd32017-07-08 18:32:54 +0000262has also been specified, its argument is used as a prefix to the
djm@openbsd.org853edbe2017-07-07 03:53:12 +0000263default path for the resulting host key files.
Damien Miller3ca1eb32011-05-05 14:13:50 +1000264This is used by
Damien Miller58f1baf2011-05-05 14:06:15 +1000265.Pa /etc/rc
266to generate new host keys.
Damien Miller4f752cf2013-12-18 17:45:35 +1100267.It Fl a Ar rounds
jmc@openbsd.org3b44bf32019-09-27 20:03:24 +0000268When saving a private key, this option specifies the number of KDF
djm@openbsd.orged7bd5d2018-08-08 01:16:01 +0000269(key derivation function) rounds used.
Damien Miller4f752cf2013-12-18 17:45:35 +1100270Higher numbers result in slower passphrase verification and increased
271resistance to brute-force password cracking (should the keys be stolen).
Damien Miller265d3092005-03-02 12:05:06 +1100272.It Fl B
273Show the bubblebabble digest of specified private or public key file.
Damien Miller32aa1441999-10-29 09:15:49 +1000274.It Fl b Ar bits
Damien Miller450a7a12000-03-26 13:04:51 +1000275Specifies the number of bits in the key to create.
dtucker@openbsd.orgd7c6e382019-04-19 05:47:44 +0000276For RSA keys, the minimum size is 1024 bits and the default is 3072 bits.
277Generally, 3072 bits is considered sufficient.
Darren Tucker9f647332005-11-28 16:41:46 +1100278DSA keys must be exactly 1024 bits as specified by FIPS 186-2.
Damien Millerad210322011-05-05 14:15:54 +1000279For ECDSA keys, the
280.Fl b
Damien Miller6232a162011-09-22 21:36:00 +1000281flag determines the key length by selecting from one of three elliptic
Damien Millerad210322011-05-05 14:15:54 +1000282curve sizes: 256, 384 or 521 bits.
283Attempting to use bit lengths other than these three values for ECDSA keys
284will fail.
naddy@openbsd.orgf0edda82019-11-18 23:16:49 +0000285ECDSA-SK, Ed25519 and Ed25519-SK keys have a fixed length and the
Damien Miller8ba0ead2013-12-18 17:46:27 +1100286.Fl b
287flag will be ignored.
Damien Miller265d3092005-03-02 12:05:06 +1100288.It Fl C Ar comment
289Provides a new comment.
Damien Miller32aa1441999-10-29 09:15:49 +1000290.It Fl c
291Requests changing the comment in the private and public key files.
292The program will prompt for the file containing the private keys, for
Ben Lindstromaafff9c2001-05-06 03:01:02 +0000293the passphrase if the key has one, and for the new comment.
Damien Miller7ea845e2010-02-12 09:21:02 +1100294.It Fl D Ar pkcs11
naddy@openbsd.orgc13b7452019-03-05 16:17:12 +0000295Download the public keys provided by the PKCS#11 shared library
Damien Millera7618442010-02-12 09:26:02 +1100296.Ar pkcs11 .
Damien Miller757f34e2010-08-05 13:05:31 +1000297When used in combination with
298.Fl s ,
299this option indicates that a CA key resides in a PKCS#11 token (see the
300.Sx CERTIFICATES
301section for details).
djm@openbsd.org56d1c832014-12-21 22:27:55 +0000302.It Fl E Ar fingerprint_hash
303Specifies the hash algorithm used when displaying key fingerprints.
304Valid options are:
305.Dq md5
306and
307.Dq sha256 .
308The default is
309.Dq sha256 .
Ben Lindstrom5a707822001-04-22 17:15:46 +0000310.It Fl e
Ben Lindstrom46c264f2001-04-24 16:56:58 +0000311This option will read a private or public OpenSSH key file and
djm@openbsd.org180b5202019-01-22 11:19:42 +0000312print to stdout a public key in one of the formats specified by the
Damien Miller44b25042010-07-02 13:35:01 +1000313.Fl m
314option.
315The default export format is
316.Dq RFC4716 .
Damien Millerea727282010-07-02 13:35:34 +1000317This option allows exporting OpenSSH keys for use by other programs, including
Damien Miller44b25042010-07-02 13:35:01 +1000318several commercial SSH implementations.
djm@openbsd.org737e4ed2018-12-07 03:32:26 +0000319.It Fl F Ar hostname | [hostname]:port
Damien Miller265d3092005-03-02 12:05:06 +1100320Search for the specified
321.Ar hostname
djm@openbsd.org737e4ed2018-12-07 03:32:26 +0000322(with optional port number)
Damien Miller265d3092005-03-02 12:05:06 +1100323in a
324.Pa known_hosts
325file, listing any occurrences found.
326This option is useful to find hashed host names or addresses and may also be
327used in conjunction with the
328.Fl H
329option to print found keys in a hashed format.
330.It Fl f Ar filename
331Specifies the filename of the key file.
Damien Miller37876e92003-05-15 10:19:46 +1000332.It Fl g
Darren Tucker0b42e6d2004-08-13 21:22:40 +1000333Use generic DNS format when printing fingerprint resource records using the
Darren Tucker6e370372004-08-13 21:23:25 +1000334.Fl r
Darren Tucker0b42e6d2004-08-13 21:22:40 +1000335command.
Damien Miller265d3092005-03-02 12:05:06 +1100336.It Fl H
337Hash a
338.Pa known_hosts
Darren Tuckerda1adbc2005-03-14 23:15:58 +1100339file.
340This replaces all hostnames and addresses with hashed representations
341within the specified file; the original content is moved to a file with
342a .old suffix.
Damien Miller265d3092005-03-02 12:05:06 +1100343These hashes may be used normally by
344.Nm ssh
345and
346.Nm sshd ,
347but they do not reveal identifying information should the file's contents
348be disclosed.
349This option will not modify existing hashed hostnames and is therefore safe
350to use on files that mix hashed and non-hashed names.
Damien Miller0a80ca12010-02-27 07:55:05 +1100351.It Fl h
352When signing a key, create a host certificate instead of a user
353certificate.
354Please see the
355.Sx CERTIFICATES
356section for details.
Damien Miller15f5b562010-03-03 10:25:21 +1100357.It Fl I Ar certificate_identity
Damien Miller0a80ca12010-02-27 07:55:05 +1100358Specify the key identity when signing a public key.
359Please see the
360.Sx CERTIFICATES
361section for details.
Ben Lindstrom5a707822001-04-22 17:15:46 +0000362.It Fl i
363This option will read an unencrypted private (or public) key file
Damien Miller44b25042010-07-02 13:35:01 +1000364in the format specified by the
365.Fl m
366option and print an OpenSSH compatible private
Ben Lindstrom5a707822001-04-22 17:15:46 +0000367(or public) key to stdout.
Damien Miller43b156c2014-04-20 13:23:03 +1000368This option allows importing keys from other software, including several
369commercial SSH implementations.
370The default import format is
371.Dq RFC4716 .
jmc@openbsd.orgc593cc52020-01-03 07:33:33 +0000372.It Fl K
djm@openbsd.org90399712020-01-02 22:40:09 +0000373Download resident keys from a FIDO authenticator.
374Public and private key files will be written to the current directory for
375each downloaded key.
376.It Fl k
Damien Millerf3747bf2013-01-18 11:44:04 +1100377Generate a KRL file.
378In this mode,
379.Nm
380will generate a KRL file at the location specified via the
381.Fl f
Damien Miller881a7a22013-01-20 22:34:46 +1100382flag that revokes every key or certificate presented on the command line.
Damien Millerf3747bf2013-01-18 11:44:04 +1100383Keys/certificates to be revoked may be specified by public key file or
384using the format described in the
385.Sx KEY REVOCATION LISTS
386section.
Damien Millerf2b70ca2010-03-05 07:39:35 +1100387.It Fl L
djm@openbsd.org94bc0b72015-11-13 04:34:15 +0000388Prints the contents of one or more certificates.
Damien Miller10f6f6b1999-11-17 17:29:08 +1100389.It Fl l
Darren Tucker35c45532008-06-13 04:43:15 +1000390Show fingerprint of specified public key file.
Damien Millereb5fec62001-11-12 10:52:44 +1100391For RSA and DSA keys
392.Nm
Darren Tuckerf09e8252008-06-13 05:18:03 +1000393tries to find the matching public key file and prints its fingerprint.
394If combined with
395.Fl v ,
jmc@openbsd.org92838842016-05-03 18:38:12 +0000396a visual ASCII art representation of the key is supplied with the
djm@openbsd.orgcdcd9412016-05-03 14:54:08 +0000397fingerprint.
djm@openbsd.org3e60d182019-12-30 03:30:09 +0000398.It Fl M Cm generate
399Generate candidate Diffie-Hellman Group Exchange (DH-GEX) parameters for
400eventual use by the
401.Sq diffie-hellman-group-exchange-*
402key exchange methods.
403The numbers generated by this operation must be further screened before
404use.
405See the
406.Sx MODULI GENERATION
407section for more information.
408.It Fl M Cm screen
409Screen candidate parameters for Diffie-Hellman Group Exchange.
410This will accept a list of candidate numbers and test that they are
411safe (Sophie Germain) primes with acceptable group generators.
412The results of this operation may be added to the
413.Pa /etc/moduli
414file.
415See the
416.Sx MODULI GENERATION
417section for more information.
Damien Miller44b25042010-07-02 13:35:01 +1000418.It Fl m Ar key_format
djm@openbsd.orgecd2f332019-01-22 11:40:42 +0000419Specify a key format for key generation, the
Damien Miller44b25042010-07-02 13:35:01 +1000420.Fl i
djm@openbsd.orgecd2f332019-01-22 11:40:42 +0000421(import),
Damien Miller44b25042010-07-02 13:35:01 +1000422.Fl e
djm@openbsd.orgecd2f332019-01-22 11:40:42 +0000423(export) conversion options, and the
424.Fl p
425change passphrase operation.
426The latter may be used to convert between OpenSSH private key and PEM
427private key formats.
Damien Miller44b25042010-07-02 13:35:01 +1000428The supported key formats are:
429.Dq RFC4716
Damien Millerea727282010-07-02 13:35:34 +1000430(RFC 4716/SSH2 public or private key),
Damien Miller44b25042010-07-02 13:35:01 +1000431.Dq PKCS8
djm@openbsd.orgeb0d8e72019-07-15 13:16:29 +0000432(PKCS8 public or private key)
Damien Miller44b25042010-07-02 13:35:01 +1000433or
434.Dq PEM
435(PEM public key).
djm@openbsd.orgeb0d8e72019-07-15 13:16:29 +0000436By default OpenSSH will write newly-generated private keys in its own
437format, but when converting public keys for export the default format is
Damien Miller44b25042010-07-02 13:35:01 +1000438.Dq RFC4716 .
djm@openbsd.orged7bd5d2018-08-08 01:16:01 +0000439Setting a format of
440.Dq PEM
441when generating or updating a supported private key type will cause the
442key to be stored in the legacy PEM private key format.
Damien Miller265d3092005-03-02 12:05:06 +1100443.It Fl N Ar new_passphrase
444Provides the new passphrase.
Damien Miller0a80ca12010-02-27 07:55:05 +1100445.It Fl n Ar principals
446Specify one or more principals (user or host names) to be included in
447a certificate when signing a key.
448Multiple principals may be specified, separated by commas.
449Please see the
450.Sx CERTIFICATES
451section for details.
Damien Miller4e270b02010-04-16 15:56:21 +1000452.It Fl O Ar option
djm@openbsd.org3e60d182019-12-30 03:30:09 +0000453Specify a key/value option.
454These are specific to the operation that
455.Nm
456has been requested to perform.
457.Pp
458When signing certificates, one of the options listed in the
Damien Miller0a80ca12010-02-27 07:55:05 +1100459.Sx CERTIFICATES
djm@openbsd.org3e60d182019-12-30 03:30:09 +0000460section may be specified here.
461.Pp
462When performing moduli generation or screening, one of the options
463listed in the
464.Sx MODULI GENERATION
465section may be specified.
466.Pp
jmc@openbsd.orgcd534762020-01-06 07:43:28 +0000467When generating a key that will be hosted on a FIDO authenticator,
468this flag may be used to specify key-specific options.
469Those supported at present are:
470.Bl -tag -width Ds
471.It Cm application
472Override the default FIDO application/origin string of
djm@openbsd.orgc312ca02020-01-06 02:00:46 +0000473.Dq ssh: .
jmc@openbsd.orgcd534762020-01-06 07:43:28 +0000474This may be useful when generating host or domain-specific resident keys.
djm@openbsd.orgd596b1d2020-02-04 09:58:04 +0000475The specified application string must begin with
476.Dq ssh: .
jmc@openbsd.org072f3b82020-02-03 08:15:37 +0000477.It Cm challenge Ns = Ns Ar path
jmc@openbsd.org0facae72020-02-02 07:36:50 +0000478Specifies a path to a challenge string that will be passed to the
479FIDO token during key generation.
jmc@openbsd.org072f3b82020-02-03 08:15:37 +0000480The challenge string may be used as part of an out-of-band
481protocol for key enrollment
482(a random challenge is used by default).
jmc@openbsd.orgcd534762020-01-06 07:43:28 +0000483.It Cm device
484Explicitly specify a
djm@openbsd.orgc312ca02020-01-06 02:00:46 +0000485.Xr fido 4
486device to use, rather than letting the token middleware select one.
jmc@openbsd.orgcd534762020-01-06 07:43:28 +0000487.It Cm no-touch-required
488Indicate that the generated private key should not require touch
djm@openbsd.org3093d122019-12-30 09:49:52 +0000489events (user presence) when making signatures.
490Note that
491.Xr sshd 8
492will refuse such signatures by default, unless overridden via
493an authorized_keys option.
jmc@openbsd.orgcd534762020-01-06 07:43:28 +0000494.It Cm resident
495Indicate that the key should be stored on the FIDO authenticator itself.
djm@openbsd.org3093d122019-12-30 09:49:52 +0000496Resident keys may be supported on FIDO2 tokens and typically require that
497a PIN be set on the token prior to generation.
498Resident keys may be loaded off the token using
499.Xr ssh-add 1 .
jmc@openbsd.orgcd534762020-01-06 07:43:28 +0000500.It Cm user
501A username to be associated with a resident key,
djm@openbsd.orgc312ca02020-01-06 02:00:46 +0000502overriding the empty default username.
503Specifying a username may be useful when generating multiple resident keys
504for the same application name.
jmc@openbsd.org072f3b82020-02-03 08:15:37 +0000505.It Cm write-attestation Ns = Ns Ar path
djm@openbsd.org24c0f752020-01-28 08:01:34 +0000506May be used at key generation time to record the attestation certificate
507returned from FIDO tokens during key generation.
508By default this information is discarded.
jmc@openbsd.orgcd534762020-01-06 07:43:28 +0000509.El
djm@openbsd.org3093d122019-12-30 09:49:52 +0000510.Pp
511The
512.Fl O
513option may be specified multiple times.
Damien Miller265d3092005-03-02 12:05:06 +1100514.It Fl P Ar passphrase
515Provides the (old) passphrase.
Damien Miller32aa1441999-10-29 09:15:49 +1000516.It Fl p
517Requests changing the passphrase of a private key file instead of
Damien Miller450a7a12000-03-26 13:04:51 +1000518creating a new private key.
519The program will prompt for the file
Damien Miller32aa1441999-10-29 09:15:49 +1000520containing the private key, for the old passphrase, and twice for the
521new passphrase.
Damien Miller072fdcd2013-01-20 22:34:04 +1100522.It Fl Q
523Test whether keys have been revoked in a KRL.
Damien Miller32aa1441999-10-29 09:15:49 +1000524.It Fl q
525Silence
526.Nm ssh-keygen .
djm@openbsd.org63bba572018-12-07 03:33:18 +0000527.It Fl R Ar hostname | [hostname]:port
djm@openbsd.org737e4ed2018-12-07 03:32:26 +0000528Removes all keys belonging to the specified
Damien Miller4b42d7f2005-03-01 21:48:35 +1100529.Ar hostname
djm@openbsd.org737e4ed2018-12-07 03:32:26 +0000530(with optional port number)
Damien Miller4c9c6fd2005-03-02 12:03:43 +1100531from a
Damien Miller4b42d7f2005-03-01 21:48:35 +1100532.Pa known_hosts
533file.
Damien Miller4c9c6fd2005-03-02 12:03:43 +1100534This option is useful to delete hashed hosts (see the
Damien Miller4b42d7f2005-03-01 21:48:35 +1100535.Fl H
536option above).
Damien Miller265d3092005-03-02 12:05:06 +1100537.It Fl r Ar hostname
538Print the SSHFP fingerprint resource record named
539.Ar hostname
540for the specified public key file.
Damien Miller0a80ca12010-02-27 07:55:05 +1100541.It Fl s Ar ca_key
542Certify (sign) a public key using the specified CA key.
543Please see the
544.Sx CERTIFICATES
545section for details.
Damien Millerf3747bf2013-01-18 11:44:04 +1100546.Pp
547When generating a KRL,
548.Fl s
Damien Millerac5542b2013-01-20 22:33:02 +1100549specifies a path to a CA public key file used to revoke certificates directly
Damien Millerf3747bf2013-01-18 11:44:04 +1100550by key ID or serial number.
551See the
552.Sx KEY REVOCATION LISTS
553section for details.
djm@openbsd.org97dc5d12019-11-18 04:50:45 +0000554.It Fl t Cm dsa | ecdsa | ecdsa-sk | ed25519 | ed25519-sk | rsa
Damien Miller265d3092005-03-02 12:05:06 +1100555Specifies the type of key to create.
556The possible values are
Damien Miller6186bbc2010-09-24 22:00:54 +1000557.Dq dsa ,
Damien Miller8ba0ead2013-12-18 17:46:27 +1100558.Dq ecdsa ,
naddy@openbsd.orgaa4c6402019-11-07 08:38:38 +0000559.Dq ecdsa-sk ,
Damien Miller8ba0ead2013-12-18 17:46:27 +1100560.Dq ed25519 ,
djm@openbsd.org97dc5d12019-11-18 04:50:45 +0000561.Dq ed25519-sk ,
Damien Miller265d3092005-03-02 12:05:06 +1100562or
jmc@openbsd.orgf10c0d32017-05-02 17:04:09 +0000563.Dq rsa .
djm@openbsd.org476e3552019-05-20 00:20:35 +0000564.Pp
565This flag may also be used to specify the desired signature type when
jmc@openbsd.org85ceb0e2019-05-20 06:01:59 +0000566signing certificates using an RSA CA key.
djm@openbsd.org476e3552019-05-20 00:20:35 +0000567The available RSA signature variants are
568.Dq ssh-rsa
569(SHA1 signatures, not recommended),
jmc@openbsd.org85ceb0e2019-05-20 06:01:59 +0000570.Dq rsa-sha2-256 ,
571and
djm@openbsd.org476e3552019-05-20 00:20:35 +0000572.Dq rsa-sha2-512
573(the default).
djm@openbsd.orga98339e2017-06-28 01:09:22 +0000574.It Fl U
575When used in combination with
576.Fl s ,
577this option indicates that a CA key resides in a
578.Xr ssh-agent 1 .
579See the
580.Sx CERTIFICATES
581section for more information.
Damien Millerac5542b2013-01-20 22:33:02 +1100582.It Fl u
583Update a KRL.
584When specified with
585.Fl k ,
Damien Miller881a7a22013-01-20 22:34:46 +1100586keys listed via the command line are added to the existing KRL rather than
Damien Millerac5542b2013-01-20 22:33:02 +1100587a new KRL being created.
Damien Miller0a80ca12010-02-27 07:55:05 +1100588.It Fl V Ar validity_interval
589Specify a validity interval when signing a certificate.
590A validity interval may consist of a single time, indicating that the
591certificate is valid beginning now and expiring at that time, or may consist
592of two times separated by a colon to indicate an explicit time interval.
djm@openbsd.org@openbsd.orgd52131a2017-11-03 05:14:04 +0000593.Pp
594The start time may be specified as the string
595.Dq always
596to indicate the certificate has no specified start time,
djm@openbsd.orgbf0fbf22018-03-12 00:52:01 +0000597a date in YYYYMMDD format, a time in YYYYMMDDHHMM[SS] format,
djm@openbsd.org@openbsd.orgd52131a2017-11-03 05:14:04 +0000598a relative time (to the current time) consisting of a minus sign followed by
599an interval in the format described in the
Damien Millerfecfd112013-07-18 16:11:50 +1000600TIME FORMATS section of
Damien Miller77497e12010-03-22 05:50:51 +1100601.Xr sshd_config 5 .
djm@openbsd.org@openbsd.orgd52131a2017-11-03 05:14:04 +0000602.Pp
djm@openbsd.orgbf0fbf22018-03-12 00:52:01 +0000603The end time may be specified as a YYYYMMDD date, a YYYYMMDDHHMM[SS] time,
djm@openbsd.org@openbsd.orgd52131a2017-11-03 05:14:04 +0000604a relative time starting with a plus character or the string
605.Dq forever
606to indicate that the certificate has no expirty date.
Damien Miller0a80ca12010-02-27 07:55:05 +1100607.Pp
608For example:
609.Dq +52w1d
610(valid from now to 52 weeks and one day from now),
611.Dq -4w:+4w
612(valid from four weeks ago to four weeks from now),
613.Dq 20100101123000:20110101123000
614(valid from 12:30 PM, January 1st, 2010 to 12:30 PM, January 1st, 2011),
615.Dq -1d:20110101
616(valid from yesterday to midnight, January 1st, 2011).
djm@openbsd.org@openbsd.orgd52131a2017-11-03 05:14:04 +0000617.Dq -1m:forever
618(valid from one minute ago and never expiring).
Darren Tucker06930c72003-12-31 11:34:51 +1100619.It Fl v
620Verbose mode.
621Causes
622.Nm
623to print debugging messages about its progress.
624This is helpful for debugging moduli generation.
625Multiple
626.Fl v
627options increase the verbosity.
628The maximum is 3.
naddy@openbsd.orgaa4c6402019-11-07 08:38:38 +0000629.It Fl w Ar provider
naddy@openbsd.org141df482019-12-21 20:22:34 +0000630Specifies a path to a library that will be used when creating
631FIDO authenticator-hosted keys, overriding the default of using
632the internal USB HID support.
djm@openbsd.org72a8bea2020-01-23 23:31:52 +0000633.It Fl Y Cm find-principals
634Find the principal(s) associated with the public key of a signature,
djm@openbsd.org56cffcc2020-01-23 02:43:48 +0000635provided using the
636.Fl s
637flag in an authorized signers file provided using the
638.Fl f
639flag.
640The format of the allowed signers file is documented in the
641.Sx ALLOWED SIGNERS
jmc@openbsd.org5533c2f2020-01-23 07:16:38 +0000642section below.
djm@openbsd.org72a8bea2020-01-23 23:31:52 +0000643If one or more matching principals are found, they are returned on
644standard output.
jmc@openbsd.org20ccd852019-12-27 08:28:44 +0000645.It Fl Y Cm check-novalidate
646Checks that a signature generated using
647.Nm
648.Fl Y Cm sign
649has a valid structure.
650This does not validate if a signature comes from an authorized signer.
651When testing a signature,
652.Nm
653accepts a message on standard input and a signature namespace using
654.Fl n .
655A file containing the corresponding signature must also be supplied using the
656.Fl s
657flag.
658Successful testing of the signature is signalled by
659.Nm
660returning a zero exit status.
jmc@openbsd.orgf23d91f2019-09-05 05:47:23 +0000661.It Fl Y Cm sign
djm@openbsd.org2a9c9f72019-09-03 08:34:19 +0000662Cryptographically sign a file or some data using a SSH key.
663When signing,
664.Nm
665accepts zero or more files to sign on the command-line - if no files
666are specified then
667.Nm
668will sign data presented on standard input.
669Signatures are written to the path of the input file with
670.Dq .sig
671appended, or to standard output if the message to be signed was read from
672standard input.
673.Pp
674The key used for signing is specified using the
675.Fl f
676option and may refer to either a private key, or a public key with the private
677half available via
678.Xr ssh-agent 1 .
679An additional signature namespace, used to prevent signature confusion across
680different domains of use (e.g. file signing vs email signing) must be provided
681via the
682.Fl n
683flag.
684Namespaces are arbitrary strings, and may include:
685.Dq file
686for file signing,
687.Dq email
688for email signing.
689For custom uses, it is recommended to use names following a
690NAMESPACE@YOUR.DOMAIN pattern to generate unambiguous namespaces.
jmc@openbsd.orgf23d91f2019-09-05 05:47:23 +0000691.It Fl Y Cm verify
djm@openbsd.org2a9c9f72019-09-03 08:34:19 +0000692Request to verify a signature generated using
693.Nm
jmc@openbsd.orgf23d91f2019-09-05 05:47:23 +0000694.Fl Y Cm sign
djm@openbsd.org2a9c9f72019-09-03 08:34:19 +0000695as described above.
696When verifying a signature,
697.Nm
698accepts a message on standard input and a signature namespace using
699.Fl n .
700A file containing the corresponding signature must also be supplied using the
701.Fl s
702flag, along with the identity of the signer using
703.Fl I
704and a list of allowed signers via the
705.Fl f
706flag.
707The format of the allowed signers file is documented in the
708.Sx ALLOWED SIGNERS
709section below.
710A file containing revoked keys can be passed using the
711.Fl r
jmc@openbsd.orgdb1e6f62019-09-04 05:56:54 +0000712flag.
713The revocation file may be a KRL or a one-per-line list of public keys.
djm@openbsd.org2a9c9f72019-09-03 08:34:19 +0000714Successful verification by an authorized signer is signalled by
715.Nm
jmc@openbsd.org70fc9a62019-10-22 08:50:35 +0000716returning a zero exit status.
jmc@openbsd.org5b6c9542019-12-27 08:25:07 +0000717.It Fl y
718This option will read a private
719OpenSSH format file and print an OpenSSH public key to stdout.
Damien Miller4e270b02010-04-16 15:56:21 +1000720.It Fl z Ar serial_number
721Specifies a serial number to be embedded in the certificate to distinguish
722this certificate from others from the same CA.
djm@openbsd.orgbe063942019-01-23 04:51:02 +0000723If the
724.Ar serial_number
725is prefixed with a
726.Sq +
727character, then the serial number will be incremented for each certificate
728signed on a single command-line.
Damien Miller4e270b02010-04-16 15:56:21 +1000729The default serial number is zero.
Damien Millerf3747bf2013-01-18 11:44:04 +1100730.Pp
731When generating a KRL, the
732.Fl z
733flag is used to specify a KRL version number.
Damien Miller32aa1441999-10-29 09:15:49 +1000734.El
Darren Tucker019cefe2003-08-02 22:40:07 +1000735.Sh MODULI GENERATION
736.Nm
737may be used to generate groups for the Diffie-Hellman Group Exchange
738(DH-GEX) protocol.
739Generating these groups is a two-step process: first, candidate
740primes are generated using a fast, but memory intensive process.
741These candidate primes are then tested for suitability (a CPU-intensive
742process).
743.Pp
744Generation of primes is performed using the
djm@openbsd.org3e60d182019-12-30 03:30:09 +0000745.Fl M Cm generate
Darren Tucker019cefe2003-08-02 22:40:07 +1000746option.
747The desired length of the primes may be specified by the
djm@openbsd.org3e60d182019-12-30 03:30:09 +0000748.Fl O Cm bits
Darren Tucker019cefe2003-08-02 22:40:07 +1000749option.
750For example:
751.Pp
djm@openbsd.org3e60d182019-12-30 03:30:09 +0000752.Dl # ssh-keygen -M generate -O bits=2048 moduli-2048.candidates
Darren Tucker019cefe2003-08-02 22:40:07 +1000753.Pp
754By default, the search for primes begins at a random point in the
755desired length range.
756This may be overridden using the
djm@openbsd.org3e60d182019-12-30 03:30:09 +0000757.Fl O Cm start
Darren Tucker019cefe2003-08-02 22:40:07 +1000758option, which specifies a different start point (in hex).
759.Pp
Damien Millerdfceafe2012-07-06 13:44:19 +1000760Once a set of candidates have been generated, they must be screened for
Darren Tucker019cefe2003-08-02 22:40:07 +1000761suitability.
762This may be performed using the
djm@openbsd.org3e60d182019-12-30 03:30:09 +0000763.Fl M Cm screen
Darren Tucker019cefe2003-08-02 22:40:07 +1000764option.
765In this mode
766.Nm
767will read candidates from standard input (or a file specified using the
768.Fl f
769option).
770For example:
771.Pp
djm@openbsd.org3e60d182019-12-30 03:30:09 +0000772.Dl # ssh-keygen -M screen -f moduli-2048.candidates moduli-2048
Darren Tucker019cefe2003-08-02 22:40:07 +1000773.Pp
774By default, each candidate will be subjected to 100 primality tests.
775This may be overridden using the
djm@openbsd.org3e60d182019-12-30 03:30:09 +0000776.Fl O Cm prime-tests
Darren Tucker019cefe2003-08-02 22:40:07 +1000777option.
778The DH generator value will be chosen automatically for the
779prime under consideration.
780If a specific generator is desired, it may be requested using the
djm@openbsd.org3e60d182019-12-30 03:30:09 +0000781.Fl O Cm generator
Darren Tucker019cefe2003-08-02 22:40:07 +1000782option.
Damien Miller265d3092005-03-02 12:05:06 +1100783Valid generator values are 2, 3, and 5.
Darren Tucker019cefe2003-08-02 22:40:07 +1000784.Pp
785Screened DH groups may be installed in
786.Pa /etc/moduli .
787It is important that this file contains moduli of a range of bit lengths and
788that both ends of a connection share common moduli.
djm@openbsd.org3e60d182019-12-30 03:30:09 +0000789.Pp
790A number of options are available for moduli generation and screening via the
791.Fl O
792flag:
jmc@openbsd.org3b1382f2019-12-30 16:10:00 +0000793.Bl -tag -width Ds
djm@openbsd.org3e60d182019-12-30 03:30:09 +0000794.It Ic lines Ns = Ns Ar number
795Exit after screening the specified number of lines while performing DH
796candidate screening.
djm@openbsd.org3e60d182019-12-30 03:30:09 +0000797.It Ic start-line Ns = Ns Ar line-number
798Start screening at the specified line number while performing DH candidate
799screening.
djm@openbsd.org3e60d182019-12-30 03:30:09 +0000800.It Ic checkpoint Ns = Ns Ar filename
801Write the last line processed to the specified file while performing DH
802candidate screening.
803This will be used to skip lines in the input file that have already been
804processed if the job is restarted.
djm@openbsd.org3e60d182019-12-30 03:30:09 +0000805.It Ic memory Ns = Ns Ar mbytes
806Specify the amount of memory to use (in megabytes) when generating
807candidate moduli for DH-GEX.
djm@openbsd.org3e60d182019-12-30 03:30:09 +0000808.It Ic start Ns = Ns Ar hex-value
809Specify start point (in hex) when generating candidate moduli for DH-GEX.
djm@openbsd.org3e60d182019-12-30 03:30:09 +0000810.It Ic generator Ns = Ns Ar value
811Specify desired generator (in decimal) when testing candidate moduli for DH-GEX.
812.El
Damien Miller0a80ca12010-02-27 07:55:05 +1100813.Sh CERTIFICATES
814.Nm
815supports signing of keys to produce certificates that may be used for
816user or host authentication.
817Certificates consist of a public key, some identity information, zero or
Damien Miller1f181422010-04-18 08:08:03 +1000818more principal (user or host) names and a set of options that
Damien Miller0a80ca12010-02-27 07:55:05 +1100819are signed by a Certification Authority (CA) key.
820Clients or servers may then trust only the CA key and verify its signature
821on a certificate rather than trusting many user/host keys.
822Note that OpenSSH certificates are a different, and much simpler, format to
823the X.509 certificates used in
824.Xr ssl 8 .
825.Pp
826.Nm
827supports two types of certificates: user and host.
828User certificates authenticate users to servers, whereas host certificates
Damien Miller15f5b562010-03-03 10:25:21 +1100829authenticate server hosts to users.
830To generate a user certificate:
Damien Miller0a80ca12010-02-27 07:55:05 +1100831.Pp
832.Dl $ ssh-keygen -s /path/to/ca_key -I key_id /path/to/user_key.pub
833.Pp
834The resultant certificate will be placed in
Damien Miller1b61a282010-03-22 05:55:06 +1100835.Pa /path/to/user_key-cert.pub .
Damien Miller0a80ca12010-02-27 07:55:05 +1100836A host certificate requires the
837.Fl h
838option:
839.Pp
840.Dl $ ssh-keygen -s /path/to/ca_key -I key_id -h /path/to/host_key.pub
841.Pp
842The host certificate will be output to
Damien Miller1b61a282010-03-22 05:55:06 +1100843.Pa /path/to/host_key-cert.pub .
Damien Miller757f34e2010-08-05 13:05:31 +1000844.Pp
845It is possible to sign using a CA key stored in a PKCS#11 token by
846providing the token library using
847.Fl D
848and identifying the CA key by providing its public half as an argument
849to
850.Fl s :
851.Pp
naddy@openbsd.org05291e52015-08-20 19:20:06 +0000852.Dl $ ssh-keygen -s ca_key.pub -D libpkcs11.so -I key_id user_key.pub
Damien Miller757f34e2010-08-05 13:05:31 +1000853.Pp
djm@openbsd.orga98339e2017-06-28 01:09:22 +0000854Similarly, it is possible for the CA key to be hosted in a
855.Xr ssh-agent 1 .
856This is indicated by the
857.Fl U
858flag and, again, the CA key must be identified by its public half.
859.Pp
860.Dl $ ssh-keygen -Us ca_key.pub -I key_id user_key.pub
861.Pp
Damien Miller757f34e2010-08-05 13:05:31 +1000862In all cases,
Damien Miller0a80ca12010-02-27 07:55:05 +1100863.Ar key_id
864is a "key identifier" that is logged by the server when the certificate
865is used for authentication.
866.Pp
867Certificates may be limited to be valid for a set of principal (user/host)
868names.
869By default, generated certificates are valid for all users or hosts.
870To generate a certificate for a specified set of principals:
871.Pp
872.Dl $ ssh-keygen -s ca_key -I key_id -n user1,user2 user_key.pub
naddy@openbsd.org05291e52015-08-20 19:20:06 +0000873.Dl "$ ssh-keygen -s ca_key -I key_id -h -n host.domain host_key.pub"
Damien Miller0a80ca12010-02-27 07:55:05 +1100874.Pp
875Additional limitations on the validity and use of user certificates may
Damien Miller1f181422010-04-18 08:08:03 +1000876be specified through certificate options.
Damien Miller4e270b02010-04-16 15:56:21 +1000877A certificate option may disable features of the SSH session, may be
Damien Miller0a80ca12010-02-27 07:55:05 +1100878valid only when presented from particular source addresses or may
879force the use of a specific command.
djm@openbsd.org1e645fe2019-12-30 03:28:41 +0000880.Pp
881The options that are valid for user certificates are:
882.Pp
883.Bl -tag -width Ds -compact
884.It Ic clear
885Clear all enabled permissions.
886This is useful for clearing the default set of permissions so permissions may
887be added individually.
888.Pp
889.It Ic critical : Ns Ar name Ns Op Ns = Ns Ar contents
890.It Ic extension : Ns Ar name Ns Op Ns = Ns Ar contents
891Includes an arbitrary certificate critical option or extension.
892The specified
893.Ar name
894should include a domain suffix, e.g.\&
895.Dq name@example.com .
896If
897.Ar contents
898is specified then it is included as the contents of the extension/option
899encoded as a string, otherwise the extension/option is created with no
900contents (usually indicating a flag).
901Extensions may be ignored by a client or server that does not recognise them,
902whereas unknown critical options will cause the certificate to be refused.
903.Pp
904.It Ic force-command Ns = Ns Ar command
905Forces the execution of
906.Ar command
907instead of any shell or command specified by the user when
908the certificate is used for authentication.
909.Pp
910.It Ic no-agent-forwarding
911Disable
912.Xr ssh-agent 1
913forwarding (permitted by default).
914.Pp
915.It Ic no-port-forwarding
916Disable port forwarding (permitted by default).
917.Pp
918.It Ic no-pty
919Disable PTY allocation (permitted by default).
920.Pp
921.It Ic no-user-rc
922Disable execution of
923.Pa ~/.ssh/rc
924by
925.Xr sshd 8
926(permitted by default).
927.Pp
928.It Ic no-x11-forwarding
929Disable X11 forwarding (permitted by default).
930.Pp
931.It Ic permit-agent-forwarding
932Allows
933.Xr ssh-agent 1
934forwarding.
935.Pp
936.It Ic permit-port-forwarding
937Allows port forwarding.
938.Pp
939.It Ic permit-pty
940Allows PTY allocation.
941.Pp
942.It Ic permit-user-rc
943Allows execution of
944.Pa ~/.ssh/rc
945by
946.Xr sshd 8 .
947.Pp
948.It Ic permit-X11-forwarding
949Allows X11 forwarding.
950.Pp
951.It Ic no-touch-required
952Do not require signatures made using this key require demonstration
naddy@openbsd.orgb715fdc2020-01-18 21:16:43 +0000953of user presence (e.g. by having the user touch the authenticator).
naddy@openbsd.org84911da2020-01-18 15:45:41 +0000954This option only makes sense for the FIDO authenticator algorithms
djm@openbsd.org1e645fe2019-12-30 03:28:41 +0000955.Cm ecdsa-sk
956and
957.Cm ed25519-sk .
958.Pp
959.It Ic source-address Ns = Ns Ar address_list
960Restrict the source addresses from which the certificate is considered valid.
961The
962.Ar address_list
963is a comma-separated list of one or more address/netmask pairs in CIDR
964format.
965.El
966.Pp
967At present, no standard options are valid for host keys.
Damien Miller0a80ca12010-02-27 07:55:05 +1100968.Pp
969Finally, certificates may be defined with a validity lifetime.
970The
971.Fl V
972option allows specification of certificate start and end times.
973A certificate that is presented at a time outside this range will not be
974considered valid.
Darren Tucker3ee50c52012-09-06 21:18:11 +1000975By default, certificates are valid from
976.Ux
977Epoch to the distant future.
Damien Miller0a80ca12010-02-27 07:55:05 +1100978.Pp
979For certificates to be used for user or host authentication, the CA
980public key must be trusted by
981.Xr sshd 8
982or
983.Xr ssh 1 .
984Please refer to those manual pages for details.
Damien Millerf3747bf2013-01-18 11:44:04 +1100985.Sh KEY REVOCATION LISTS
986.Nm
987is able to manage OpenSSH format Key Revocation Lists (KRLs).
988These binary files specify keys or certificates to be revoked using a
Damien Miller13797712013-12-29 17:47:14 +1100989compact format, taking as little as one bit per certificate if they are being
Damien Millerf3747bf2013-01-18 11:44:04 +1100990revoked by serial number.
991.Pp
992KRLs may be generated using the
993.Fl k
994flag.
Damien Miller881a7a22013-01-20 22:34:46 +1100995This option reads one or more files from the command line and generates a new
Damien Millerf3747bf2013-01-18 11:44:04 +1100996KRL.
997The files may either contain a KRL specification (see below) or public keys,
998listed one per line.
999Plain public keys are revoked by listing their hash or contents in the KRL and
1000certificates revoked by serial number or key ID (if the serial is zero or
1001not available).
1002.Pp
1003Revoking keys using a KRL specification offers explicit control over the
1004types of record used to revoke keys and may be used to directly revoke
1005certificates by serial number or key ID without having the complete original
1006certificate on hand.
1007A KRL specification consists of lines containing one of the following directives
1008followed by a colon and some directive-specific information.
1009.Bl -tag -width Ds
Damien Millera0a7ee82013-01-20 22:35:06 +11001010.It Cm serial : Ar serial_number Ns Op - Ns Ar serial_number
Damien Millerf3747bf2013-01-18 11:44:04 +11001011Revokes a certificate with the specified serial number.
Damien Millerac5542b2013-01-20 22:33:02 +11001012Serial numbers are 64-bit values, not including zero and may be expressed
Damien Millerf3747bf2013-01-18 11:44:04 +11001013in decimal, hex or octal.
1014If two serial numbers are specified separated by a hyphen, then the range
1015of serial numbers including and between each is revoked.
1016The CA key must have been specified on the
1017.Nm
Damien Miller881a7a22013-01-20 22:34:46 +11001018command line using the
Damien Millerf3747bf2013-01-18 11:44:04 +11001019.Fl s
1020option.
1021.It Cm id : Ar key_id
1022Revokes a certificate with the specified key ID string.
1023The CA key must have been specified on the
1024.Nm
Damien Miller881a7a22013-01-20 22:34:46 +11001025command line using the
Damien Millerf3747bf2013-01-18 11:44:04 +11001026.Fl s
1027option.
1028.It Cm key : Ar public_key
1029Revokes the specified key.
Damien Millerac5542b2013-01-20 22:33:02 +11001030If a certificate is listed, then it is revoked as a plain public key.
Damien Millerf3747bf2013-01-18 11:44:04 +11001031.It Cm sha1 : Ar public_key
djm@openbsd.org9405c622018-09-12 01:21:34 +00001032Revokes the specified key by including its SHA1 hash in the KRL.
1033.It Cm sha256 : Ar public_key
1034Revokes the specified key by including its SHA256 hash in the KRL.
1035KRLs that revoke keys by SHA256 hash are not supported by OpenSSH versions
1036prior to 7.9.
1037.It Cm hash : Ar fingerprint
djm@openbsd.orgf0fcd7e2018-09-12 06:18:59 +00001038Revokes a key using a fingerprint hash, as obtained from a
djm@openbsd.org9405c622018-09-12 01:21:34 +00001039.Xr sshd 8
1040authentication log message or the
1041.Nm
1042.Fl l
1043flag.
1044Only SHA256 fingerprints are supported here and resultant KRLs are
1045not supported by OpenSSH versions prior to 7.9.
Damien Millerf3747bf2013-01-18 11:44:04 +11001046.El
1047.Pp
1048KRLs may be updated using the
1049.Fl u
1050flag in addition to
1051.Fl k .
Damien Miller881a7a22013-01-20 22:34:46 +11001052When this option is specified, keys listed via the command line are merged into
Damien Millerf3747bf2013-01-18 11:44:04 +11001053the KRL, adding to those already there.
1054.Pp
1055It is also possible, given a KRL, to test whether it revokes a particular key
1056(or keys).
1057The
1058.Fl Q
jmc@openbsd.org8b290082015-11-05 09:48:05 +00001059flag will query an existing KRL, testing each key specified on the command line.
Damien Miller881a7a22013-01-20 22:34:46 +11001060If any key listed on the command line has been revoked (or an error encountered)
Damien Millerf3747bf2013-01-18 11:44:04 +11001061then
1062.Nm
1063will exit with a non-zero exit status.
1064A zero exit status will only be returned if no key was revoked.
djm@openbsd.org2a9c9f72019-09-03 08:34:19 +00001065.Sh ALLOWED SIGNERS
1066When verifying signatures,
1067.Nm
1068uses a simple list of identities and keys to determine whether a signature
1069comes from an authorized source.
1070This "allowed signers" file uses a format patterned after the
1071AUTHORIZED_KEYS FILE FORMAT described in
jmc@openbsd.orgdb1e6f62019-09-04 05:56:54 +00001072.Xr sshd 8 .
djm@openbsd.org2a9c9f72019-09-03 08:34:19 +00001073Each line of the file contains the following space-separated fields:
1074principals, options, keytype, base64-encoded key.
1075Empty lines and lines starting with a
1076.Ql #
1077are ignored as comments.
1078.Pp
1079The principals field is a pattern-list (See PATTERNS in
1080.Xr ssh_config 5 )
1081consisting of one or more comma-separated USER@DOMAIN identity patterns
1082that are accepted for signing.
1083When verifying, the identity presented via the
jmc@openbsd.org70fc9a62019-10-22 08:50:35 +00001084.Fl I
1085option must match a principals pattern in order for the corresponding key to be
djm@openbsd.org2a9c9f72019-09-03 08:34:19 +00001086considered acceptable for verification.
1087.Pp
1088The options (if present) consist of comma-separated option specifications.
1089No spaces are permitted, except within double quotes.
1090The following option specifications are supported (note that option keywords
1091are case-insensitive):
1092.Bl -tag -width Ds
1093.It Cm cert-authority
1094Indicates that this key is accepted as a certificate authority (CA) and
1095that certificates signed by this CA may be accepted for verification.
1096.It Cm namespaces="namespace-list"
1097Specifies a pattern-list of namespaces that are accepted for this key.
djm@openbsd.orgd637c4a2019-09-03 08:35:27 +00001098If this option is present, the signature namespace embedded in the
djm@openbsd.org2a9c9f72019-09-03 08:34:19 +00001099signature object and presented on the verification command-line must
1100match the specified list before the key will be considered acceptable.
1101.El
1102.Pp
1103When verifying signatures made by certificates, the expected principal
1104name must match both the principals pattern in the allowed signers file and
1105the principals embedded in the certificate itself.
1106.Pp
1107An example allowed signers file:
1108.Bd -literal -offset 3n
1109# Comments allowed at start of line
1110user1@example.com,user2@example.com ssh-rsa AAAAX1...
1111# A certificate authority, trusted for all principals in a domain.
1112*@example.com cert-authority ssh-ed25519 AAAB4...
1113# A key that is accepted only for file signing.
1114user2@example.com namespaces="file" ssh-ed25519 AAA41...
1115.Ed
naddy@openbsd.orgaa4c6402019-11-07 08:38:38 +00001116.Sh ENVIRONMENT
1117.Bl -tag -width Ds
1118.It Ev SSH_SK_PROVIDER
djm@openbsd.org963d7182020-02-07 03:57:31 +00001119Specifies a path to a library that will be used when loading any
1120FIDO authenticator-hosted keys, overriding the default of using
1121the built-in USB HID support.
naddy@openbsd.orgaa4c6402019-11-07 08:38:38 +00001122.El
Damien Miller32aa1441999-10-29 09:15:49 +10001123.Sh FILES
Damien Miller6186bbc2010-09-24 22:00:54 +10001124.Bl -tag -width Ds -compact
Damien Miller167ea5d2005-05-26 12:04:02 +10001125.It Pa ~/.ssh/id_dsa
Damien Miller6186bbc2010-09-24 22:00:54 +10001126.It Pa ~/.ssh/id_ecdsa
naddy@openbsd.orgaa4c6402019-11-07 08:38:38 +00001127.It Pa ~/.ssh/id_ecdsa_sk
Damien Miller8ba0ead2013-12-18 17:46:27 +11001128.It Pa ~/.ssh/id_ed25519
naddy@openbsd.orgf0edda82019-11-18 23:16:49 +00001129.It Pa ~/.ssh/id_ed25519_sk
Damien Miller167ea5d2005-05-26 12:04:02 +10001130.It Pa ~/.ssh/id_rsa
naddy@openbsd.org141df482019-12-21 20:22:34 +00001131Contains the DSA, ECDSA, authenticator-hosted ECDSA, Ed25519,
1132authenticator-hosted Ed25519 or RSA authentication identity of the user.
Ben Lindstrom18a82ac2001-04-11 15:59:35 +00001133This file should not be readable by anyone but the user.
1134It is possible to
1135specify a passphrase when generating the key; that passphrase will be
Darren Tucker199ee6f2009-10-24 11:50:17 +11001136used to encrypt the private part of this file using 128-bit AES.
Ben Lindstrom18a82ac2001-04-11 15:59:35 +00001137This file is not automatically accessed by
1138.Nm
1139but it is offered as the default file for the private key.
Ben Lindstrombda98b02001-07-04 03:35:24 +00001140.Xr ssh 1
Ben Lindstrom18a82ac2001-04-11 15:59:35 +00001141will read this file when a login attempt is made.
Damien Miller6186bbc2010-09-24 22:00:54 +10001142.Pp
1143.It Pa ~/.ssh/id_dsa.pub
1144.It Pa ~/.ssh/id_ecdsa.pub
naddy@openbsd.orgaa4c6402019-11-07 08:38:38 +00001145.It Pa ~/.ssh/id_ecdsa_sk.pub
Damien Miller8ba0ead2013-12-18 17:46:27 +11001146.It Pa ~/.ssh/id_ed25519.pub
naddy@openbsd.orgf0edda82019-11-18 23:16:49 +00001147.It Pa ~/.ssh/id_ed25519_sk.pub
Damien Miller167ea5d2005-05-26 12:04:02 +10001148.It Pa ~/.ssh/id_rsa.pub
naddy@openbsd.org141df482019-12-21 20:22:34 +00001149Contains the DSA, ECDSA, authenticator-hosted ECDSA, Ed25519,
1150authenticator-hosted Ed25519 or RSA public key for authentication.
Damien Millere247cc42000-05-07 12:03:14 +10001151The contents of this file should be added to
Damien Miller167ea5d2005-05-26 12:04:02 +10001152.Pa ~/.ssh/authorized_keys
Damien Millere247cc42000-05-07 12:03:14 +10001153on all machines
Ben Lindstrom594e2032001-09-12 18:35:30 +00001154where the user wishes to log in using public key authentication.
Damien Millere247cc42000-05-07 12:03:14 +10001155There is no need to keep the contents of this file secret.
Damien Miller6186bbc2010-09-24 22:00:54 +10001156.Pp
Darren Tucker019cefe2003-08-02 22:40:07 +10001157.It Pa /etc/moduli
1158Contains Diffie-Hellman groups used for DH-GEX.
1159The file format is described in
1160.Xr moduli 5 .
Damien Miller37023962000-07-11 17:31:38 +10001161.El
Damien Miller32aa1441999-10-29 09:15:49 +10001162.Sh SEE ALSO
1163.Xr ssh 1 ,
1164.Xr ssh-add 1 ,
Damien Miller2e8b1c81999-11-15 23:33:56 +11001165.Xr ssh-agent 1 ,
Darren Tucker019cefe2003-08-02 22:40:07 +10001166.Xr moduli 5 ,
Ben Lindstrom77788dc2001-02-10 23:10:33 +00001167.Xr sshd 8
Ben Lindstrom5a707822001-04-22 17:15:46 +00001168.Rs
Damien Millerc0367fb2007-01-05 16:25:46 +11001169.%R RFC 4716
1170.%T "The Secure Shell (SSH) Public Key File Format"
1171.%D 2006
Ben Lindstrom5a707822001-04-22 17:15:46 +00001172.Re
Damien Millerf1ce5052003-06-11 22:04:39 +10001173.Sh AUTHORS
1174OpenSSH is a derivative of the original and free
1175ssh 1.2.12 release by Tatu Ylonen.
1176Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos,
1177Theo de Raadt and Dug Song
1178removed many bugs, re-added newer features and
1179created OpenSSH.
1180Markus Friedl contributed the support for SSH
1181protocol versions 1.5 and 2.0.