blob: 1b77bdf6dfbc510c5ba2a7737e9a1e7a6f2c8d6b [file] [log] [blame]
jmc@openbsd.org483cc722019-11-30 07:07:59 +00001.\" $OpenBSD: ssh-keygen.1,v 1.179 2019/11/30 07:07:59 jmc 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.\"
jmc@openbsd.org483cc722019-11-30 07:07:59 +000038.Dd $Mdocdate: November 30 2019 $
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.orgaa4c6402019-11-07 08:38:38 +000053.Op Fl w Ar provider
54.Op Fl x Ar flags
Damien Miller32aa1441999-10-29 09:15:49 +100055.Nm ssh-keygen
56.Fl p
Damien Miller10f6f6b1999-11-17 17:29:08 +110057.Op Fl f Ar keyfile
djm@openbsd.orgecd2f332019-01-22 11:40:42 +000058.Op Fl m Ar format
jmc@openbsd.org69189742019-10-03 17:07:50 +000059.Op Fl N Ar new_passphrase
60.Op Fl P Ar old_passphrase
Damien Miller32aa1441999-10-29 09:15:49 +100061.Nm ssh-keygen
Ben Lindstrom5a707822001-04-22 17:15:46 +000062.Fl i
Damien Miller1a425f32000-09-02 10:08:09 +110063.Op Fl f Ar input_keyfile
jmc@openbsd.org69189742019-10-03 17:07:50 +000064.Op Fl m Ar key_format
Damien Millere247cc42000-05-07 12:03:14 +100065.Nm ssh-keygen
Ben Lindstrom5a707822001-04-22 17:15:46 +000066.Fl e
Damien Miller1a425f32000-09-02 10:08:09 +110067.Op Fl f Ar input_keyfile
jmc@openbsd.org69189742019-10-03 17:07:50 +000068.Op Fl m Ar key_format
Damien Millere247cc42000-05-07 12:03:14 +100069.Nm ssh-keygen
70.Fl y
Damien Miller1a425f32000-09-02 10:08:09 +110071.Op Fl f Ar input_keyfile
Damien Millere247cc42000-05-07 12:03:14 +100072.Nm ssh-keygen
Damien Miller32aa1441999-10-29 09:15:49 +100073.Fl c
Damien Miller32aa1441999-10-29 09:15:49 +100074.Op Fl C Ar comment
Damien Miller10f6f6b1999-11-17 17:29:08 +110075.Op Fl f Ar keyfile
jmc@openbsd.org69189742019-10-03 17:07:50 +000076.Op Fl P Ar passphrase
Damien Miller10f6f6b1999-11-17 17:29:08 +110077.Nm ssh-keygen
78.Fl l
naddy@openbsd.org6288e3a2015-02-24 15:24:05 +000079.Op Fl v
djm@openbsd.org56d1c832014-12-21 22:27:55 +000080.Op Fl E Ar fingerprint_hash
Ben Lindstrom8fd372b2001-03-12 03:02:17 +000081.Op Fl f Ar input_keyfile
82.Nm ssh-keygen
83.Fl B
Damien Miller1a425f32000-09-02 10:08:09 +110084.Op Fl f Ar input_keyfile
Ben Lindstroma1ec4a92001-08-06 21:51:34 +000085.Nm ssh-keygen
Damien Miller048dc932010-02-12 09:22:04 +110086.Fl D Ar pkcs11
Ben Lindstroma1ec4a92001-08-06 21:51:34 +000087.Nm ssh-keygen
Damien Miller4b42d7f2005-03-01 21:48:35 +110088.Fl F Ar hostname
jmc@openbsd.org6c91d422019-09-29 16:31:57 +000089.Op Fl lv
Damien Miller4b42d7f2005-03-01 21:48:35 +110090.Op Fl f Ar known_hosts_file
91.Nm ssh-keygen
92.Fl H
93.Op Fl f Ar known_hosts_file
94.Nm ssh-keygen
95.Fl R Ar hostname
96.Op Fl f Ar known_hosts_file
97.Nm ssh-keygen
Damien Miller37876e92003-05-15 10:19:46 +100098.Fl r Ar hostname
Damien Miller37876e92003-05-15 10:19:46 +100099.Op Fl g
jmc@openbsd.org6c91d422019-09-29 16:31:57 +0000100.Op Fl f Ar input_keyfile
Darren Tucker019cefe2003-08-02 22:40:07 +1000101.Nm ssh-keygen
102.Fl G Ar output_file
Darren Tucker06930c72003-12-31 11:34:51 +1100103.Op Fl v
Darren Tucker019cefe2003-08-02 22:40:07 +1000104.Op Fl b Ar bits
105.Op Fl M Ar memory
106.Op Fl S Ar start_point
107.Nm ssh-keygen
Darren Tucker019cefe2003-08-02 22:40:07 +1000108.Fl f Ar input_file
jmc@openbsd.org69189742019-10-03 17:07:50 +0000109.Fl T Ar output_file
Darren Tucker06930c72003-12-31 11:34:51 +1100110.Op Fl v
Damien Miller4f752cf2013-12-18 17:45:35 +1100111.Op Fl a Ar rounds
Damien Millerdfceafe2012-07-06 13:44:19 +1000112.Op Fl J Ar num_lines
113.Op Fl j Ar start_line
Damien Miller390d0562011-10-18 16:05:19 +1100114.Op Fl K Ar checkpt
Darren Tucker019cefe2003-08-02 22:40:07 +1000115.Op Fl W Ar generator
Damien Miller0a80ca12010-02-27 07:55:05 +1100116.Nm ssh-keygen
Damien Miller0a80ca12010-02-27 07:55:05 +1100117.Fl I Ar certificate_identity
jmc@openbsd.org69189742019-10-03 17:07:50 +0000118.Fl s Ar ca_key
jmc@openbsd.org6c91d422019-09-29 16:31:57 +0000119.Op Fl hU
djm@openbsd.orga98339e2017-06-28 01:09:22 +0000120.Op Fl D Ar pkcs11_provider
Damien Miller0a80ca12010-02-27 07:55:05 +1100121.Op Fl n Ar principals
Damien Miller4e270b02010-04-16 15:56:21 +1000122.Op Fl O Ar option
Damien Miller0a80ca12010-02-27 07:55:05 +1100123.Op Fl V Ar validity_interval
Damien Miller4e270b02010-04-16 15:56:21 +1000124.Op Fl z Ar serial_number
Damien Miller0a80ca12010-02-27 07:55:05 +1100125.Ar
Damien Millerf2b70ca2010-03-05 07:39:35 +1100126.Nm ssh-keygen
Damien Millerf2b70ca2010-03-05 07:39:35 +1100127.Fl L
128.Op Fl f Ar input_keyfile
Damien Miller58f1baf2011-05-05 14:06:15 +1000129.Nm ssh-keygen
130.Fl A
djm@openbsd.org853edbe2017-07-07 03:53:12 +0000131.Op Fl f Ar prefix_path
Damien Millerf3747bf2013-01-18 11:44:04 +1100132.Nm ssh-keygen
133.Fl k
134.Fl f Ar krl_file
135.Op Fl u
Damien Millerac5542b2013-01-20 22:33:02 +1100136.Op Fl s Ar ca_public
137.Op Fl z Ar version_number
Damien Millerf3747bf2013-01-18 11:44:04 +1100138.Ar
139.Nm ssh-keygen
140.Fl Q
141.Fl f Ar krl_file
142.Ar
djm@openbsd.org2a9c9f72019-09-03 08:34:19 +0000143.Nm ssh-keygen
jmc@openbsd.org69189742019-10-03 17:07:50 +0000144.Fl Y Cm check-novalidate
145.Fl n Ar namespace
146.Fl s Ar signature_file
147.Nm ssh-keygen
djm@openbsd.org2a9c9f72019-09-03 08:34:19 +0000148.Fl Y Cm sign
149.Fl f Ar key_file
150.Fl n Ar namespace
151.Ar
152.Nm ssh-keygen
153.Fl Y Cm verify
djm@openbsd.org8aa2aa32019-09-16 03:23:02 +0000154.Fl f Ar allowed_signers_file
jmc@openbsd.org69189742019-10-03 17:07:50 +0000155.Fl I Ar signer_identity
djm@openbsd.org2a9c9f72019-09-03 08:34:19 +0000156.Fl n Ar namespace
157.Fl s Ar signature_file
158.Op Fl r Ar revocation_file
Damien Miller22c77262000-04-13 12:26:34 +1000159.Sh DESCRIPTION
Damien Miller32aa1441999-10-29 09:15:49 +1000160.Nm
Ben Lindstrom5a707822001-04-22 17:15:46 +0000161generates, manages and converts authentication keys for
Damien Miller32aa1441999-10-29 09:15:49 +1000162.Xr ssh 1 .
Damien Millere247cc42000-05-07 12:03:14 +1000163.Nm
jmc@openbsd.org2b6f7992017-05-03 06:32:02 +0000164can create keys for use by SSH protocol version 2.
jmc@openbsd.orga685ae82016-02-17 07:38:19 +0000165.Pp
Damien Millerfbf486b2003-05-23 18:44:23 +1000166The type of key to be generated is specified with the
Damien Miller0bc1bd82000-11-13 22:57:25 +1100167.Fl t
Damien Millera41c8b12002-01-22 23:05:08 +1100168option.
Damien Millerf14be5c2005-11-05 15:15:49 +1100169If invoked without any arguments,
170.Nm
naddy@openbsd.org2e9c3242017-05-05 10:41:58 +0000171will generate an RSA key.
Damien Millere247cc42000-05-07 12:03:14 +1000172.Pp
Darren Tucker019cefe2003-08-02 22:40:07 +1000173.Nm
174is also used to generate groups for use in Diffie-Hellman group
175exchange (DH-GEX).
176See the
177.Sx MODULI GENERATION
178section for details.
179.Pp
Damien Millerf3747bf2013-01-18 11:44:04 +1100180Finally,
181.Nm
182can be used to generate and update Key Revocation Lists, and to test whether
Damien Millerac5542b2013-01-20 22:33:02 +1100183given keys have been revoked by one.
184See the
Damien Millerf3747bf2013-01-18 11:44:04 +1100185.Sx KEY REVOCATION LISTS
186section for details.
187.Pp
Damien Miller32aa1441999-10-29 09:15:49 +1000188Normally each user wishing to use SSH
Damien Millereb8b60e2010-08-31 22:41:14 +1000189with public key authentication runs this once to create the authentication
Damien Miller32aa1441999-10-29 09:15:49 +1000190key in
Damien Miller8ba0ead2013-12-18 17:46:27 +1100191.Pa ~/.ssh/id_dsa ,
Damien Millereb8b60e2010-08-31 22:41:14 +1000192.Pa ~/.ssh/id_ecdsa ,
naddy@openbsd.orgaa4c6402019-11-07 08:38:38 +0000193.Pa ~/.ssh/id_ecdsa_sk ,
naddy@openbsd.orgf0edda82019-11-18 23:16:49 +0000194.Pa ~/.ssh/id_ed25519 ,
195.Pa ~/.ssh/id_ed25519_sk
Damien Millere247cc42000-05-07 12:03:14 +1000196or
Damien Miller167ea5d2005-05-26 12:04:02 +1000197.Pa ~/.ssh/id_rsa .
Damien Millere247cc42000-05-07 12:03:14 +1000198Additionally, the system administrator may use this to generate host keys,
199as seen in
200.Pa /etc/rc .
Damien Miller32aa1441999-10-29 09:15:49 +1000201.Pp
202Normally this program generates the key and asks for a file in which
Damien Miller450a7a12000-03-26 13:04:51 +1000203to store the private key.
204The public key is stored in a file with the same name but
Damien Miller32aa1441999-10-29 09:15:49 +1000205.Dq .pub
Damien Miller450a7a12000-03-26 13:04:51 +1000206appended.
207The program also asks for a passphrase.
208The passphrase may be empty to indicate no passphrase
Ben Lindstrombf555ba2001-01-18 02:04:35 +0000209(host keys must have an empty passphrase), or it may be a string of
Damien Miller450a7a12000-03-26 13:04:51 +1000210arbitrary length.
Ben Lindstrom4e366d52001-12-06 16:43:21 +0000211A passphrase is similar to a password, except it can be a phrase with a
212series of words, punctuation, numbers, whitespace, or any string of
213characters you want.
214Good passphrases are 10-30 characters long, are
Damien Miller32aa1441999-10-29 09:15:49 +1000215not simple sentences or otherwise easily guessable (English
Ben Lindstrom2a097a42001-06-09 01:13:40 +0000216prose has only 1-2 bits of entropy per character, and provides very bad
Ben Lindstrom4e366d52001-12-06 16:43:21 +0000217passphrases), and contain a mix of upper and lowercase letters,
218numbers, and non-alphanumeric characters.
Damien Miller450a7a12000-03-26 13:04:51 +1000219The passphrase can be changed later by using the
Damien Miller32aa1441999-10-29 09:15:49 +1000220.Fl p
221option.
222.Pp
Damien Miller450a7a12000-03-26 13:04:51 +1000223There is no way to recover a lost passphrase.
Damien Miller085c90f2011-05-05 14:15:33 +1000224If the passphrase is lost or forgotten, a new key must be generated
225and the corresponding public key copied to other machines.
Damien Miller32aa1441999-10-29 09:15:49 +1000226.Pp
djm@openbsd.orgc45616a2019-01-22 11:00:15 +0000227.Nm
228will by default write keys in an OpenSSH-specific format.
229This format is preferred as it offers better protection for
230keys at rest as well as allowing storage of key comments within
231the private key file itself.
232The key comment may be useful to help identify the key.
Damien Miller450a7a12000-03-26 13:04:51 +1000233The comment is initialized to
Damien Miller32aa1441999-10-29 09:15:49 +1000234.Dq user@host
235when the key is created, but can be changed using the
236.Fl c
237option.
238.Pp
djm@openbsd.orgc45616a2019-01-22 11:00:15 +0000239It is still possible for
240.Nm
241to write the previously-used PEM format private keys using the
242.Fl m
243flag.
244This may be used when generating new keys, and existing new-format
245keys may be converted using this option in conjunction with the
246.Fl p
247(change passphrase) flag.
248.Pp
Damien Millere247cc42000-05-07 12:03:14 +1000249After a key is generated, instructions below detail where the keys
250should be placed to be activated.
251.Pp
Damien Miller32aa1441999-10-29 09:15:49 +1000252The options are as follows:
253.Bl -tag -width Ds
Damien Miller58f1baf2011-05-05 14:06:15 +1000254.It Fl A
djm@openbsd.org97dc5d12019-11-18 04:50:45 +0000255For each of the key types (rsa, dsa, ecdsa and ed25519)
Damien Miller8ba0ead2013-12-18 17:46:27 +1100256for which host keys
Damien Miller58f1baf2011-05-05 14:06:15 +1000257do not exist, generate the host keys with the default key file path,
258an empty passphrase, default bits for the key type, and default comment.
jmc@openbsd.orgdc44dd32017-07-08 18:32:54 +0000259If
djm@openbsd.org853edbe2017-07-07 03:53:12 +0000260.Fl f
jmc@openbsd.orgdc44dd32017-07-08 18:32:54 +0000261has also been specified, its argument is used as a prefix to the
djm@openbsd.org853edbe2017-07-07 03:53:12 +0000262default path for the resulting host key files.
Damien Miller3ca1eb32011-05-05 14:13:50 +1000263This is used by
Damien Miller58f1baf2011-05-05 14:06:15 +1000264.Pa /etc/rc
265to generate new host keys.
Damien Miller4f752cf2013-12-18 17:45:35 +1100266.It Fl a Ar rounds
jmc@openbsd.org3b44bf32019-09-27 20:03:24 +0000267When saving a private key, this option specifies the number of KDF
djm@openbsd.orged7bd5d2018-08-08 01:16:01 +0000268(key derivation function) rounds used.
Damien Miller4f752cf2013-12-18 17:45:35 +1100269Higher numbers result in slower passphrase verification and increased
270resistance to brute-force password cracking (should the keys be stolen).
271.Pp
jmc@openbsd.org2b6f7992017-05-03 06:32:02 +0000272When screening DH-GEX candidates (using the
Darren Tucker019cefe2003-08-02 22:40:07 +1000273.Fl T
jmc@openbsd.org3b44bf32019-09-27 20:03:24 +0000274command),
275this option specifies the number of primality tests to perform.
Damien Miller265d3092005-03-02 12:05:06 +1100276.It Fl B
277Show the bubblebabble digest of specified private or public key file.
Damien Miller32aa1441999-10-29 09:15:49 +1000278.It Fl b Ar bits
Damien Miller450a7a12000-03-26 13:04:51 +1000279Specifies the number of bits in the key to create.
dtucker@openbsd.orgd7c6e382019-04-19 05:47:44 +0000280For RSA keys, the minimum size is 1024 bits and the default is 3072 bits.
281Generally, 3072 bits is considered sufficient.
Darren Tucker9f647332005-11-28 16:41:46 +1100282DSA keys must be exactly 1024 bits as specified by FIPS 186-2.
Damien Millerad210322011-05-05 14:15:54 +1000283For ECDSA keys, the
284.Fl b
Damien Miller6232a162011-09-22 21:36:00 +1000285flag determines the key length by selecting from one of three elliptic
Damien Millerad210322011-05-05 14:15:54 +1000286curve sizes: 256, 384 or 521 bits.
287Attempting to use bit lengths other than these three values for ECDSA keys
288will fail.
naddy@openbsd.orgf0edda82019-11-18 23:16:49 +0000289ECDSA-SK, Ed25519 and Ed25519-SK keys have a fixed length and the
Damien Miller8ba0ead2013-12-18 17:46:27 +1100290.Fl b
291flag will be ignored.
Damien Miller265d3092005-03-02 12:05:06 +1100292.It Fl C Ar comment
293Provides a new comment.
Damien Miller32aa1441999-10-29 09:15:49 +1000294.It Fl c
295Requests changing the comment in the private and public key files.
296The program will prompt for the file containing the private keys, for
Ben Lindstromaafff9c2001-05-06 03:01:02 +0000297the passphrase if the key has one, and for the new comment.
Damien Miller7ea845e2010-02-12 09:21:02 +1100298.It Fl D Ar pkcs11
naddy@openbsd.orgc13b7452019-03-05 16:17:12 +0000299Download the public keys provided by the PKCS#11 shared library
Damien Millera7618442010-02-12 09:26:02 +1100300.Ar pkcs11 .
Damien Miller757f34e2010-08-05 13:05:31 +1000301When used in combination with
302.Fl s ,
303this option indicates that a CA key resides in a PKCS#11 token (see the
304.Sx CERTIFICATES
305section for details).
djm@openbsd.org56d1c832014-12-21 22:27:55 +0000306.It Fl E Ar fingerprint_hash
307Specifies the hash algorithm used when displaying key fingerprints.
308Valid options are:
309.Dq md5
310and
311.Dq sha256 .
312The default is
313.Dq sha256 .
Ben Lindstrom5a707822001-04-22 17:15:46 +0000314.It Fl e
Ben Lindstrom46c264f2001-04-24 16:56:58 +0000315This option will read a private or public OpenSSH key file and
djm@openbsd.org180b5202019-01-22 11:19:42 +0000316print to stdout a public key in one of the formats specified by the
Damien Miller44b25042010-07-02 13:35:01 +1000317.Fl m
318option.
319The default export format is
320.Dq RFC4716 .
Damien Millerea727282010-07-02 13:35:34 +1000321This option allows exporting OpenSSH keys for use by other programs, including
Damien Miller44b25042010-07-02 13:35:01 +1000322several commercial SSH implementations.
djm@openbsd.org737e4ed2018-12-07 03:32:26 +0000323.It Fl F Ar hostname | [hostname]:port
Damien Miller265d3092005-03-02 12:05:06 +1100324Search for the specified
325.Ar hostname
djm@openbsd.org737e4ed2018-12-07 03:32:26 +0000326(with optional port number)
Damien Miller265d3092005-03-02 12:05:06 +1100327in a
328.Pa known_hosts
329file, listing any occurrences found.
330This option is useful to find hashed host names or addresses and may also be
331used in conjunction with the
332.Fl H
333option to print found keys in a hashed format.
334.It Fl f Ar filename
335Specifies the filename of the key file.
336.It Fl G Ar output_file
337Generate candidate primes for DH-GEX.
338These primes must be screened for
339safety (using the
340.Fl T
341option) before use.
Damien Miller37876e92003-05-15 10:19:46 +1000342.It Fl g
Darren Tucker0b42e6d2004-08-13 21:22:40 +1000343Use generic DNS format when printing fingerprint resource records using the
Darren Tucker6e370372004-08-13 21:23:25 +1000344.Fl r
Darren Tucker0b42e6d2004-08-13 21:22:40 +1000345command.
Damien Miller265d3092005-03-02 12:05:06 +1100346.It Fl H
347Hash a
348.Pa known_hosts
Darren Tuckerda1adbc2005-03-14 23:15:58 +1100349file.
350This replaces all hostnames and addresses with hashed representations
351within the specified file; the original content is moved to a file with
352a .old suffix.
Damien Miller265d3092005-03-02 12:05:06 +1100353These hashes may be used normally by
354.Nm ssh
355and
356.Nm sshd ,
357but they do not reveal identifying information should the file's contents
358be disclosed.
359This option will not modify existing hashed hostnames and is therefore safe
360to use on files that mix hashed and non-hashed names.
Damien Miller0a80ca12010-02-27 07:55:05 +1100361.It Fl h
362When signing a key, create a host certificate instead of a user
363certificate.
364Please see the
365.Sx CERTIFICATES
366section for details.
Damien Miller15f5b562010-03-03 10:25:21 +1100367.It Fl I Ar certificate_identity
Damien Miller0a80ca12010-02-27 07:55:05 +1100368Specify the key identity when signing a public key.
369Please see the
370.Sx CERTIFICATES
371section for details.
Ben Lindstrom5a707822001-04-22 17:15:46 +0000372.It Fl i
373This option will read an unencrypted private (or public) key file
Damien Miller44b25042010-07-02 13:35:01 +1000374in the format specified by the
375.Fl m
376option and print an OpenSSH compatible private
Ben Lindstrom5a707822001-04-22 17:15:46 +0000377(or public) key to stdout.
Damien Miller43b156c2014-04-20 13:23:03 +1000378This option allows importing keys from other software, including several
379commercial SSH implementations.
380The default import format is
381.Dq RFC4716 .
Damien Millerdfceafe2012-07-06 13:44:19 +1000382.It Fl J Ar num_lines
383Exit after screening the specified number of lines
384while performing DH candidate screening using the
385.Fl T
386option.
387.It Fl j Ar start_line
388Start screening at the specified line number
389while performing DH candidate screening using the
390.Fl T
391option.
Damien Miller390d0562011-10-18 16:05:19 +1100392.It Fl K Ar checkpt
393Write the last line processed to the file
394.Ar checkpt
395while performing DH candidate screening using the
396.Fl T
397option.
398This will be used to skip lines in the input file that have already been
399processed if the job is restarted.
Damien Millerf3747bf2013-01-18 11:44:04 +1100400.It Fl k
401Generate a KRL file.
402In this mode,
403.Nm
404will generate a KRL file at the location specified via the
405.Fl f
Damien Miller881a7a22013-01-20 22:34:46 +1100406flag that revokes every key or certificate presented on the command line.
Damien Millerf3747bf2013-01-18 11:44:04 +1100407Keys/certificates to be revoked may be specified by public key file or
408using the format described in the
409.Sx KEY REVOCATION LISTS
410section.
Damien Millerf2b70ca2010-03-05 07:39:35 +1100411.It Fl L
djm@openbsd.org94bc0b72015-11-13 04:34:15 +0000412Prints the contents of one or more certificates.
Damien Miller10f6f6b1999-11-17 17:29:08 +1100413.It Fl l
Darren Tucker35c45532008-06-13 04:43:15 +1000414Show fingerprint of specified public key file.
Damien Millereb5fec62001-11-12 10:52:44 +1100415For RSA and DSA keys
416.Nm
Darren Tuckerf09e8252008-06-13 05:18:03 +1000417tries to find the matching public key file and prints its fingerprint.
418If combined with
419.Fl v ,
jmc@openbsd.org92838842016-05-03 18:38:12 +0000420a visual ASCII art representation of the key is supplied with the
djm@openbsd.orgcdcd9412016-05-03 14:54:08 +0000421fingerprint.
Damien Millerea727282010-07-02 13:35:34 +1000422.It Fl M Ar memory
423Specify the amount of memory to use (in megabytes) when generating
424candidate moduli for DH-GEX.
Damien Miller44b25042010-07-02 13:35:01 +1000425.It Fl m Ar key_format
djm@openbsd.orgecd2f332019-01-22 11:40:42 +0000426Specify a key format for key generation, the
Damien Miller44b25042010-07-02 13:35:01 +1000427.Fl i
djm@openbsd.orgecd2f332019-01-22 11:40:42 +0000428(import),
Damien Miller44b25042010-07-02 13:35:01 +1000429.Fl e
djm@openbsd.orgecd2f332019-01-22 11:40:42 +0000430(export) conversion options, and the
431.Fl p
432change passphrase operation.
433The latter may be used to convert between OpenSSH private key and PEM
434private key formats.
Damien Miller44b25042010-07-02 13:35:01 +1000435The supported key formats are:
436.Dq RFC4716
Damien Millerea727282010-07-02 13:35:34 +1000437(RFC 4716/SSH2 public or private key),
Damien Miller44b25042010-07-02 13:35:01 +1000438.Dq PKCS8
djm@openbsd.orgeb0d8e72019-07-15 13:16:29 +0000439(PKCS8 public or private key)
Damien Miller44b25042010-07-02 13:35:01 +1000440or
441.Dq PEM
442(PEM public key).
djm@openbsd.orgeb0d8e72019-07-15 13:16:29 +0000443By default OpenSSH will write newly-generated private keys in its own
444format, but when converting public keys for export the default format is
Damien Miller44b25042010-07-02 13:35:01 +1000445.Dq RFC4716 .
djm@openbsd.orged7bd5d2018-08-08 01:16:01 +0000446Setting a format of
447.Dq PEM
448when generating or updating a supported private key type will cause the
449key to be stored in the legacy PEM private key format.
Damien Miller265d3092005-03-02 12:05:06 +1100450.It Fl N Ar new_passphrase
451Provides the new passphrase.
Damien Miller0a80ca12010-02-27 07:55:05 +1100452.It Fl n Ar principals
453Specify one or more principals (user or host names) to be included in
454a certificate when signing a key.
455Multiple principals may be specified, separated by commas.
456Please see the
457.Sx CERTIFICATES
458section for details.
Damien Miller4e270b02010-04-16 15:56:21 +1000459.It Fl O Ar option
460Specify a certificate option when signing a key.
Damien Miller0a80ca12010-02-27 07:55:05 +1100461This option may be specified multiple times.
jmc@openbsd.org6b848972017-05-02 07:13:31 +0000462See also the
Damien Miller0a80ca12010-02-27 07:55:05 +1100463.Sx CERTIFICATES
jmc@openbsd.org6b848972017-05-02 07:13:31 +0000464section for further details.
djm@openbsd.org130283d2018-01-25 03:34:43 +0000465.Pp
466At present, no standard options are valid for host keys.
Damien Miller4e270b02010-04-16 15:56:21 +1000467The options that are valid for user certificates are:
jmc@openbsd.org6b848972017-05-02 07:13:31 +0000468.Pp
469.Bl -tag -width Ds -compact
Damien Millerc59e2442010-03-22 05:50:31 +1100470.It Ic clear
471Clear all enabled permissions.
472This is useful for clearing the default set of permissions so permissions may
473be added individually.
jmc@openbsd.org6b848972017-05-02 07:13:31 +0000474.Pp
jmc@openbsd.orgd4084cd2017-04-29 06:06:01 +0000475.It Ic critical : Ns Ar name Ns Op Ns = Ns Ar contents
jmc@openbsd.org6b848972017-05-02 07:13:31 +0000476.It Ic extension : Ns Ar name Ns Op Ns = Ns Ar contents
477Includes an arbitrary certificate critical option or extension.
478The specified
djm@openbsd.org249516e2017-04-29 04:12:25 +0000479.Ar name
jmc@openbsd.orgd4084cd2017-04-29 06:06:01 +0000480should include a domain suffix, e.g.\&
djm@openbsd.org249516e2017-04-29 04:12:25 +0000481.Dq name@example.com .
jmc@openbsd.orgd4084cd2017-04-29 06:06:01 +0000482If
djm@openbsd.org249516e2017-04-29 04:12:25 +0000483.Ar contents
484is specified then it is included as the contents of the extension/option
485encoded as a string, otherwise the extension/option is created with no
486contents (usually indicating a flag).
487Extensions may be ignored by a client or server that does not recognise them,
488whereas unknown critical options will cause the certificate to be refused.
jmc@openbsd.org6b848972017-05-02 07:13:31 +0000489.Pp
490.It Ic force-command Ns = Ns Ar command
491Forces the execution of
492.Ar command
493instead of any shell or command specified by the user when
494the certificate is used for authentication.
495.Pp
496.It Ic no-agent-forwarding
497Disable
498.Xr ssh-agent 1
499forwarding (permitted by default).
500.Pp
501.It Ic no-port-forwarding
502Disable port forwarding (permitted by default).
503.Pp
504.It Ic no-pty
505Disable PTY allocation (permitted by default).
506.Pp
507.It Ic no-user-rc
508Disable execution of
509.Pa ~/.ssh/rc
510by
511.Xr sshd 8
512(permitted by default).
513.Pp
514.It Ic no-x11-forwarding
515Disable X11 forwarding (permitted by default).
516.Pp
517.It Ic permit-agent-forwarding
518Allows
519.Xr ssh-agent 1
520forwarding.
521.Pp
522.It Ic permit-port-forwarding
523Allows port forwarding.
524.Pp
525.It Ic permit-pty
526Allows PTY allocation.
527.Pp
528.It Ic permit-user-rc
529Allows execution of
530.Pa ~/.ssh/rc
531by
532.Xr sshd 8 .
533.Pp
djm@openbsd.org130283d2018-01-25 03:34:43 +0000534.It Ic permit-X11-forwarding
jmc@openbsd.org6b848972017-05-02 07:13:31 +0000535Allows X11 forwarding.
536.Pp
djm@openbsd.org2e712632019-11-25 00:54:23 +0000537.It Ic no-touch-required
538Do not require signatures made using this key require demonstration
539of user presence (e.g. by having the user touch the key).
540This option only makes sense for the Security Key algorithms
541.Cm ecdsa-sk
542and
543.Cm ed25519-sk .
544.Pp
jmc@openbsd.org6b848972017-05-02 07:13:31 +0000545.It Ic source-address Ns = Ns Ar address_list
546Restrict the source addresses from which the certificate is considered valid.
547The
548.Ar address_list
549is a comma-separated list of one or more address/netmask pairs in CIDR
550format.
551.El
Damien Miller265d3092005-03-02 12:05:06 +1100552.It Fl P Ar passphrase
553Provides the (old) passphrase.
Damien Miller32aa1441999-10-29 09:15:49 +1000554.It Fl p
555Requests changing the passphrase of a private key file instead of
Damien Miller450a7a12000-03-26 13:04:51 +1000556creating a new private key.
557The program will prompt for the file
Damien Miller32aa1441999-10-29 09:15:49 +1000558containing the private key, for the old passphrase, and twice for the
559new passphrase.
Damien Miller072fdcd2013-01-20 22:34:04 +1100560.It Fl Q
561Test whether keys have been revoked in a KRL.
Damien Miller32aa1441999-10-29 09:15:49 +1000562.It Fl q
563Silence
564.Nm ssh-keygen .
djm@openbsd.org63bba572018-12-07 03:33:18 +0000565.It Fl R Ar hostname | [hostname]:port
djm@openbsd.org737e4ed2018-12-07 03:32:26 +0000566Removes all keys belonging to the specified
Damien Miller4b42d7f2005-03-01 21:48:35 +1100567.Ar hostname
djm@openbsd.org737e4ed2018-12-07 03:32:26 +0000568(with optional port number)
Damien Miller4c9c6fd2005-03-02 12:03:43 +1100569from a
Damien Miller4b42d7f2005-03-01 21:48:35 +1100570.Pa known_hosts
571file.
Damien Miller4c9c6fd2005-03-02 12:03:43 +1100572This option is useful to delete hashed hosts (see the
Damien Miller4b42d7f2005-03-01 21:48:35 +1100573.Fl H
574option above).
Damien Miller265d3092005-03-02 12:05:06 +1100575.It Fl r Ar hostname
576Print the SSHFP fingerprint resource record named
577.Ar hostname
578for the specified public key file.
Darren Tucker019cefe2003-08-02 22:40:07 +1000579.It Fl S Ar start
580Specify start point (in hex) when generating candidate moduli for DH-GEX.
Damien Miller0a80ca12010-02-27 07:55:05 +1100581.It Fl s Ar ca_key
582Certify (sign) a public key using the specified CA key.
583Please see the
584.Sx CERTIFICATES
585section for details.
Damien Millerf3747bf2013-01-18 11:44:04 +1100586.Pp
587When generating a KRL,
588.Fl s
Damien Millerac5542b2013-01-20 22:33:02 +1100589specifies a path to a CA public key file used to revoke certificates directly
Damien Millerf3747bf2013-01-18 11:44:04 +1100590by key ID or serial number.
591See the
592.Sx KEY REVOCATION LISTS
593section for details.
Darren Tucker019cefe2003-08-02 22:40:07 +1000594.It Fl T Ar output_file
595Test DH group exchange candidate primes (generated using the
596.Fl G
597option) for safety.
djm@openbsd.org97dc5d12019-11-18 04:50:45 +0000598.It Fl t Cm dsa | ecdsa | ecdsa-sk | ed25519 | ed25519-sk | rsa
Damien Miller265d3092005-03-02 12:05:06 +1100599Specifies the type of key to create.
600The possible values are
Damien Miller6186bbc2010-09-24 22:00:54 +1000601.Dq dsa ,
Damien Miller8ba0ead2013-12-18 17:46:27 +1100602.Dq ecdsa ,
naddy@openbsd.orgaa4c6402019-11-07 08:38:38 +0000603.Dq ecdsa-sk ,
Damien Miller8ba0ead2013-12-18 17:46:27 +1100604.Dq ed25519 ,
djm@openbsd.org97dc5d12019-11-18 04:50:45 +0000605.Dq ed25519-sk ,
Damien Miller265d3092005-03-02 12:05:06 +1100606or
jmc@openbsd.orgf10c0d32017-05-02 17:04:09 +0000607.Dq rsa .
djm@openbsd.org476e3552019-05-20 00:20:35 +0000608.Pp
609This flag may also be used to specify the desired signature type when
jmc@openbsd.org85ceb0e2019-05-20 06:01:59 +0000610signing certificates using an RSA CA key.
djm@openbsd.org476e3552019-05-20 00:20:35 +0000611The available RSA signature variants are
612.Dq ssh-rsa
613(SHA1 signatures, not recommended),
jmc@openbsd.org85ceb0e2019-05-20 06:01:59 +0000614.Dq rsa-sha2-256 ,
615and
djm@openbsd.org476e3552019-05-20 00:20:35 +0000616.Dq rsa-sha2-512
617(the default).
djm@openbsd.orga98339e2017-06-28 01:09:22 +0000618.It Fl U
619When used in combination with
620.Fl s ,
621this option indicates that a CA key resides in a
622.Xr ssh-agent 1 .
623See the
624.Sx CERTIFICATES
625section for more information.
Damien Millerac5542b2013-01-20 22:33:02 +1100626.It Fl u
627Update a KRL.
628When specified with
629.Fl k ,
Damien Miller881a7a22013-01-20 22:34:46 +1100630keys listed via the command line are added to the existing KRL rather than
Damien Millerac5542b2013-01-20 22:33:02 +1100631a new KRL being created.
Damien Miller0a80ca12010-02-27 07:55:05 +1100632.It Fl V Ar validity_interval
633Specify a validity interval when signing a certificate.
634A validity interval may consist of a single time, indicating that the
635certificate is valid beginning now and expiring at that time, or may consist
636of two times separated by a colon to indicate an explicit time interval.
djm@openbsd.org@openbsd.orgd52131a2017-11-03 05:14:04 +0000637.Pp
638The start time may be specified as the string
639.Dq always
640to indicate the certificate has no specified start time,
djm@openbsd.orgbf0fbf22018-03-12 00:52:01 +0000641a date in YYYYMMDD format, a time in YYYYMMDDHHMM[SS] format,
djm@openbsd.org@openbsd.orgd52131a2017-11-03 05:14:04 +0000642a relative time (to the current time) consisting of a minus sign followed by
643an interval in the format described in the
Damien Millerfecfd112013-07-18 16:11:50 +1000644TIME FORMATS section of
Damien Miller77497e12010-03-22 05:50:51 +1100645.Xr sshd_config 5 .
djm@openbsd.org@openbsd.orgd52131a2017-11-03 05:14:04 +0000646.Pp
djm@openbsd.orgbf0fbf22018-03-12 00:52:01 +0000647The end time may be specified as a YYYYMMDD date, a YYYYMMDDHHMM[SS] time,
djm@openbsd.org@openbsd.orgd52131a2017-11-03 05:14:04 +0000648a relative time starting with a plus character or the string
649.Dq forever
650to indicate that the certificate has no expirty date.
Damien Miller0a80ca12010-02-27 07:55:05 +1100651.Pp
652For example:
653.Dq +52w1d
654(valid from now to 52 weeks and one day from now),
655.Dq -4w:+4w
656(valid from four weeks ago to four weeks from now),
657.Dq 20100101123000:20110101123000
658(valid from 12:30 PM, January 1st, 2010 to 12:30 PM, January 1st, 2011),
659.Dq -1d:20110101
660(valid from yesterday to midnight, January 1st, 2011).
djm@openbsd.org@openbsd.orgd52131a2017-11-03 05:14:04 +0000661.Dq -1m:forever
662(valid from one minute ago and never expiring).
Darren Tucker06930c72003-12-31 11:34:51 +1100663.It Fl v
664Verbose mode.
665Causes
666.Nm
667to print debugging messages about its progress.
668This is helpful for debugging moduli generation.
669Multiple
670.Fl v
671options increase the verbosity.
672The maximum is 3.
Damien Miller265d3092005-03-02 12:05:06 +1100673.It Fl W Ar generator
674Specify desired generator when testing candidate moduli for DH-GEX.
naddy@openbsd.orgaa4c6402019-11-07 08:38:38 +0000675.It Fl w Ar provider
676Specifies a path to a security key provider library that will be used when
djm@openbsd.org6bff9522019-11-14 21:27:29 +0000677creating any security key-hosted keys, overriding the default of the
678internal support for USB HID keys.
naddy@openbsd.orgaa4c6402019-11-07 08:38:38 +0000679.It Fl x Ar flags
680Specifies the security key flags to use when enrolling a security key-hosted
681key.
djm@openbsd.orgdaeaf412019-11-25 00:55:58 +0000682Flags may be specified by name or directly as a hexadecimal value.
683Only one named flag is supported at present:
684.Cm no-touch-required ,
685which indicates that the generated private key should not require touch
686events (user presence) when making signatures.
687Note that
688.Xr sshd 8
689will refuse such signatures by default, unless overridden via
690an authorized_keys option.
Damien Miller265d3092005-03-02 12:05:06 +1100691.It Fl y
692This option will read a private
693OpenSSH format file and print an OpenSSH public key to stdout.
jmc@openbsd.orgf23d91f2019-09-05 05:47:23 +0000694.It Fl Y Cm sign
djm@openbsd.org2a9c9f72019-09-03 08:34:19 +0000695Cryptographically sign a file or some data using a SSH key.
696When signing,
697.Nm
698accepts zero or more files to sign on the command-line - if no files
699are specified then
700.Nm
701will sign data presented on standard input.
702Signatures are written to the path of the input file with
703.Dq .sig
704appended, or to standard output if the message to be signed was read from
705standard input.
706.Pp
707The key used for signing is specified using the
708.Fl f
709option and may refer to either a private key, or a public key with the private
710half available via
711.Xr ssh-agent 1 .
712An additional signature namespace, used to prevent signature confusion across
713different domains of use (e.g. file signing vs email signing) must be provided
714via the
715.Fl n
716flag.
717Namespaces are arbitrary strings, and may include:
718.Dq file
719for file signing,
720.Dq email
721for email signing.
722For custom uses, it is recommended to use names following a
723NAMESPACE@YOUR.DOMAIN pattern to generate unambiguous namespaces.
jmc@openbsd.orgf23d91f2019-09-05 05:47:23 +0000724.It Fl Y Cm verify
djm@openbsd.org2a9c9f72019-09-03 08:34:19 +0000725Request to verify a signature generated using
726.Nm
jmc@openbsd.orgf23d91f2019-09-05 05:47:23 +0000727.Fl Y Cm sign
djm@openbsd.org2a9c9f72019-09-03 08:34:19 +0000728as described above.
729When verifying a signature,
730.Nm
731accepts a message on standard input and a signature namespace using
732.Fl n .
733A file containing the corresponding signature must also be supplied using the
734.Fl s
735flag, along with the identity of the signer using
736.Fl I
737and a list of allowed signers via the
738.Fl f
739flag.
740The format of the allowed signers file is documented in the
741.Sx ALLOWED SIGNERS
742section below.
743A file containing revoked keys can be passed using the
744.Fl r
jmc@openbsd.orgdb1e6f62019-09-04 05:56:54 +0000745flag.
746The revocation file may be a KRL or a one-per-line list of public keys.
djm@openbsd.org2a9c9f72019-09-03 08:34:19 +0000747Successful verification by an authorized signer is signalled by
748.Nm
jmc@openbsd.org70fc9a62019-10-22 08:50:35 +0000749returning a zero exit status.
djm@openbsd.org8aa2aa32019-09-16 03:23:02 +0000750.It Fl Y Cm check-novalidate
751Checks that a signature generated using
752.Nm
753.Fl Y Cm sign
754has a valid structure.
755This does not validate if a signature comes from an authorized signer.
756When testing a signature,
757.Nm
758accepts a message on standard input and a signature namespace using
759.Fl n .
760A file containing the corresponding signature must also be supplied using the
761.Fl s
jmc@openbsd.org90d4b252019-09-20 18:50:58 +0000762flag.
763Successful testing of the signature is signalled by
djm@openbsd.org8aa2aa32019-09-16 03:23:02 +0000764.Nm
djm@openbsd.org2a9c9f72019-09-03 08:34:19 +0000765returning a zero exit status.
Damien Miller4e270b02010-04-16 15:56:21 +1000766.It Fl z Ar serial_number
767Specifies a serial number to be embedded in the certificate to distinguish
768this certificate from others from the same CA.
djm@openbsd.orgbe063942019-01-23 04:51:02 +0000769If the
770.Ar serial_number
771is prefixed with a
772.Sq +
773character, then the serial number will be incremented for each certificate
774signed on a single command-line.
Damien Miller4e270b02010-04-16 15:56:21 +1000775The default serial number is zero.
Damien Millerf3747bf2013-01-18 11:44:04 +1100776.Pp
777When generating a KRL, the
778.Fl z
779flag is used to specify a KRL version number.
Damien Miller32aa1441999-10-29 09:15:49 +1000780.El
Darren Tucker019cefe2003-08-02 22:40:07 +1000781.Sh MODULI GENERATION
782.Nm
783may be used to generate groups for the Diffie-Hellman Group Exchange
784(DH-GEX) protocol.
785Generating these groups is a two-step process: first, candidate
786primes are generated using a fast, but memory intensive process.
787These candidate primes are then tested for suitability (a CPU-intensive
788process).
789.Pp
790Generation of primes is performed using the
791.Fl G
792option.
793The desired length of the primes may be specified by the
794.Fl b
795option.
796For example:
797.Pp
Damien Miller265d3092005-03-02 12:05:06 +1100798.Dl # ssh-keygen -G moduli-2048.candidates -b 2048
Darren Tucker019cefe2003-08-02 22:40:07 +1000799.Pp
800By default, the search for primes begins at a random point in the
801desired length range.
802This may be overridden using the
803.Fl S
804option, which specifies a different start point (in hex).
805.Pp
Damien Millerdfceafe2012-07-06 13:44:19 +1000806Once a set of candidates have been generated, they must be screened for
Darren Tucker019cefe2003-08-02 22:40:07 +1000807suitability.
808This may be performed using the
809.Fl T
810option.
811In this mode
812.Nm
813will read candidates from standard input (or a file specified using the
814.Fl f
815option).
816For example:
817.Pp
Damien Miller265d3092005-03-02 12:05:06 +1100818.Dl # ssh-keygen -T moduli-2048 -f moduli-2048.candidates
Darren Tucker019cefe2003-08-02 22:40:07 +1000819.Pp
820By default, each candidate will be subjected to 100 primality tests.
821This may be overridden using the
822.Fl a
823option.
824The DH generator value will be chosen automatically for the
825prime under consideration.
826If a specific generator is desired, it may be requested using the
827.Fl W
828option.
Damien Miller265d3092005-03-02 12:05:06 +1100829Valid generator values are 2, 3, and 5.
Darren Tucker019cefe2003-08-02 22:40:07 +1000830.Pp
831Screened DH groups may be installed in
832.Pa /etc/moduli .
833It is important that this file contains moduli of a range of bit lengths and
834that both ends of a connection share common moduli.
Damien Miller0a80ca12010-02-27 07:55:05 +1100835.Sh CERTIFICATES
836.Nm
837supports signing of keys to produce certificates that may be used for
838user or host authentication.
839Certificates consist of a public key, some identity information, zero or
Damien Miller1f181422010-04-18 08:08:03 +1000840more principal (user or host) names and a set of options that
Damien Miller0a80ca12010-02-27 07:55:05 +1100841are signed by a Certification Authority (CA) key.
842Clients or servers may then trust only the CA key and verify its signature
843on a certificate rather than trusting many user/host keys.
844Note that OpenSSH certificates are a different, and much simpler, format to
845the X.509 certificates used in
846.Xr ssl 8 .
847.Pp
848.Nm
849supports two types of certificates: user and host.
850User certificates authenticate users to servers, whereas host certificates
Damien Miller15f5b562010-03-03 10:25:21 +1100851authenticate server hosts to users.
852To generate a user certificate:
Damien Miller0a80ca12010-02-27 07:55:05 +1100853.Pp
854.Dl $ ssh-keygen -s /path/to/ca_key -I key_id /path/to/user_key.pub
855.Pp
856The resultant certificate will be placed in
Damien Miller1b61a282010-03-22 05:55:06 +1100857.Pa /path/to/user_key-cert.pub .
Damien Miller0a80ca12010-02-27 07:55:05 +1100858A host certificate requires the
859.Fl h
860option:
861.Pp
862.Dl $ ssh-keygen -s /path/to/ca_key -I key_id -h /path/to/host_key.pub
863.Pp
864The host certificate will be output to
Damien Miller1b61a282010-03-22 05:55:06 +1100865.Pa /path/to/host_key-cert.pub .
Damien Miller757f34e2010-08-05 13:05:31 +1000866.Pp
867It is possible to sign using a CA key stored in a PKCS#11 token by
868providing the token library using
869.Fl D
870and identifying the CA key by providing its public half as an argument
871to
872.Fl s :
873.Pp
naddy@openbsd.org05291e52015-08-20 19:20:06 +0000874.Dl $ ssh-keygen -s ca_key.pub -D libpkcs11.so -I key_id user_key.pub
Damien Miller757f34e2010-08-05 13:05:31 +1000875.Pp
djm@openbsd.orga98339e2017-06-28 01:09:22 +0000876Similarly, it is possible for the CA key to be hosted in a
877.Xr ssh-agent 1 .
878This is indicated by the
879.Fl U
880flag and, again, the CA key must be identified by its public half.
881.Pp
882.Dl $ ssh-keygen -Us ca_key.pub -I key_id user_key.pub
883.Pp
Damien Miller757f34e2010-08-05 13:05:31 +1000884In all cases,
Damien Miller0a80ca12010-02-27 07:55:05 +1100885.Ar key_id
886is a "key identifier" that is logged by the server when the certificate
887is used for authentication.
888.Pp
889Certificates may be limited to be valid for a set of principal (user/host)
890names.
891By default, generated certificates are valid for all users or hosts.
892To generate a certificate for a specified set of principals:
893.Pp
894.Dl $ ssh-keygen -s ca_key -I key_id -n user1,user2 user_key.pub
naddy@openbsd.org05291e52015-08-20 19:20:06 +0000895.Dl "$ ssh-keygen -s ca_key -I key_id -h -n host.domain host_key.pub"
Damien Miller0a80ca12010-02-27 07:55:05 +1100896.Pp
897Additional limitations on the validity and use of user certificates may
Damien Miller1f181422010-04-18 08:08:03 +1000898be specified through certificate options.
Damien Miller4e270b02010-04-16 15:56:21 +1000899A certificate option may disable features of the SSH session, may be
Damien Miller0a80ca12010-02-27 07:55:05 +1100900valid only when presented from particular source addresses or may
901force the use of a specific command.
Damien Miller4e270b02010-04-16 15:56:21 +1000902For a list of valid certificate options, see the documentation for the
Damien Miller0a80ca12010-02-27 07:55:05 +1100903.Fl O
904option above.
905.Pp
906Finally, certificates may be defined with a validity lifetime.
907The
908.Fl V
909option allows specification of certificate start and end times.
910A certificate that is presented at a time outside this range will not be
911considered valid.
Darren Tucker3ee50c52012-09-06 21:18:11 +1000912By default, certificates are valid from
913.Ux
914Epoch to the distant future.
Damien Miller0a80ca12010-02-27 07:55:05 +1100915.Pp
916For certificates to be used for user or host authentication, the CA
917public key must be trusted by
918.Xr sshd 8
919or
920.Xr ssh 1 .
921Please refer to those manual pages for details.
Damien Millerf3747bf2013-01-18 11:44:04 +1100922.Sh KEY REVOCATION LISTS
923.Nm
924is able to manage OpenSSH format Key Revocation Lists (KRLs).
925These binary files specify keys or certificates to be revoked using a
Damien Miller13797712013-12-29 17:47:14 +1100926compact format, taking as little as one bit per certificate if they are being
Damien Millerf3747bf2013-01-18 11:44:04 +1100927revoked by serial number.
928.Pp
929KRLs may be generated using the
930.Fl k
931flag.
Damien Miller881a7a22013-01-20 22:34:46 +1100932This option reads one or more files from the command line and generates a new
Damien Millerf3747bf2013-01-18 11:44:04 +1100933KRL.
934The files may either contain a KRL specification (see below) or public keys,
935listed one per line.
936Plain public keys are revoked by listing their hash or contents in the KRL and
937certificates revoked by serial number or key ID (if the serial is zero or
938not available).
939.Pp
940Revoking keys using a KRL specification offers explicit control over the
941types of record used to revoke keys and may be used to directly revoke
942certificates by serial number or key ID without having the complete original
943certificate on hand.
944A KRL specification consists of lines containing one of the following directives
945followed by a colon and some directive-specific information.
946.Bl -tag -width Ds
Damien Millera0a7ee82013-01-20 22:35:06 +1100947.It Cm serial : Ar serial_number Ns Op - Ns Ar serial_number
Damien Millerf3747bf2013-01-18 11:44:04 +1100948Revokes a certificate with the specified serial number.
Damien Millerac5542b2013-01-20 22:33:02 +1100949Serial numbers are 64-bit values, not including zero and may be expressed
Damien Millerf3747bf2013-01-18 11:44:04 +1100950in decimal, hex or octal.
951If two serial numbers are specified separated by a hyphen, then the range
952of serial numbers including and between each is revoked.
953The CA key must have been specified on the
954.Nm
Damien Miller881a7a22013-01-20 22:34:46 +1100955command line using the
Damien Millerf3747bf2013-01-18 11:44:04 +1100956.Fl s
957option.
958.It Cm id : Ar key_id
959Revokes a certificate with the specified key ID string.
960The CA key must have been specified on the
961.Nm
Damien Miller881a7a22013-01-20 22:34:46 +1100962command line using the
Damien Millerf3747bf2013-01-18 11:44:04 +1100963.Fl s
964option.
965.It Cm key : Ar public_key
966Revokes the specified key.
Damien Millerac5542b2013-01-20 22:33:02 +1100967If a certificate is listed, then it is revoked as a plain public key.
Damien Millerf3747bf2013-01-18 11:44:04 +1100968.It Cm sha1 : Ar public_key
djm@openbsd.org9405c622018-09-12 01:21:34 +0000969Revokes the specified key by including its SHA1 hash in the KRL.
970.It Cm sha256 : Ar public_key
971Revokes the specified key by including its SHA256 hash in the KRL.
972KRLs that revoke keys by SHA256 hash are not supported by OpenSSH versions
973prior to 7.9.
974.It Cm hash : Ar fingerprint
djm@openbsd.orgf0fcd7e2018-09-12 06:18:59 +0000975Revokes a key using a fingerprint hash, as obtained from a
djm@openbsd.org9405c622018-09-12 01:21:34 +0000976.Xr sshd 8
977authentication log message or the
978.Nm
979.Fl l
980flag.
981Only SHA256 fingerprints are supported here and resultant KRLs are
982not supported by OpenSSH versions prior to 7.9.
Damien Millerf3747bf2013-01-18 11:44:04 +1100983.El
984.Pp
985KRLs may be updated using the
986.Fl u
987flag in addition to
988.Fl k .
Damien Miller881a7a22013-01-20 22:34:46 +1100989When this option is specified, keys listed via the command line are merged into
Damien Millerf3747bf2013-01-18 11:44:04 +1100990the KRL, adding to those already there.
991.Pp
992It is also possible, given a KRL, to test whether it revokes a particular key
993(or keys).
994The
995.Fl Q
jmc@openbsd.org8b290082015-11-05 09:48:05 +0000996flag will query an existing KRL, testing each key specified on the command line.
Damien Miller881a7a22013-01-20 22:34:46 +1100997If any key listed on the command line has been revoked (or an error encountered)
Damien Millerf3747bf2013-01-18 11:44:04 +1100998then
999.Nm
1000will exit with a non-zero exit status.
1001A zero exit status will only be returned if no key was revoked.
djm@openbsd.org2a9c9f72019-09-03 08:34:19 +00001002.Sh ALLOWED SIGNERS
1003When verifying signatures,
1004.Nm
1005uses a simple list of identities and keys to determine whether a signature
1006comes from an authorized source.
1007This "allowed signers" file uses a format patterned after the
1008AUTHORIZED_KEYS FILE FORMAT described in
jmc@openbsd.orgdb1e6f62019-09-04 05:56:54 +00001009.Xr sshd 8 .
djm@openbsd.org2a9c9f72019-09-03 08:34:19 +00001010Each line of the file contains the following space-separated fields:
1011principals, options, keytype, base64-encoded key.
1012Empty lines and lines starting with a
1013.Ql #
1014are ignored as comments.
1015.Pp
1016The principals field is a pattern-list (See PATTERNS in
1017.Xr ssh_config 5 )
1018consisting of one or more comma-separated USER@DOMAIN identity patterns
1019that are accepted for signing.
1020When verifying, the identity presented via the
jmc@openbsd.org70fc9a62019-10-22 08:50:35 +00001021.Fl I
1022option must match a principals pattern in order for the corresponding key to be
djm@openbsd.org2a9c9f72019-09-03 08:34:19 +00001023considered acceptable for verification.
1024.Pp
1025The options (if present) consist of comma-separated option specifications.
1026No spaces are permitted, except within double quotes.
1027The following option specifications are supported (note that option keywords
1028are case-insensitive):
1029.Bl -tag -width Ds
1030.It Cm cert-authority
1031Indicates that this key is accepted as a certificate authority (CA) and
1032that certificates signed by this CA may be accepted for verification.
1033.It Cm namespaces="namespace-list"
1034Specifies a pattern-list of namespaces that are accepted for this key.
djm@openbsd.orgd637c4a2019-09-03 08:35:27 +00001035If this option is present, the signature namespace embedded in the
djm@openbsd.org2a9c9f72019-09-03 08:34:19 +00001036signature object and presented on the verification command-line must
1037match the specified list before the key will be considered acceptable.
1038.El
1039.Pp
1040When verifying signatures made by certificates, the expected principal
1041name must match both the principals pattern in the allowed signers file and
1042the principals embedded in the certificate itself.
1043.Pp
1044An example allowed signers file:
1045.Bd -literal -offset 3n
1046# Comments allowed at start of line
1047user1@example.com,user2@example.com ssh-rsa AAAAX1...
1048# A certificate authority, trusted for all principals in a domain.
1049*@example.com cert-authority ssh-ed25519 AAAB4...
1050# A key that is accepted only for file signing.
1051user2@example.com namespaces="file" ssh-ed25519 AAA41...
1052.Ed
naddy@openbsd.orgaa4c6402019-11-07 08:38:38 +00001053.Sh ENVIRONMENT
1054.Bl -tag -width Ds
1055.It Ev SSH_SK_PROVIDER
1056Specifies the path to a security key provider library used to interact with
1057hardware security keys.
1058.El
Damien Miller32aa1441999-10-29 09:15:49 +10001059.Sh FILES
Damien Miller6186bbc2010-09-24 22:00:54 +10001060.Bl -tag -width Ds -compact
Damien Miller167ea5d2005-05-26 12:04:02 +10001061.It Pa ~/.ssh/id_dsa
Damien Miller6186bbc2010-09-24 22:00:54 +10001062.It Pa ~/.ssh/id_ecdsa
naddy@openbsd.orgaa4c6402019-11-07 08:38:38 +00001063.It Pa ~/.ssh/id_ecdsa_sk
Damien Miller8ba0ead2013-12-18 17:46:27 +11001064.It Pa ~/.ssh/id_ed25519
naddy@openbsd.orgf0edda82019-11-18 23:16:49 +00001065.It Pa ~/.ssh/id_ed25519_sk
Damien Miller167ea5d2005-05-26 12:04:02 +10001066.It Pa ~/.ssh/id_rsa
naddy@openbsd.orgf0edda82019-11-18 23:16:49 +00001067Contains the DSA, ECDSA, security key-hosted ECDSA, Ed25519,
1068security key-hosted Ed25519 or RSA authentication identity of the user.
Ben Lindstrom18a82ac2001-04-11 15:59:35 +00001069This file should not be readable by anyone but the user.
1070It is possible to
1071specify a passphrase when generating the key; that passphrase will be
Darren Tucker199ee6f2009-10-24 11:50:17 +11001072used to encrypt the private part of this file using 128-bit AES.
Ben Lindstrom18a82ac2001-04-11 15:59:35 +00001073This file is not automatically accessed by
1074.Nm
1075but it is offered as the default file for the private key.
Ben Lindstrombda98b02001-07-04 03:35:24 +00001076.Xr ssh 1
Ben Lindstrom18a82ac2001-04-11 15:59:35 +00001077will read this file when a login attempt is made.
Damien Miller6186bbc2010-09-24 22:00:54 +10001078.Pp
1079.It Pa ~/.ssh/id_dsa.pub
1080.It Pa ~/.ssh/id_ecdsa.pub
naddy@openbsd.orgaa4c6402019-11-07 08:38:38 +00001081.It Pa ~/.ssh/id_ecdsa_sk.pub
Damien Miller8ba0ead2013-12-18 17:46:27 +11001082.It Pa ~/.ssh/id_ed25519.pub
naddy@openbsd.orgf0edda82019-11-18 23:16:49 +00001083.It Pa ~/.ssh/id_ed25519_sk.pub
Damien Miller167ea5d2005-05-26 12:04:02 +10001084.It Pa ~/.ssh/id_rsa.pub
naddy@openbsd.orgf0edda82019-11-18 23:16:49 +00001085Contains the DSA, ECDSA, security key-hosted ECDSA, Ed25519,
1086security key-hosted Ed25519 or RSA public key for authentication.
Damien Millere247cc42000-05-07 12:03:14 +10001087The contents of this file should be added to
Damien Miller167ea5d2005-05-26 12:04:02 +10001088.Pa ~/.ssh/authorized_keys
Damien Millere247cc42000-05-07 12:03:14 +10001089on all machines
Ben Lindstrom594e2032001-09-12 18:35:30 +00001090where the user wishes to log in using public key authentication.
Damien Millere247cc42000-05-07 12:03:14 +10001091There is no need to keep the contents of this file secret.
Damien Miller6186bbc2010-09-24 22:00:54 +10001092.Pp
Darren Tucker019cefe2003-08-02 22:40:07 +10001093.It Pa /etc/moduli
1094Contains Diffie-Hellman groups used for DH-GEX.
1095The file format is described in
1096.Xr moduli 5 .
Damien Miller37023962000-07-11 17:31:38 +10001097.El
Damien Miller32aa1441999-10-29 09:15:49 +10001098.Sh SEE ALSO
1099.Xr ssh 1 ,
1100.Xr ssh-add 1 ,
Damien Miller2e8b1c81999-11-15 23:33:56 +11001101.Xr ssh-agent 1 ,
Darren Tucker019cefe2003-08-02 22:40:07 +10001102.Xr moduli 5 ,
Ben Lindstrom77788dc2001-02-10 23:10:33 +00001103.Xr sshd 8
Ben Lindstrom5a707822001-04-22 17:15:46 +00001104.Rs
Damien Millerc0367fb2007-01-05 16:25:46 +11001105.%R RFC 4716
1106.%T "The Secure Shell (SSH) Public Key File Format"
1107.%D 2006
Ben Lindstrom5a707822001-04-22 17:15:46 +00001108.Re
Damien Millerf1ce5052003-06-11 22:04:39 +10001109.Sh AUTHORS
1110OpenSSH is a derivative of the original and free
1111ssh 1.2.12 release by Tatu Ylonen.
1112Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos,
1113Theo de Raadt and Dug Song
1114removed many bugs, re-added newer features and
1115created OpenSSH.
1116Markus Friedl contributed the support for SSH
1117protocol versions 1.5 and 2.0.