blob: c0a22606b86500e9bea16a279b96889625b72e76 [file] [log] [blame]
naddy@openbsd.orgb715fdc2020-01-18 21:16:43 +00001.\" $OpenBSD: ssh-keygen.1,v 1.193 2020/01/18 21:16:43 naddy 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.\"
naddy@openbsd.org84911da2020-01-18 15:45:41 +000038.Dd $Mdocdate: January 18 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
jmc@openbsd.org69189742019-10-03 17:07:50 +0000141.Fl Y Cm check-novalidate
142.Fl n Ar namespace
143.Fl s Ar signature_file
144.Nm ssh-keygen
djm@openbsd.org2a9c9f72019-09-03 08:34:19 +0000145.Fl Y Cm sign
146.Fl f Ar key_file
147.Fl n Ar namespace
148.Ar
149.Nm ssh-keygen
150.Fl Y Cm verify
djm@openbsd.org8aa2aa32019-09-16 03:23:02 +0000151.Fl f Ar allowed_signers_file
jmc@openbsd.org69189742019-10-03 17:07:50 +0000152.Fl I Ar signer_identity
djm@openbsd.org2a9c9f72019-09-03 08:34:19 +0000153.Fl n Ar namespace
154.Fl s Ar signature_file
155.Op Fl r Ar revocation_file
Damien Miller22c77262000-04-13 12:26:34 +1000156.Sh DESCRIPTION
Damien Miller32aa1441999-10-29 09:15:49 +1000157.Nm
Ben Lindstrom5a707822001-04-22 17:15:46 +0000158generates, manages and converts authentication keys for
Damien Miller32aa1441999-10-29 09:15:49 +1000159.Xr ssh 1 .
Damien Millere247cc42000-05-07 12:03:14 +1000160.Nm
jmc@openbsd.org2b6f7992017-05-03 06:32:02 +0000161can create keys for use by SSH protocol version 2.
jmc@openbsd.orga685ae82016-02-17 07:38:19 +0000162.Pp
Damien Millerfbf486b2003-05-23 18:44:23 +1000163The type of key to be generated is specified with the
Damien Miller0bc1bd82000-11-13 22:57:25 +1100164.Fl t
Damien Millera41c8b12002-01-22 23:05:08 +1100165option.
Damien Millerf14be5c2005-11-05 15:15:49 +1100166If invoked without any arguments,
167.Nm
naddy@openbsd.org2e9c3242017-05-05 10:41:58 +0000168will generate an RSA key.
Damien Millere247cc42000-05-07 12:03:14 +1000169.Pp
Darren Tucker019cefe2003-08-02 22:40:07 +1000170.Nm
171is also used to generate groups for use in Diffie-Hellman group
172exchange (DH-GEX).
173See the
174.Sx MODULI GENERATION
175section for details.
176.Pp
Damien Millerf3747bf2013-01-18 11:44:04 +1100177Finally,
178.Nm
179can be used to generate and update Key Revocation Lists, and to test whether
Damien Millerac5542b2013-01-20 22:33:02 +1100180given keys have been revoked by one.
181See the
Damien Millerf3747bf2013-01-18 11:44:04 +1100182.Sx KEY REVOCATION LISTS
183section for details.
184.Pp
Damien Miller32aa1441999-10-29 09:15:49 +1000185Normally each user wishing to use SSH
Damien Millereb8b60e2010-08-31 22:41:14 +1000186with public key authentication runs this once to create the authentication
Damien Miller32aa1441999-10-29 09:15:49 +1000187key in
Damien Miller8ba0ead2013-12-18 17:46:27 +1100188.Pa ~/.ssh/id_dsa ,
Damien Millereb8b60e2010-08-31 22:41:14 +1000189.Pa ~/.ssh/id_ecdsa ,
naddy@openbsd.orgaa4c6402019-11-07 08:38:38 +0000190.Pa ~/.ssh/id_ecdsa_sk ,
naddy@openbsd.orgf0edda82019-11-18 23:16:49 +0000191.Pa ~/.ssh/id_ed25519 ,
192.Pa ~/.ssh/id_ed25519_sk
Damien Millere247cc42000-05-07 12:03:14 +1000193or
Damien Miller167ea5d2005-05-26 12:04:02 +1000194.Pa ~/.ssh/id_rsa .
Damien Millere247cc42000-05-07 12:03:14 +1000195Additionally, the system administrator may use this to generate host keys,
196as seen in
197.Pa /etc/rc .
Damien Miller32aa1441999-10-29 09:15:49 +1000198.Pp
199Normally this program generates the key and asks for a file in which
Damien Miller450a7a12000-03-26 13:04:51 +1000200to store the private key.
201The public key is stored in a file with the same name but
Damien Miller32aa1441999-10-29 09:15:49 +1000202.Dq .pub
Damien Miller450a7a12000-03-26 13:04:51 +1000203appended.
204The program also asks for a passphrase.
205The passphrase may be empty to indicate no passphrase
Ben Lindstrombf555ba2001-01-18 02:04:35 +0000206(host keys must have an empty passphrase), or it may be a string of
Damien Miller450a7a12000-03-26 13:04:51 +1000207arbitrary length.
Ben Lindstrom4e366d52001-12-06 16:43:21 +0000208A passphrase is similar to a password, except it can be a phrase with a
209series of words, punctuation, numbers, whitespace, or any string of
210characters you want.
211Good passphrases are 10-30 characters long, are
Damien Miller32aa1441999-10-29 09:15:49 +1000212not simple sentences or otherwise easily guessable (English
Ben Lindstrom2a097a42001-06-09 01:13:40 +0000213prose has only 1-2 bits of entropy per character, and provides very bad
Ben Lindstrom4e366d52001-12-06 16:43:21 +0000214passphrases), and contain a mix of upper and lowercase letters,
215numbers, and non-alphanumeric characters.
Damien Miller450a7a12000-03-26 13:04:51 +1000216The passphrase can be changed later by using the
Damien Miller32aa1441999-10-29 09:15:49 +1000217.Fl p
218option.
219.Pp
Damien Miller450a7a12000-03-26 13:04:51 +1000220There is no way to recover a lost passphrase.
Damien Miller085c90f2011-05-05 14:15:33 +1000221If the passphrase is lost or forgotten, a new key must be generated
222and the corresponding public key copied to other machines.
Damien Miller32aa1441999-10-29 09:15:49 +1000223.Pp
djm@openbsd.orgc45616a2019-01-22 11:00:15 +0000224.Nm
225will by default write keys in an OpenSSH-specific format.
226This format is preferred as it offers better protection for
227keys at rest as well as allowing storage of key comments within
228the private key file itself.
229The key comment may be useful to help identify the key.
Damien Miller450a7a12000-03-26 13:04:51 +1000230The comment is initialized to
Damien Miller32aa1441999-10-29 09:15:49 +1000231.Dq user@host
232when the key is created, but can be changed using the
233.Fl c
234option.
235.Pp
djm@openbsd.orgc45616a2019-01-22 11:00:15 +0000236It is still possible for
237.Nm
238to write the previously-used PEM format private keys using the
239.Fl m
240flag.
241This may be used when generating new keys, and existing new-format
242keys may be converted using this option in conjunction with the
243.Fl p
244(change passphrase) flag.
245.Pp
Damien Millere247cc42000-05-07 12:03:14 +1000246After a key is generated, instructions below detail where the keys
247should be placed to be activated.
248.Pp
Damien Miller32aa1441999-10-29 09:15:49 +1000249The options are as follows:
250.Bl -tag -width Ds
Damien Miller58f1baf2011-05-05 14:06:15 +1000251.It Fl A
djm@openbsd.org97dc5d12019-11-18 04:50:45 +0000252For each of the key types (rsa, dsa, ecdsa and ed25519)
Damien Miller8ba0ead2013-12-18 17:46:27 +1100253for which host keys
Damien Miller58f1baf2011-05-05 14:06:15 +1000254do not exist, generate the host keys with the default key file path,
255an empty passphrase, default bits for the key type, and default comment.
jmc@openbsd.orgdc44dd32017-07-08 18:32:54 +0000256If
djm@openbsd.org853edbe2017-07-07 03:53:12 +0000257.Fl f
jmc@openbsd.orgdc44dd32017-07-08 18:32:54 +0000258has also been specified, its argument is used as a prefix to the
djm@openbsd.org853edbe2017-07-07 03:53:12 +0000259default path for the resulting host key files.
Damien Miller3ca1eb32011-05-05 14:13:50 +1000260This is used by
Damien Miller58f1baf2011-05-05 14:06:15 +1000261.Pa /etc/rc
262to generate new host keys.
Damien Miller4f752cf2013-12-18 17:45:35 +1100263.It Fl a Ar rounds
jmc@openbsd.org3b44bf32019-09-27 20:03:24 +0000264When saving a private key, this option specifies the number of KDF
djm@openbsd.orged7bd5d2018-08-08 01:16:01 +0000265(key derivation function) rounds used.
Damien Miller4f752cf2013-12-18 17:45:35 +1100266Higher numbers result in slower passphrase verification and increased
267resistance to brute-force password cracking (should the keys be stolen).
Damien Miller265d3092005-03-02 12:05:06 +1100268.It Fl B
269Show the bubblebabble digest of specified private or public key file.
Damien Miller32aa1441999-10-29 09:15:49 +1000270.It Fl b Ar bits
Damien Miller450a7a12000-03-26 13:04:51 +1000271Specifies the number of bits in the key to create.
dtucker@openbsd.orgd7c6e382019-04-19 05:47:44 +0000272For RSA keys, the minimum size is 1024 bits and the default is 3072 bits.
273Generally, 3072 bits is considered sufficient.
Darren Tucker9f647332005-11-28 16:41:46 +1100274DSA keys must be exactly 1024 bits as specified by FIPS 186-2.
Damien Millerad210322011-05-05 14:15:54 +1000275For ECDSA keys, the
276.Fl b
Damien Miller6232a162011-09-22 21:36:00 +1000277flag determines the key length by selecting from one of three elliptic
Damien Millerad210322011-05-05 14:15:54 +1000278curve sizes: 256, 384 or 521 bits.
279Attempting to use bit lengths other than these three values for ECDSA keys
280will fail.
naddy@openbsd.orgf0edda82019-11-18 23:16:49 +0000281ECDSA-SK, Ed25519 and Ed25519-SK keys have a fixed length and the
Damien Miller8ba0ead2013-12-18 17:46:27 +1100282.Fl b
283flag will be ignored.
Damien Miller265d3092005-03-02 12:05:06 +1100284.It Fl C Ar comment
285Provides a new comment.
Damien Miller32aa1441999-10-29 09:15:49 +1000286.It Fl c
287Requests changing the comment in the private and public key files.
288The program will prompt for the file containing the private keys, for
Ben Lindstromaafff9c2001-05-06 03:01:02 +0000289the passphrase if the key has one, and for the new comment.
Damien Miller7ea845e2010-02-12 09:21:02 +1100290.It Fl D Ar pkcs11
naddy@openbsd.orgc13b7452019-03-05 16:17:12 +0000291Download the public keys provided by the PKCS#11 shared library
Damien Millera7618442010-02-12 09:26:02 +1100292.Ar pkcs11 .
Damien Miller757f34e2010-08-05 13:05:31 +1000293When used in combination with
294.Fl s ,
295this option indicates that a CA key resides in a PKCS#11 token (see the
296.Sx CERTIFICATES
297section for details).
djm@openbsd.org56d1c832014-12-21 22:27:55 +0000298.It Fl E Ar fingerprint_hash
299Specifies the hash algorithm used when displaying key fingerprints.
300Valid options are:
301.Dq md5
302and
303.Dq sha256 .
304The default is
305.Dq sha256 .
Ben Lindstrom5a707822001-04-22 17:15:46 +0000306.It Fl e
Ben Lindstrom46c264f2001-04-24 16:56:58 +0000307This option will read a private or public OpenSSH key file and
djm@openbsd.org180b5202019-01-22 11:19:42 +0000308print to stdout a public key in one of the formats specified by the
Damien Miller44b25042010-07-02 13:35:01 +1000309.Fl m
310option.
311The default export format is
312.Dq RFC4716 .
Damien Millerea727282010-07-02 13:35:34 +1000313This option allows exporting OpenSSH keys for use by other programs, including
Damien Miller44b25042010-07-02 13:35:01 +1000314several commercial SSH implementations.
djm@openbsd.org737e4ed2018-12-07 03:32:26 +0000315.It Fl F Ar hostname | [hostname]:port
Damien Miller265d3092005-03-02 12:05:06 +1100316Search for the specified
317.Ar hostname
djm@openbsd.org737e4ed2018-12-07 03:32:26 +0000318(with optional port number)
Damien Miller265d3092005-03-02 12:05:06 +1100319in a
320.Pa known_hosts
321file, listing any occurrences found.
322This option is useful to find hashed host names or addresses and may also be
323used in conjunction with the
324.Fl H
325option to print found keys in a hashed format.
326.It Fl f Ar filename
327Specifies the filename of the key file.
Damien Miller37876e92003-05-15 10:19:46 +1000328.It Fl g
Darren Tucker0b42e6d2004-08-13 21:22:40 +1000329Use generic DNS format when printing fingerprint resource records using the
Darren Tucker6e370372004-08-13 21:23:25 +1000330.Fl r
Darren Tucker0b42e6d2004-08-13 21:22:40 +1000331command.
Damien Miller265d3092005-03-02 12:05:06 +1100332.It Fl H
333Hash a
334.Pa known_hosts
Darren Tuckerda1adbc2005-03-14 23:15:58 +1100335file.
336This replaces all hostnames and addresses with hashed representations
337within the specified file; the original content is moved to a file with
338a .old suffix.
Damien Miller265d3092005-03-02 12:05:06 +1100339These hashes may be used normally by
340.Nm ssh
341and
342.Nm sshd ,
343but they do not reveal identifying information should the file's contents
344be disclosed.
345This option will not modify existing hashed hostnames and is therefore safe
346to use on files that mix hashed and non-hashed names.
Damien Miller0a80ca12010-02-27 07:55:05 +1100347.It Fl h
348When signing a key, create a host certificate instead of a user
349certificate.
350Please see the
351.Sx CERTIFICATES
352section for details.
Damien Miller15f5b562010-03-03 10:25:21 +1100353.It Fl I Ar certificate_identity
Damien Miller0a80ca12010-02-27 07:55:05 +1100354Specify the key identity when signing a public key.
355Please see the
356.Sx CERTIFICATES
357section for details.
Ben Lindstrom5a707822001-04-22 17:15:46 +0000358.It Fl i
359This option will read an unencrypted private (or public) key file
Damien Miller44b25042010-07-02 13:35:01 +1000360in the format specified by the
361.Fl m
362option and print an OpenSSH compatible private
Ben Lindstrom5a707822001-04-22 17:15:46 +0000363(or public) key to stdout.
Damien Miller43b156c2014-04-20 13:23:03 +1000364This option allows importing keys from other software, including several
365commercial SSH implementations.
366The default import format is
367.Dq RFC4716 .
jmc@openbsd.orgc593cc52020-01-03 07:33:33 +0000368.It Fl K
djm@openbsd.org90399712020-01-02 22:40:09 +0000369Download resident keys from a FIDO authenticator.
370Public and private key files will be written to the current directory for
371each downloaded key.
372.It Fl k
Damien Millerf3747bf2013-01-18 11:44:04 +1100373Generate a KRL file.
374In this mode,
375.Nm
376will generate a KRL file at the location specified via the
377.Fl f
Damien Miller881a7a22013-01-20 22:34:46 +1100378flag that revokes every key or certificate presented on the command line.
Damien Millerf3747bf2013-01-18 11:44:04 +1100379Keys/certificates to be revoked may be specified by public key file or
380using the format described in the
381.Sx KEY REVOCATION LISTS
382section.
Damien Millerf2b70ca2010-03-05 07:39:35 +1100383.It Fl L
djm@openbsd.org94bc0b72015-11-13 04:34:15 +0000384Prints the contents of one or more certificates.
Damien Miller10f6f6b1999-11-17 17:29:08 +1100385.It Fl l
Darren Tucker35c45532008-06-13 04:43:15 +1000386Show fingerprint of specified public key file.
Damien Millereb5fec62001-11-12 10:52:44 +1100387For RSA and DSA keys
388.Nm
Darren Tuckerf09e8252008-06-13 05:18:03 +1000389tries to find the matching public key file and prints its fingerprint.
390If combined with
391.Fl v ,
jmc@openbsd.org92838842016-05-03 18:38:12 +0000392a visual ASCII art representation of the key is supplied with the
djm@openbsd.orgcdcd9412016-05-03 14:54:08 +0000393fingerprint.
djm@openbsd.org3e60d182019-12-30 03:30:09 +0000394.It Fl M Cm generate
395Generate candidate Diffie-Hellman Group Exchange (DH-GEX) parameters for
396eventual use by the
397.Sq diffie-hellman-group-exchange-*
398key exchange methods.
399The numbers generated by this operation must be further screened before
400use.
401See the
402.Sx MODULI GENERATION
403section for more information.
404.It Fl M Cm screen
405Screen candidate parameters for Diffie-Hellman Group Exchange.
406This will accept a list of candidate numbers and test that they are
407safe (Sophie Germain) primes with acceptable group generators.
408The results of this operation may be added to the
409.Pa /etc/moduli
410file.
411See the
412.Sx MODULI GENERATION
413section for more information.
Damien Miller44b25042010-07-02 13:35:01 +1000414.It Fl m Ar key_format
djm@openbsd.orgecd2f332019-01-22 11:40:42 +0000415Specify a key format for key generation, the
Damien Miller44b25042010-07-02 13:35:01 +1000416.Fl i
djm@openbsd.orgecd2f332019-01-22 11:40:42 +0000417(import),
Damien Miller44b25042010-07-02 13:35:01 +1000418.Fl e
djm@openbsd.orgecd2f332019-01-22 11:40:42 +0000419(export) conversion options, and the
420.Fl p
421change passphrase operation.
422The latter may be used to convert between OpenSSH private key and PEM
423private key formats.
Damien Miller44b25042010-07-02 13:35:01 +1000424The supported key formats are:
425.Dq RFC4716
Damien Millerea727282010-07-02 13:35:34 +1000426(RFC 4716/SSH2 public or private key),
Damien Miller44b25042010-07-02 13:35:01 +1000427.Dq PKCS8
djm@openbsd.orgeb0d8e72019-07-15 13:16:29 +0000428(PKCS8 public or private key)
Damien Miller44b25042010-07-02 13:35:01 +1000429or
430.Dq PEM
431(PEM public key).
djm@openbsd.orgeb0d8e72019-07-15 13:16:29 +0000432By default OpenSSH will write newly-generated private keys in its own
433format, but when converting public keys for export the default format is
Damien Miller44b25042010-07-02 13:35:01 +1000434.Dq RFC4716 .
djm@openbsd.orged7bd5d2018-08-08 01:16:01 +0000435Setting a format of
436.Dq PEM
437when generating or updating a supported private key type will cause the
438key to be stored in the legacy PEM private key format.
Damien Miller265d3092005-03-02 12:05:06 +1100439.It Fl N Ar new_passphrase
440Provides the new passphrase.
Damien Miller0a80ca12010-02-27 07:55:05 +1100441.It Fl n Ar principals
442Specify one or more principals (user or host names) to be included in
443a certificate when signing a key.
444Multiple principals may be specified, separated by commas.
445Please see the
446.Sx CERTIFICATES
447section for details.
Damien Miller4e270b02010-04-16 15:56:21 +1000448.It Fl O Ar option
djm@openbsd.org3e60d182019-12-30 03:30:09 +0000449Specify a key/value option.
450These are specific to the operation that
451.Nm
452has been requested to perform.
453.Pp
454When signing certificates, one of the options listed in the
Damien Miller0a80ca12010-02-27 07:55:05 +1100455.Sx CERTIFICATES
djm@openbsd.org3e60d182019-12-30 03:30:09 +0000456section may be specified here.
457.Pp
458When performing moduli generation or screening, one of the options
459listed in the
460.Sx MODULI GENERATION
461section may be specified.
462.Pp
jmc@openbsd.orgcd534762020-01-06 07:43:28 +0000463When generating a key that will be hosted on a FIDO authenticator,
464this flag may be used to specify key-specific options.
465Those supported at present are:
466.Bl -tag -width Ds
467.It Cm application
468Override the default FIDO application/origin string of
djm@openbsd.orgc312ca02020-01-06 02:00:46 +0000469.Dq ssh: .
jmc@openbsd.orgcd534762020-01-06 07:43:28 +0000470This may be useful when generating host or domain-specific resident keys.
471.It Cm device
472Explicitly specify a
djm@openbsd.orgc312ca02020-01-06 02:00:46 +0000473.Xr fido 4
474device to use, rather than letting the token middleware select one.
jmc@openbsd.orgcd534762020-01-06 07:43:28 +0000475.It Cm no-touch-required
476Indicate that the generated private key should not require touch
djm@openbsd.org3093d122019-12-30 09:49:52 +0000477events (user presence) when making signatures.
478Note that
479.Xr sshd 8
480will refuse such signatures by default, unless overridden via
481an authorized_keys option.
jmc@openbsd.orgcd534762020-01-06 07:43:28 +0000482.It Cm resident
483Indicate that the key should be stored on the FIDO authenticator itself.
djm@openbsd.org3093d122019-12-30 09:49:52 +0000484Resident keys may be supported on FIDO2 tokens and typically require that
485a PIN be set on the token prior to generation.
486Resident keys may be loaded off the token using
487.Xr ssh-add 1 .
jmc@openbsd.orgcd534762020-01-06 07:43:28 +0000488.It Cm user
489A username to be associated with a resident key,
djm@openbsd.orgc312ca02020-01-06 02:00:46 +0000490overriding the empty default username.
491Specifying a username may be useful when generating multiple resident keys
492for the same application name.
jmc@openbsd.orgcd534762020-01-06 07:43:28 +0000493.El
djm@openbsd.org3093d122019-12-30 09:49:52 +0000494.Pp
495The
496.Fl O
497option may be specified multiple times.
Damien Miller265d3092005-03-02 12:05:06 +1100498.It Fl P Ar passphrase
499Provides the (old) passphrase.
Damien Miller32aa1441999-10-29 09:15:49 +1000500.It Fl p
501Requests changing the passphrase of a private key file instead of
Damien Miller450a7a12000-03-26 13:04:51 +1000502creating a new private key.
503The program will prompt for the file
Damien Miller32aa1441999-10-29 09:15:49 +1000504containing the private key, for the old passphrase, and twice for the
505new passphrase.
Damien Miller072fdcd2013-01-20 22:34:04 +1100506.It Fl Q
507Test whether keys have been revoked in a KRL.
Damien Miller32aa1441999-10-29 09:15:49 +1000508.It Fl q
509Silence
510.Nm ssh-keygen .
djm@openbsd.org63bba572018-12-07 03:33:18 +0000511.It Fl R Ar hostname | [hostname]:port
djm@openbsd.org737e4ed2018-12-07 03:32:26 +0000512Removes all keys belonging to the specified
Damien Miller4b42d7f2005-03-01 21:48:35 +1100513.Ar hostname
djm@openbsd.org737e4ed2018-12-07 03:32:26 +0000514(with optional port number)
Damien Miller4c9c6fd2005-03-02 12:03:43 +1100515from a
Damien Miller4b42d7f2005-03-01 21:48:35 +1100516.Pa known_hosts
517file.
Damien Miller4c9c6fd2005-03-02 12:03:43 +1100518This option is useful to delete hashed hosts (see the
Damien Miller4b42d7f2005-03-01 21:48:35 +1100519.Fl H
520option above).
Damien Miller265d3092005-03-02 12:05:06 +1100521.It Fl r Ar hostname
522Print the SSHFP fingerprint resource record named
523.Ar hostname
524for the specified public key file.
Damien Miller0a80ca12010-02-27 07:55:05 +1100525.It Fl s Ar ca_key
526Certify (sign) a public key using the specified CA key.
527Please see the
528.Sx CERTIFICATES
529section for details.
Damien Millerf3747bf2013-01-18 11:44:04 +1100530.Pp
531When generating a KRL,
532.Fl s
Damien Millerac5542b2013-01-20 22:33:02 +1100533specifies a path to a CA public key file used to revoke certificates directly
Damien Millerf3747bf2013-01-18 11:44:04 +1100534by key ID or serial number.
535See the
536.Sx KEY REVOCATION LISTS
537section for details.
djm@openbsd.org97dc5d12019-11-18 04:50:45 +0000538.It Fl t Cm dsa | ecdsa | ecdsa-sk | ed25519 | ed25519-sk | rsa
Damien Miller265d3092005-03-02 12:05:06 +1100539Specifies the type of key to create.
540The possible values are
Damien Miller6186bbc2010-09-24 22:00:54 +1000541.Dq dsa ,
Damien Miller8ba0ead2013-12-18 17:46:27 +1100542.Dq ecdsa ,
naddy@openbsd.orgaa4c6402019-11-07 08:38:38 +0000543.Dq ecdsa-sk ,
Damien Miller8ba0ead2013-12-18 17:46:27 +1100544.Dq ed25519 ,
djm@openbsd.org97dc5d12019-11-18 04:50:45 +0000545.Dq ed25519-sk ,
Damien Miller265d3092005-03-02 12:05:06 +1100546or
jmc@openbsd.orgf10c0d32017-05-02 17:04:09 +0000547.Dq rsa .
djm@openbsd.org476e3552019-05-20 00:20:35 +0000548.Pp
549This flag may also be used to specify the desired signature type when
jmc@openbsd.org85ceb0e2019-05-20 06:01:59 +0000550signing certificates using an RSA CA key.
djm@openbsd.org476e3552019-05-20 00:20:35 +0000551The available RSA signature variants are
552.Dq ssh-rsa
553(SHA1 signatures, not recommended),
jmc@openbsd.org85ceb0e2019-05-20 06:01:59 +0000554.Dq rsa-sha2-256 ,
555and
djm@openbsd.org476e3552019-05-20 00:20:35 +0000556.Dq rsa-sha2-512
557(the default).
djm@openbsd.orga98339e2017-06-28 01:09:22 +0000558.It Fl U
559When used in combination with
560.Fl s ,
561this option indicates that a CA key resides in a
562.Xr ssh-agent 1 .
563See the
564.Sx CERTIFICATES
565section for more information.
Damien Millerac5542b2013-01-20 22:33:02 +1100566.It Fl u
567Update a KRL.
568When specified with
569.Fl k ,
Damien Miller881a7a22013-01-20 22:34:46 +1100570keys listed via the command line are added to the existing KRL rather than
Damien Millerac5542b2013-01-20 22:33:02 +1100571a new KRL being created.
Damien Miller0a80ca12010-02-27 07:55:05 +1100572.It Fl V Ar validity_interval
573Specify a validity interval when signing a certificate.
574A validity interval may consist of a single time, indicating that the
575certificate is valid beginning now and expiring at that time, or may consist
576of two times separated by a colon to indicate an explicit time interval.
djm@openbsd.org@openbsd.orgd52131a2017-11-03 05:14:04 +0000577.Pp
578The start time may be specified as the string
579.Dq always
580to indicate the certificate has no specified start time,
djm@openbsd.orgbf0fbf22018-03-12 00:52:01 +0000581a date in YYYYMMDD format, a time in YYYYMMDDHHMM[SS] format,
djm@openbsd.org@openbsd.orgd52131a2017-11-03 05:14:04 +0000582a relative time (to the current time) consisting of a minus sign followed by
583an interval in the format described in the
Damien Millerfecfd112013-07-18 16:11:50 +1000584TIME FORMATS section of
Damien Miller77497e12010-03-22 05:50:51 +1100585.Xr sshd_config 5 .
djm@openbsd.org@openbsd.orgd52131a2017-11-03 05:14:04 +0000586.Pp
djm@openbsd.orgbf0fbf22018-03-12 00:52:01 +0000587The end time may be specified as a YYYYMMDD date, a YYYYMMDDHHMM[SS] time,
djm@openbsd.org@openbsd.orgd52131a2017-11-03 05:14:04 +0000588a relative time starting with a plus character or the string
589.Dq forever
590to indicate that the certificate has no expirty date.
Damien Miller0a80ca12010-02-27 07:55:05 +1100591.Pp
592For example:
593.Dq +52w1d
594(valid from now to 52 weeks and one day from now),
595.Dq -4w:+4w
596(valid from four weeks ago to four weeks from now),
597.Dq 20100101123000:20110101123000
598(valid from 12:30 PM, January 1st, 2010 to 12:30 PM, January 1st, 2011),
599.Dq -1d:20110101
600(valid from yesterday to midnight, January 1st, 2011).
djm@openbsd.org@openbsd.orgd52131a2017-11-03 05:14:04 +0000601.Dq -1m:forever
602(valid from one minute ago and never expiring).
Darren Tucker06930c72003-12-31 11:34:51 +1100603.It Fl v
604Verbose mode.
605Causes
606.Nm
607to print debugging messages about its progress.
608This is helpful for debugging moduli generation.
609Multiple
610.Fl v
611options increase the verbosity.
612The maximum is 3.
naddy@openbsd.orgaa4c6402019-11-07 08:38:38 +0000613.It Fl w Ar provider
naddy@openbsd.org141df482019-12-21 20:22:34 +0000614Specifies a path to a library that will be used when creating
615FIDO authenticator-hosted keys, overriding the default of using
616the internal USB HID support.
jmc@openbsd.org20ccd852019-12-27 08:28:44 +0000617.It Fl Y Cm check-novalidate
618Checks that a signature generated using
619.Nm
620.Fl Y Cm sign
621has a valid structure.
622This does not validate if a signature comes from an authorized signer.
623When testing a signature,
624.Nm
625accepts a message on standard input and a signature namespace using
626.Fl n .
627A file containing the corresponding signature must also be supplied using the
628.Fl s
629flag.
630Successful testing of the signature is signalled by
631.Nm
632returning a zero exit status.
jmc@openbsd.orgf23d91f2019-09-05 05:47:23 +0000633.It Fl Y Cm sign
djm@openbsd.org2a9c9f72019-09-03 08:34:19 +0000634Cryptographically sign a file or some data using a SSH key.
635When signing,
636.Nm
637accepts zero or more files to sign on the command-line - if no files
638are specified then
639.Nm
640will sign data presented on standard input.
641Signatures are written to the path of the input file with
642.Dq .sig
643appended, or to standard output if the message to be signed was read from
644standard input.
645.Pp
646The key used for signing is specified using the
647.Fl f
648option and may refer to either a private key, or a public key with the private
649half available via
650.Xr ssh-agent 1 .
651An additional signature namespace, used to prevent signature confusion across
652different domains of use (e.g. file signing vs email signing) must be provided
653via the
654.Fl n
655flag.
656Namespaces are arbitrary strings, and may include:
657.Dq file
658for file signing,
659.Dq email
660for email signing.
661For custom uses, it is recommended to use names following a
662NAMESPACE@YOUR.DOMAIN pattern to generate unambiguous namespaces.
jmc@openbsd.orgf23d91f2019-09-05 05:47:23 +0000663.It Fl Y Cm verify
djm@openbsd.org2a9c9f72019-09-03 08:34:19 +0000664Request to verify a signature generated using
665.Nm
jmc@openbsd.orgf23d91f2019-09-05 05:47:23 +0000666.Fl Y Cm sign
djm@openbsd.org2a9c9f72019-09-03 08:34:19 +0000667as described above.
668When verifying a signature,
669.Nm
670accepts a message on standard input and a signature namespace using
671.Fl n .
672A file containing the corresponding signature must also be supplied using the
673.Fl s
674flag, along with the identity of the signer using
675.Fl I
676and a list of allowed signers via the
677.Fl f
678flag.
679The format of the allowed signers file is documented in the
680.Sx ALLOWED SIGNERS
681section below.
682A file containing revoked keys can be passed using the
683.Fl r
jmc@openbsd.orgdb1e6f62019-09-04 05:56:54 +0000684flag.
685The revocation file may be a KRL or a one-per-line list of public keys.
djm@openbsd.org2a9c9f72019-09-03 08:34:19 +0000686Successful verification by an authorized signer is signalled by
687.Nm
jmc@openbsd.org70fc9a62019-10-22 08:50:35 +0000688returning a zero exit status.
jmc@openbsd.org5b6c9542019-12-27 08:25:07 +0000689.It Fl y
690This option will read a private
691OpenSSH format file and print an OpenSSH public key to stdout.
Damien Miller4e270b02010-04-16 15:56:21 +1000692.It Fl z Ar serial_number
693Specifies a serial number to be embedded in the certificate to distinguish
694this certificate from others from the same CA.
djm@openbsd.orgbe063942019-01-23 04:51:02 +0000695If the
696.Ar serial_number
697is prefixed with a
698.Sq +
699character, then the serial number will be incremented for each certificate
700signed on a single command-line.
Damien Miller4e270b02010-04-16 15:56:21 +1000701The default serial number is zero.
Damien Millerf3747bf2013-01-18 11:44:04 +1100702.Pp
703When generating a KRL, the
704.Fl z
705flag is used to specify a KRL version number.
Damien Miller32aa1441999-10-29 09:15:49 +1000706.El
Darren Tucker019cefe2003-08-02 22:40:07 +1000707.Sh MODULI GENERATION
708.Nm
709may be used to generate groups for the Diffie-Hellman Group Exchange
710(DH-GEX) protocol.
711Generating these groups is a two-step process: first, candidate
712primes are generated using a fast, but memory intensive process.
713These candidate primes are then tested for suitability (a CPU-intensive
714process).
715.Pp
716Generation of primes is performed using the
djm@openbsd.org3e60d182019-12-30 03:30:09 +0000717.Fl M Cm generate
Darren Tucker019cefe2003-08-02 22:40:07 +1000718option.
719The desired length of the primes may be specified by the
djm@openbsd.org3e60d182019-12-30 03:30:09 +0000720.Fl O Cm bits
Darren Tucker019cefe2003-08-02 22:40:07 +1000721option.
722For example:
723.Pp
djm@openbsd.org3e60d182019-12-30 03:30:09 +0000724.Dl # ssh-keygen -M generate -O bits=2048 moduli-2048.candidates
Darren Tucker019cefe2003-08-02 22:40:07 +1000725.Pp
726By default, the search for primes begins at a random point in the
727desired length range.
728This may be overridden using the
djm@openbsd.org3e60d182019-12-30 03:30:09 +0000729.Fl O Cm start
Darren Tucker019cefe2003-08-02 22:40:07 +1000730option, which specifies a different start point (in hex).
731.Pp
Damien Millerdfceafe2012-07-06 13:44:19 +1000732Once a set of candidates have been generated, they must be screened for
Darren Tucker019cefe2003-08-02 22:40:07 +1000733suitability.
734This may be performed using the
djm@openbsd.org3e60d182019-12-30 03:30:09 +0000735.Fl M Cm screen
Darren Tucker019cefe2003-08-02 22:40:07 +1000736option.
737In this mode
738.Nm
739will read candidates from standard input (or a file specified using the
740.Fl f
741option).
742For example:
743.Pp
djm@openbsd.org3e60d182019-12-30 03:30:09 +0000744.Dl # ssh-keygen -M screen -f moduli-2048.candidates moduli-2048
Darren Tucker019cefe2003-08-02 22:40:07 +1000745.Pp
746By default, each candidate will be subjected to 100 primality tests.
747This may be overridden using the
djm@openbsd.org3e60d182019-12-30 03:30:09 +0000748.Fl O Cm prime-tests
Darren Tucker019cefe2003-08-02 22:40:07 +1000749option.
750The DH generator value will be chosen automatically for the
751prime under consideration.
752If a specific generator is desired, it may be requested using the
djm@openbsd.org3e60d182019-12-30 03:30:09 +0000753.Fl O Cm generator
Darren Tucker019cefe2003-08-02 22:40:07 +1000754option.
Damien Miller265d3092005-03-02 12:05:06 +1100755Valid generator values are 2, 3, and 5.
Darren Tucker019cefe2003-08-02 22:40:07 +1000756.Pp
757Screened DH groups may be installed in
758.Pa /etc/moduli .
759It is important that this file contains moduli of a range of bit lengths and
760that both ends of a connection share common moduli.
djm@openbsd.org3e60d182019-12-30 03:30:09 +0000761.Pp
762A number of options are available for moduli generation and screening via the
763.Fl O
764flag:
jmc@openbsd.org3b1382f2019-12-30 16:10:00 +0000765.Bl -tag -width Ds
djm@openbsd.org3e60d182019-12-30 03:30:09 +0000766.It Ic lines Ns = Ns Ar number
767Exit after screening the specified number of lines while performing DH
768candidate screening.
djm@openbsd.org3e60d182019-12-30 03:30:09 +0000769.It Ic start-line Ns = Ns Ar line-number
770Start screening at the specified line number while performing DH candidate
771screening.
djm@openbsd.org3e60d182019-12-30 03:30:09 +0000772.It Ic checkpoint Ns = Ns Ar filename
773Write the last line processed to the specified file while performing DH
774candidate screening.
775This will be used to skip lines in the input file that have already been
776processed if the job is restarted.
djm@openbsd.org3e60d182019-12-30 03:30:09 +0000777.It Ic memory Ns = Ns Ar mbytes
778Specify the amount of memory to use (in megabytes) when generating
779candidate moduli for DH-GEX.
djm@openbsd.org3e60d182019-12-30 03:30:09 +0000780.It Ic start Ns = Ns Ar hex-value
781Specify start point (in hex) when generating candidate moduli for DH-GEX.
djm@openbsd.org3e60d182019-12-30 03:30:09 +0000782.It Ic generator Ns = Ns Ar value
783Specify desired generator (in decimal) when testing candidate moduli for DH-GEX.
784.El
Damien Miller0a80ca12010-02-27 07:55:05 +1100785.Sh CERTIFICATES
786.Nm
787supports signing of keys to produce certificates that may be used for
788user or host authentication.
789Certificates consist of a public key, some identity information, zero or
Damien Miller1f181422010-04-18 08:08:03 +1000790more principal (user or host) names and a set of options that
Damien Miller0a80ca12010-02-27 07:55:05 +1100791are signed by a Certification Authority (CA) key.
792Clients or servers may then trust only the CA key and verify its signature
793on a certificate rather than trusting many user/host keys.
794Note that OpenSSH certificates are a different, and much simpler, format to
795the X.509 certificates used in
796.Xr ssl 8 .
797.Pp
798.Nm
799supports two types of certificates: user and host.
800User certificates authenticate users to servers, whereas host certificates
Damien Miller15f5b562010-03-03 10:25:21 +1100801authenticate server hosts to users.
802To generate a user certificate:
Damien Miller0a80ca12010-02-27 07:55:05 +1100803.Pp
804.Dl $ ssh-keygen -s /path/to/ca_key -I key_id /path/to/user_key.pub
805.Pp
806The resultant certificate will be placed in
Damien Miller1b61a282010-03-22 05:55:06 +1100807.Pa /path/to/user_key-cert.pub .
Damien Miller0a80ca12010-02-27 07:55:05 +1100808A host certificate requires the
809.Fl h
810option:
811.Pp
812.Dl $ ssh-keygen -s /path/to/ca_key -I key_id -h /path/to/host_key.pub
813.Pp
814The host certificate will be output to
Damien Miller1b61a282010-03-22 05:55:06 +1100815.Pa /path/to/host_key-cert.pub .
Damien Miller757f34e2010-08-05 13:05:31 +1000816.Pp
817It is possible to sign using a CA key stored in a PKCS#11 token by
818providing the token library using
819.Fl D
820and identifying the CA key by providing its public half as an argument
821to
822.Fl s :
823.Pp
naddy@openbsd.org05291e52015-08-20 19:20:06 +0000824.Dl $ ssh-keygen -s ca_key.pub -D libpkcs11.so -I key_id user_key.pub
Damien Miller757f34e2010-08-05 13:05:31 +1000825.Pp
djm@openbsd.orga98339e2017-06-28 01:09:22 +0000826Similarly, it is possible for the CA key to be hosted in a
827.Xr ssh-agent 1 .
828This is indicated by the
829.Fl U
830flag and, again, the CA key must be identified by its public half.
831.Pp
832.Dl $ ssh-keygen -Us ca_key.pub -I key_id user_key.pub
833.Pp
Damien Miller757f34e2010-08-05 13:05:31 +1000834In all cases,
Damien Miller0a80ca12010-02-27 07:55:05 +1100835.Ar key_id
836is a "key identifier" that is logged by the server when the certificate
837is used for authentication.
838.Pp
839Certificates may be limited to be valid for a set of principal (user/host)
840names.
841By default, generated certificates are valid for all users or hosts.
842To generate a certificate for a specified set of principals:
843.Pp
844.Dl $ ssh-keygen -s ca_key -I key_id -n user1,user2 user_key.pub
naddy@openbsd.org05291e52015-08-20 19:20:06 +0000845.Dl "$ ssh-keygen -s ca_key -I key_id -h -n host.domain host_key.pub"
Damien Miller0a80ca12010-02-27 07:55:05 +1100846.Pp
847Additional limitations on the validity and use of user certificates may
Damien Miller1f181422010-04-18 08:08:03 +1000848be specified through certificate options.
Damien Miller4e270b02010-04-16 15:56:21 +1000849A certificate option may disable features of the SSH session, may be
Damien Miller0a80ca12010-02-27 07:55:05 +1100850valid only when presented from particular source addresses or may
851force the use of a specific command.
djm@openbsd.org1e645fe2019-12-30 03:28:41 +0000852.Pp
853The options that are valid for user certificates are:
854.Pp
855.Bl -tag -width Ds -compact
856.It Ic clear
857Clear all enabled permissions.
858This is useful for clearing the default set of permissions so permissions may
859be added individually.
860.Pp
861.It Ic critical : Ns Ar name Ns Op Ns = Ns Ar contents
862.It Ic extension : Ns Ar name Ns Op Ns = Ns Ar contents
863Includes an arbitrary certificate critical option or extension.
864The specified
865.Ar name
866should include a domain suffix, e.g.\&
867.Dq name@example.com .
868If
869.Ar contents
870is specified then it is included as the contents of the extension/option
871encoded as a string, otherwise the extension/option is created with no
872contents (usually indicating a flag).
873Extensions may be ignored by a client or server that does not recognise them,
874whereas unknown critical options will cause the certificate to be refused.
875.Pp
876.It Ic force-command Ns = Ns Ar command
877Forces the execution of
878.Ar command
879instead of any shell or command specified by the user when
880the certificate is used for authentication.
881.Pp
882.It Ic no-agent-forwarding
883Disable
884.Xr ssh-agent 1
885forwarding (permitted by default).
886.Pp
887.It Ic no-port-forwarding
888Disable port forwarding (permitted by default).
889.Pp
890.It Ic no-pty
891Disable PTY allocation (permitted by default).
892.Pp
893.It Ic no-user-rc
894Disable execution of
895.Pa ~/.ssh/rc
896by
897.Xr sshd 8
898(permitted by default).
899.Pp
900.It Ic no-x11-forwarding
901Disable X11 forwarding (permitted by default).
902.Pp
903.It Ic permit-agent-forwarding
904Allows
905.Xr ssh-agent 1
906forwarding.
907.Pp
908.It Ic permit-port-forwarding
909Allows port forwarding.
910.Pp
911.It Ic permit-pty
912Allows PTY allocation.
913.Pp
914.It Ic permit-user-rc
915Allows execution of
916.Pa ~/.ssh/rc
917by
918.Xr sshd 8 .
919.Pp
920.It Ic permit-X11-forwarding
921Allows X11 forwarding.
922.Pp
923.It Ic no-touch-required
924Do not require signatures made using this key require demonstration
naddy@openbsd.orgb715fdc2020-01-18 21:16:43 +0000925of user presence (e.g. by having the user touch the authenticator).
naddy@openbsd.org84911da2020-01-18 15:45:41 +0000926This option only makes sense for the FIDO authenticator algorithms
djm@openbsd.org1e645fe2019-12-30 03:28:41 +0000927.Cm ecdsa-sk
928and
929.Cm ed25519-sk .
930.Pp
931.It Ic source-address Ns = Ns Ar address_list
932Restrict the source addresses from which the certificate is considered valid.
933The
934.Ar address_list
935is a comma-separated list of one or more address/netmask pairs in CIDR
936format.
937.El
938.Pp
939At present, no standard options are valid for host keys.
Damien Miller0a80ca12010-02-27 07:55:05 +1100940.Pp
941Finally, certificates may be defined with a validity lifetime.
942The
943.Fl V
944option allows specification of certificate start and end times.
945A certificate that is presented at a time outside this range will not be
946considered valid.
Darren Tucker3ee50c52012-09-06 21:18:11 +1000947By default, certificates are valid from
948.Ux
949Epoch to the distant future.
Damien Miller0a80ca12010-02-27 07:55:05 +1100950.Pp
951For certificates to be used for user or host authentication, the CA
952public key must be trusted by
953.Xr sshd 8
954or
955.Xr ssh 1 .
956Please refer to those manual pages for details.
Damien Millerf3747bf2013-01-18 11:44:04 +1100957.Sh KEY REVOCATION LISTS
958.Nm
959is able to manage OpenSSH format Key Revocation Lists (KRLs).
960These binary files specify keys or certificates to be revoked using a
Damien Miller13797712013-12-29 17:47:14 +1100961compact format, taking as little as one bit per certificate if they are being
Damien Millerf3747bf2013-01-18 11:44:04 +1100962revoked by serial number.
963.Pp
964KRLs may be generated using the
965.Fl k
966flag.
Damien Miller881a7a22013-01-20 22:34:46 +1100967This option reads one or more files from the command line and generates a new
Damien Millerf3747bf2013-01-18 11:44:04 +1100968KRL.
969The files may either contain a KRL specification (see below) or public keys,
970listed one per line.
971Plain public keys are revoked by listing their hash or contents in the KRL and
972certificates revoked by serial number or key ID (if the serial is zero or
973not available).
974.Pp
975Revoking keys using a KRL specification offers explicit control over the
976types of record used to revoke keys and may be used to directly revoke
977certificates by serial number or key ID without having the complete original
978certificate on hand.
979A KRL specification consists of lines containing one of the following directives
980followed by a colon and some directive-specific information.
981.Bl -tag -width Ds
Damien Millera0a7ee82013-01-20 22:35:06 +1100982.It Cm serial : Ar serial_number Ns Op - Ns Ar serial_number
Damien Millerf3747bf2013-01-18 11:44:04 +1100983Revokes a certificate with the specified serial number.
Damien Millerac5542b2013-01-20 22:33:02 +1100984Serial numbers are 64-bit values, not including zero and may be expressed
Damien Millerf3747bf2013-01-18 11:44:04 +1100985in decimal, hex or octal.
986If two serial numbers are specified separated by a hyphen, then the range
987of serial numbers including and between each is revoked.
988The CA key must have been specified on the
989.Nm
Damien Miller881a7a22013-01-20 22:34:46 +1100990command line using the
Damien Millerf3747bf2013-01-18 11:44:04 +1100991.Fl s
992option.
993.It Cm id : Ar key_id
994Revokes a certificate with the specified key ID string.
995The CA key must have been specified on the
996.Nm
Damien Miller881a7a22013-01-20 22:34:46 +1100997command line using the
Damien Millerf3747bf2013-01-18 11:44:04 +1100998.Fl s
999option.
1000.It Cm key : Ar public_key
1001Revokes the specified key.
Damien Millerac5542b2013-01-20 22:33:02 +11001002If a certificate is listed, then it is revoked as a plain public key.
Damien Millerf3747bf2013-01-18 11:44:04 +11001003.It Cm sha1 : Ar public_key
djm@openbsd.org9405c622018-09-12 01:21:34 +00001004Revokes the specified key by including its SHA1 hash in the KRL.
1005.It Cm sha256 : Ar public_key
1006Revokes the specified key by including its SHA256 hash in the KRL.
1007KRLs that revoke keys by SHA256 hash are not supported by OpenSSH versions
1008prior to 7.9.
1009.It Cm hash : Ar fingerprint
djm@openbsd.orgf0fcd7e2018-09-12 06:18:59 +00001010Revokes a key using a fingerprint hash, as obtained from a
djm@openbsd.org9405c622018-09-12 01:21:34 +00001011.Xr sshd 8
1012authentication log message or the
1013.Nm
1014.Fl l
1015flag.
1016Only SHA256 fingerprints are supported here and resultant KRLs are
1017not supported by OpenSSH versions prior to 7.9.
Damien Millerf3747bf2013-01-18 11:44:04 +11001018.El
1019.Pp
1020KRLs may be updated using the
1021.Fl u
1022flag in addition to
1023.Fl k .
Damien Miller881a7a22013-01-20 22:34:46 +11001024When this option is specified, keys listed via the command line are merged into
Damien Millerf3747bf2013-01-18 11:44:04 +11001025the KRL, adding to those already there.
1026.Pp
1027It is also possible, given a KRL, to test whether it revokes a particular key
1028(or keys).
1029The
1030.Fl Q
jmc@openbsd.org8b290082015-11-05 09:48:05 +00001031flag will query an existing KRL, testing each key specified on the command line.
Damien Miller881a7a22013-01-20 22:34:46 +11001032If any key listed on the command line has been revoked (or an error encountered)
Damien Millerf3747bf2013-01-18 11:44:04 +11001033then
1034.Nm
1035will exit with a non-zero exit status.
1036A zero exit status will only be returned if no key was revoked.
djm@openbsd.org2a9c9f72019-09-03 08:34:19 +00001037.Sh ALLOWED SIGNERS
1038When verifying signatures,
1039.Nm
1040uses a simple list of identities and keys to determine whether a signature
1041comes from an authorized source.
1042This "allowed signers" file uses a format patterned after the
1043AUTHORIZED_KEYS FILE FORMAT described in
jmc@openbsd.orgdb1e6f62019-09-04 05:56:54 +00001044.Xr sshd 8 .
djm@openbsd.org2a9c9f72019-09-03 08:34:19 +00001045Each line of the file contains the following space-separated fields:
1046principals, options, keytype, base64-encoded key.
1047Empty lines and lines starting with a
1048.Ql #
1049are ignored as comments.
1050.Pp
1051The principals field is a pattern-list (See PATTERNS in
1052.Xr ssh_config 5 )
1053consisting of one or more comma-separated USER@DOMAIN identity patterns
1054that are accepted for signing.
1055When verifying, the identity presented via the
jmc@openbsd.org70fc9a62019-10-22 08:50:35 +00001056.Fl I
1057option must match a principals pattern in order for the corresponding key to be
djm@openbsd.org2a9c9f72019-09-03 08:34:19 +00001058considered acceptable for verification.
1059.Pp
1060The options (if present) consist of comma-separated option specifications.
1061No spaces are permitted, except within double quotes.
1062The following option specifications are supported (note that option keywords
1063are case-insensitive):
1064.Bl -tag -width Ds
1065.It Cm cert-authority
1066Indicates that this key is accepted as a certificate authority (CA) and
1067that certificates signed by this CA may be accepted for verification.
1068.It Cm namespaces="namespace-list"
1069Specifies a pattern-list of namespaces that are accepted for this key.
djm@openbsd.orgd637c4a2019-09-03 08:35:27 +00001070If this option is present, the signature namespace embedded in the
djm@openbsd.org2a9c9f72019-09-03 08:34:19 +00001071signature object and presented on the verification command-line must
1072match the specified list before the key will be considered acceptable.
1073.El
1074.Pp
1075When verifying signatures made by certificates, the expected principal
1076name must match both the principals pattern in the allowed signers file and
1077the principals embedded in the certificate itself.
1078.Pp
1079An example allowed signers file:
1080.Bd -literal -offset 3n
1081# Comments allowed at start of line
1082user1@example.com,user2@example.com ssh-rsa AAAAX1...
1083# A certificate authority, trusted for all principals in a domain.
1084*@example.com cert-authority ssh-ed25519 AAAB4...
1085# A key that is accepted only for file signing.
1086user2@example.com namespaces="file" ssh-ed25519 AAA41...
1087.Ed
naddy@openbsd.orgaa4c6402019-11-07 08:38:38 +00001088.Sh ENVIRONMENT
1089.Bl -tag -width Ds
1090.It Ev SSH_SK_PROVIDER
naddy@openbsd.org141df482019-12-21 20:22:34 +00001091Specifies the path to a library used to interact with FIDO authenticators.
naddy@openbsd.orgaa4c6402019-11-07 08:38:38 +00001092.El
Damien Miller32aa1441999-10-29 09:15:49 +10001093.Sh FILES
Damien Miller6186bbc2010-09-24 22:00:54 +10001094.Bl -tag -width Ds -compact
Damien Miller167ea5d2005-05-26 12:04:02 +10001095.It Pa ~/.ssh/id_dsa
Damien Miller6186bbc2010-09-24 22:00:54 +10001096.It Pa ~/.ssh/id_ecdsa
naddy@openbsd.orgaa4c6402019-11-07 08:38:38 +00001097.It Pa ~/.ssh/id_ecdsa_sk
Damien Miller8ba0ead2013-12-18 17:46:27 +11001098.It Pa ~/.ssh/id_ed25519
naddy@openbsd.orgf0edda82019-11-18 23:16:49 +00001099.It Pa ~/.ssh/id_ed25519_sk
Damien Miller167ea5d2005-05-26 12:04:02 +10001100.It Pa ~/.ssh/id_rsa
naddy@openbsd.org141df482019-12-21 20:22:34 +00001101Contains the DSA, ECDSA, authenticator-hosted ECDSA, Ed25519,
1102authenticator-hosted Ed25519 or RSA authentication identity of the user.
Ben Lindstrom18a82ac2001-04-11 15:59:35 +00001103This file should not be readable by anyone but the user.
1104It is possible to
1105specify a passphrase when generating the key; that passphrase will be
Darren Tucker199ee6f2009-10-24 11:50:17 +11001106used to encrypt the private part of this file using 128-bit AES.
Ben Lindstrom18a82ac2001-04-11 15:59:35 +00001107This file is not automatically accessed by
1108.Nm
1109but it is offered as the default file for the private key.
Ben Lindstrombda98b02001-07-04 03:35:24 +00001110.Xr ssh 1
Ben Lindstrom18a82ac2001-04-11 15:59:35 +00001111will read this file when a login attempt is made.
Damien Miller6186bbc2010-09-24 22:00:54 +10001112.Pp
1113.It Pa ~/.ssh/id_dsa.pub
1114.It Pa ~/.ssh/id_ecdsa.pub
naddy@openbsd.orgaa4c6402019-11-07 08:38:38 +00001115.It Pa ~/.ssh/id_ecdsa_sk.pub
Damien Miller8ba0ead2013-12-18 17:46:27 +11001116.It Pa ~/.ssh/id_ed25519.pub
naddy@openbsd.orgf0edda82019-11-18 23:16:49 +00001117.It Pa ~/.ssh/id_ed25519_sk.pub
Damien Miller167ea5d2005-05-26 12:04:02 +10001118.It Pa ~/.ssh/id_rsa.pub
naddy@openbsd.org141df482019-12-21 20:22:34 +00001119Contains the DSA, ECDSA, authenticator-hosted ECDSA, Ed25519,
1120authenticator-hosted Ed25519 or RSA public key for authentication.
Damien Millere247cc42000-05-07 12:03:14 +10001121The contents of this file should be added to
Damien Miller167ea5d2005-05-26 12:04:02 +10001122.Pa ~/.ssh/authorized_keys
Damien Millere247cc42000-05-07 12:03:14 +10001123on all machines
Ben Lindstrom594e2032001-09-12 18:35:30 +00001124where the user wishes to log in using public key authentication.
Damien Millere247cc42000-05-07 12:03:14 +10001125There is no need to keep the contents of this file secret.
Damien Miller6186bbc2010-09-24 22:00:54 +10001126.Pp
Darren Tucker019cefe2003-08-02 22:40:07 +10001127.It Pa /etc/moduli
1128Contains Diffie-Hellman groups used for DH-GEX.
1129The file format is described in
1130.Xr moduli 5 .
Damien Miller37023962000-07-11 17:31:38 +10001131.El
Damien Miller32aa1441999-10-29 09:15:49 +10001132.Sh SEE ALSO
1133.Xr ssh 1 ,
1134.Xr ssh-add 1 ,
Damien Miller2e8b1c81999-11-15 23:33:56 +11001135.Xr ssh-agent 1 ,
Darren Tucker019cefe2003-08-02 22:40:07 +10001136.Xr moduli 5 ,
Ben Lindstrom77788dc2001-02-10 23:10:33 +00001137.Xr sshd 8
Ben Lindstrom5a707822001-04-22 17:15:46 +00001138.Rs
Damien Millerc0367fb2007-01-05 16:25:46 +11001139.%R RFC 4716
1140.%T "The Secure Shell (SSH) Public Key File Format"
1141.%D 2006
Ben Lindstrom5a707822001-04-22 17:15:46 +00001142.Re
Damien Millerf1ce5052003-06-11 22:04:39 +10001143.Sh AUTHORS
1144OpenSSH is a derivative of the original and free
1145ssh 1.2.12 release by Tatu Ylonen.
1146Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos,
1147Theo de Raadt and Dug Song
1148removed many bugs, re-added newer features and
1149created OpenSSH.
1150Markus Friedl contributed the support for SSH
1151protocol versions 1.5 and 2.0.