| 1 |
.\" $OpenBSD: ssh-keygen.1,v 1.237 2025/12/22 01:49:03 djm Exp $ |
| 2 |
.\" |
| 3 |
.\" Author: Tatu Ylonen <[email protected]> |
| 4 |
.\" Copyright (c) 1995 Tatu Ylonen <[email protected]>, Espoo, Finland |
| 5 |
.\" All rights reserved |
| 6 |
.\" |
| 7 |
.\" 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". |
| 12 |
.\" |
| 13 |
.\" |
| 14 |
.\" 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. |
| 17 |
.\" |
| 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. |
| 37 |
.\" |
| 38 |
.Dd $Mdocdate: December 22 2025 $ |
| 39 |
.Dt SSH-KEYGEN 1 |
| 40 |
.Os |
| 41 |
.Sh NAME |
| 42 |
.Nm ssh-keygen |
| 43 |
.Nd OpenSSH authentication key utility |
| 44 |
.Sh SYNOPSIS |
| 45 |
.Nm ssh-keygen |
| 46 |
.Op Fl q |
| 47 |
.Op Fl a Ar rounds |
| 48 |
.Op Fl b Ar bits |
| 49 |
.Op Fl C Ar comment |
| 50 |
.Op Fl f Ar output_keyfile |
| 51 |
.Op Fl m Ar format |
| 52 |
.Op Fl N Ar new_passphrase |
| 53 |
.Op Fl O Ar option |
| 54 |
.Op Fl t Cm ecdsa | ecdsa-sk | ed25519 | ed25519-sk | rsa |
| 55 |
.Op Fl w Ar provider |
| 56 |
.Op Fl Z Ar cipher |
| 57 |
.Nm ssh-keygen |
| 58 |
.Fl p |
| 59 |
.Op Fl a Ar rounds |
| 60 |
.Op Fl f Ar keyfile |
| 61 |
.Op Fl m Ar format |
| 62 |
.Op Fl N Ar new_passphrase |
| 63 |
.Op Fl P Ar old_passphrase |
| 64 |
.Op Fl Z Ar cipher |
| 65 |
.Nm ssh-keygen |
| 66 |
.Fl i |
| 67 |
.Op Fl f Ar input_keyfile |
| 68 |
.Op Fl m Ar key_format |
| 69 |
.Nm ssh-keygen |
| 70 |
.Fl e |
| 71 |
.Op Fl f Ar input_keyfile |
| 72 |
.Op Fl m Ar key_format |
| 73 |
.Nm ssh-keygen |
| 74 |
.Fl y |
| 75 |
.Op Fl f Ar input_keyfile |
| 76 |
.Nm ssh-keygen |
| 77 |
.Fl c |
| 78 |
.Op Fl a Ar rounds |
| 79 |
.Op Fl C Ar comment |
| 80 |
.Op Fl f Ar keyfile |
| 81 |
.Op Fl P Ar passphrase |
| 82 |
.Nm ssh-keygen |
| 83 |
.Fl l |
| 84 |
.Op Fl v |
| 85 |
.Op Fl E Ar fingerprint_hash |
| 86 |
.Op Fl f Ar input_keyfile |
| 87 |
.Nm ssh-keygen |
| 88 |
.Fl B |
| 89 |
.Op Fl f Ar input_keyfile |
| 90 |
.Nm ssh-keygen |
| 91 |
.Fl D Ar pkcs11 |
| 92 |
.Nm ssh-keygen |
| 93 |
.Fl F Ar hostname |
| 94 |
.Op Fl lv |
| 95 |
.Op Fl f Ar known_hosts_file |
| 96 |
.Nm ssh-keygen |
| 97 |
.Fl H |
| 98 |
.Op Fl f Ar known_hosts_file |
| 99 |
.Nm ssh-keygen |
| 100 |
.Fl K |
| 101 |
.Op Fl a Ar rounds |
| 102 |
.Op Fl w Ar provider |
| 103 |
.Nm ssh-keygen |
| 104 |
.Fl R Ar hostname |
| 105 |
.Op Fl f Ar known_hosts_file |
| 106 |
.Nm ssh-keygen |
| 107 |
.Fl r Ar hostname |
| 108 |
.Op Fl g |
| 109 |
.Op Fl f Ar input_keyfile |
| 110 |
.Nm ssh-keygen |
| 111 |
.Fl M Cm generate |
| 112 |
.Op Fl O Ar option |
| 113 |
.Ar output_file |
| 114 |
.Nm ssh-keygen |
| 115 |
.Fl M Cm screen |
| 116 |
.Op Fl f Ar input_file |
| 117 |
.Op Fl O Ar option |
| 118 |
.Ar output_file |
| 119 |
.Nm ssh-keygen |
| 120 |
.Fl I Ar certificate_identity |
| 121 |
.Fl s Ar ca_key |
| 122 |
.Op Fl hU |
| 123 |
.Op Fl D Ar pkcs11_provider |
| 124 |
.Op Fl n Ar principals |
| 125 |
.Op Fl O Ar option |
| 126 |
.Op Fl V Ar validity_interval |
| 127 |
.Op Fl z Ar serial_number |
| 128 |
.Ar |
| 129 |
.Nm ssh-keygen |
| 130 |
.Fl L |
| 131 |
.Op Fl f Ar input_keyfile |
| 132 |
.Nm ssh-keygen |
| 133 |
.Fl A |
| 134 |
.Op Fl a Ar rounds |
| 135 |
.Op Fl f Ar prefix_path |
| 136 |
.Nm ssh-keygen |
| 137 |
.Fl k |
| 138 |
.Fl f Ar krl_file |
| 139 |
.Op Fl u |
| 140 |
.Op Fl s Ar ca_public |
| 141 |
.Op Fl z Ar version_number |
| 142 |
.Ar |
| 143 |
.Nm ssh-keygen |
| 144 |
.Fl Q |
| 145 |
.Op Fl l |
| 146 |
.Fl f Ar krl_file |
| 147 |
.Ar |
| 148 |
.Nm ssh-keygen |
| 149 |
.Fl Y Cm find-principals |
| 150 |
.Op Fl O Ar option |
| 151 |
.Fl s Ar signature_file |
| 152 |
.Fl f Ar allowed_signers_file |
| 153 |
.Nm ssh-keygen |
| 154 |
.Fl Y Cm match-principals |
| 155 |
.Fl I Ar signer_identity |
| 156 |
.Fl f Ar allowed_signers_file |
| 157 |
.Nm ssh-keygen |
| 158 |
.Fl Y Cm check-novalidate |
| 159 |
.Op Fl O Ar option |
| 160 |
.Fl n Ar namespace |
| 161 |
.Fl s Ar signature_file |
| 162 |
.Nm ssh-keygen |
| 163 |
.Fl Y Cm sign |
| 164 |
.Op Fl O Ar option |
| 165 |
.Fl f Ar key_file |
| 166 |
.Fl n Ar namespace |
| 167 |
.Ar |
| 168 |
.Nm ssh-keygen |
| 169 |
.Fl Y Cm verify |
| 170 |
.Op Fl O Ar option |
| 171 |
.Fl f Ar allowed_signers_file |
| 172 |
.Fl I Ar signer_identity |
| 173 |
.Fl n Ar namespace |
| 174 |
.Fl s Ar signature_file |
| 175 |
.Op Fl r Ar revocation_file |
| 176 |
.Sh DESCRIPTION |
| 177 |
.Nm |
| 178 |
generates, manages and converts authentication keys for |
| 179 |
.Xr ssh 1 . |
| 180 |
.Nm |
| 181 |
can create keys for use by SSH protocol version 2. |
| 182 |
.Pp |
| 183 |
The type of key to be generated is specified with the |
| 184 |
.Fl t |
| 185 |
option. |
| 186 |
If invoked without any arguments, |
| 187 |
.Nm |
| 188 |
will generate an Ed25519 key. |
| 189 |
.Pp |
| 190 |
.Nm |
| 191 |
is also used to generate groups for use in Diffie-Hellman group |
| 192 |
exchange (DH-GEX). |
| 193 |
See the |
| 194 |
.Sx MODULI GENERATION |
| 195 |
section for details. |
| 196 |
.Pp |
| 197 |
Finally, |
| 198 |
.Nm |
| 199 |
can be used to generate and update Key Revocation Lists, and to test whether |
| 200 |
given keys have been revoked by one. |
| 201 |
See the |
| 202 |
.Sx KEY REVOCATION LISTS |
| 203 |
section for details. |
| 204 |
.Pp |
| 205 |
Normally each user wishing to use SSH |
| 206 |
with public key authentication runs this once to create the authentication |
| 207 |
key in |
| 208 |
.Pa ~/.ssh/id_ecdsa , |
| 209 |
.Pa ~/.ssh/id_ecdsa_sk , |
| 210 |
.Pa ~/.ssh/id_ed25519 , |
| 211 |
.Pa ~/.ssh/id_ed25519_sk |
| 212 |
or |
| 213 |
.Pa ~/.ssh/id_rsa . |
| 214 |
Additionally, the system administrator may use this to generate host keys. |
| 215 |
.Pp |
| 216 |
Normally this program generates the key and asks for a file in which |
| 217 |
to store the private key. |
| 218 |
The public key is stored in a file with the same name but |
| 219 |
.Dq .pub |
| 220 |
appended. |
| 221 |
The program also asks for a passphrase. |
| 222 |
The passphrase may be empty to indicate no passphrase |
| 223 |
(host keys must have an empty passphrase), or it may be a string of |
| 224 |
arbitrary length. |
| 225 |
A passphrase is similar to a password, except it can be a phrase with a |
| 226 |
series of words, punctuation, numbers, whitespace, or any string of |
| 227 |
characters you want. |
| 228 |
Good passphrases are 10-30 characters long, are |
| 229 |
not simple sentences or otherwise easily guessable (English |
| 230 |
prose has only 1-2 bits of entropy per character, and provides very bad |
| 231 |
passphrases), and contain a mix of upper and lowercase letters, |
| 232 |
numbers, and non-alphanumeric characters. |
| 233 |
The passphrase can be changed later by using the |
| 234 |
.Fl p |
| 235 |
option. |
| 236 |
.Pp |
| 237 |
There is no way to recover a lost passphrase. |
| 238 |
If the passphrase is lost or forgotten, a new key must be generated |
| 239 |
and the corresponding public key copied to other machines. |
| 240 |
.Pp |
| 241 |
.Nm |
| 242 |
will by default write keys in an OpenSSH-specific format. |
| 243 |
This format is preferred as it offers better protection for |
| 244 |
keys at rest as well as allowing storage of key comments within |
| 245 |
the private key file itself. |
| 246 |
The key comment may be useful to help identify the key. |
| 247 |
The comment is initialized to |
| 248 |
.Dq user@host |
| 249 |
when the key is created, but can be changed using the |
| 250 |
.Fl c |
| 251 |
option. |
| 252 |
.Pp |
| 253 |
It is still possible for |
| 254 |
.Nm |
| 255 |
to write the previously-used PEM format private keys using the |
| 256 |
.Fl m |
| 257 |
flag. |
| 258 |
This may be used when generating new keys, and existing new-format |
| 259 |
keys may be converted using this option in conjunction with the |
| 260 |
.Fl p |
| 261 |
(change passphrase) flag. |
| 262 |
.Pp |
| 263 |
After a key is generated, |
| 264 |
.Nm |
| 265 |
will ask where the keys |
| 266 |
should be placed to be activated. |
| 267 |
.Pp |
| 268 |
The options are as follows: |
| 269 |
.Bl -tag -width Ds |
| 270 |
.It Fl A |
| 271 |
Generate host keys of all default key types (rsa, ecdsa, and |
| 272 |
ed25519) if they do not already exist. |
| 273 |
The host keys are generated with the default key file path, |
| 274 |
an empty passphrase, default bits for the key type, and default comment. |
| 275 |
If |
| 276 |
.Fl f |
| 277 |
has also been specified, its argument is used as a prefix to the |
| 278 |
default path for the resulting host key files. |
| 279 |
This is used by system administration scripts to generate new host keys. |
| 280 |
.It Fl a Ar rounds |
| 281 |
When saving a private key, this option specifies the number of KDF |
| 282 |
(key derivation function, currently |
| 283 |
.Xr bcrypt_pbkdf 3 ) |
| 284 |
rounds used. |
| 285 |
Higher numbers result in slower passphrase verification and increased |
| 286 |
resistance to brute-force password cracking (should the keys be stolen). |
| 287 |
The default is 16 rounds. |
| 288 |
.It Fl B |
| 289 |
Show the bubblebabble digest of specified private or public key file. |
| 290 |
.It Fl b Ar bits |
| 291 |
Specifies the number of bits in the key to create. |
| 292 |
For RSA keys, the minimum size is 1024 bits and the default is 3072 bits. |
| 293 |
Generally, 3072 bits is considered sufficient. |
| 294 |
For ECDSA keys, the |
| 295 |
.Fl b |
| 296 |
flag determines the key length by selecting from one of three elliptic |
| 297 |
curve sizes: 256, 384 or 521 bits. |
| 298 |
Attempting to use bit lengths other than these three values for ECDSA keys |
| 299 |
will fail. |
| 300 |
ECDSA-SK, Ed25519 and Ed25519-SK keys have a fixed length and the |
| 301 |
.Fl b |
| 302 |
flag will be ignored. |
| 303 |
.It Fl C Ar comment |
| 304 |
Provides a new comment. |
| 305 |
.It Fl c |
| 306 |
Requests changing the comment in the private and public key files. |
| 307 |
The program will prompt for the file containing the private keys, for |
| 308 |
the passphrase if the key has one, and for the new comment. |
| 309 |
.It Fl D Ar pkcs11 |
| 310 |
Download the public keys provided by the PKCS#11 shared library |
| 311 |
.Ar pkcs11 . |
| 312 |
When used in combination with |
| 313 |
.Fl s , |
| 314 |
this option indicates that a CA key resides in a PKCS#11 token (see the |
| 315 |
.Sx CERTIFICATES |
| 316 |
section for details). |
| 317 |
.It Fl E Ar fingerprint_hash |
| 318 |
Specifies the hash algorithm used when displaying key fingerprints. |
| 319 |
Valid options are: |
| 320 |
.Dq md5 |
| 321 |
and |
| 322 |
.Dq sha256 . |
| 323 |
The default is |
| 324 |
.Dq sha256 . |
| 325 |
.It Fl e |
| 326 |
This option will read a private or public OpenSSH key file and |
| 327 |
print to stdout a public key in one of the formats specified by the |
| 328 |
.Fl m |
| 329 |
option. |
| 330 |
The default export format is |
| 331 |
.Dq RFC4716 . |
| 332 |
This option allows exporting OpenSSH keys for use by other programs, including |
| 333 |
several commercial SSH implementations. |
| 334 |
.It Fl F Ar hostname | [hostname]:port |
| 335 |
Search for the specified |
| 336 |
.Ar hostname |
| 337 |
(with optional port number) |
| 338 |
in a |
| 339 |
.Pa known_hosts |
| 340 |
file, listing any occurrences found. |
| 341 |
This option is useful to find hashed host names or addresses and may also be |
| 342 |
used in conjunction with the |
| 343 |
.Fl H |
| 344 |
option to print found keys in a hashed format. |
| 345 |
.It Fl f Ar filename |
| 346 |
Specifies the filename of the key file. |
| 347 |
.It Fl g |
| 348 |
Use generic DNS format when printing fingerprint resource records using the |
| 349 |
.Fl r |
| 350 |
command. |
| 351 |
.It Fl H |
| 352 |
Hash a |
| 353 |
.Pa known_hosts |
| 354 |
file. |
| 355 |
This replaces all hostnames and addresses with hashed representations |
| 356 |
within the specified file; the original content is moved to a file with |
| 357 |
a .old suffix. |
| 358 |
These hashes may be used normally by |
| 359 |
.Nm ssh |
| 360 |
and |
| 361 |
.Nm sshd , |
| 362 |
but they do not reveal identifying information should the file's contents |
| 363 |
be disclosed. |
| 364 |
This option will not modify existing hashed hostnames and is therefore safe |
| 365 |
to use on files that mix hashed and non-hashed names. |
| 366 |
.It Fl h |
| 367 |
When signing a key, create a host certificate instead of a user |
| 368 |
certificate. |
| 369 |
See the |
| 370 |
.Sx CERTIFICATES |
| 371 |
section for details. |
| 372 |
.It Fl I Ar certificate_identity |
| 373 |
Specify the key identity when signing a public key. |
| 374 |
See the |
| 375 |
.Sx CERTIFICATES |
| 376 |
section for details. |
| 377 |
.It Fl i |
| 378 |
This option will read an unencrypted private (or public) key file |
| 379 |
in the format specified by the |
| 380 |
.Fl m |
| 381 |
option and print an OpenSSH compatible private |
| 382 |
(or public) key to stdout. |
| 383 |
This option allows importing keys from other software, including several |
| 384 |
commercial SSH implementations. |
| 385 |
The default import format is |
| 386 |
.Dq RFC4716 . |
| 387 |
.It Fl K |
| 388 |
Download resident keys from a FIDO authenticator. |
| 389 |
Public and private key files will be written to the current directory for |
| 390 |
each downloaded key. |
| 391 |
If multiple FIDO authenticators are attached, keys will be downloaded from |
| 392 |
the first touched authenticator. |
| 393 |
See the |
| 394 |
.Sx FIDO AUTHENTICATOR |
| 395 |
section for more information. |
| 396 |
.It Fl k |
| 397 |
Generate a KRL file. |
| 398 |
In this mode, |
| 399 |
.Nm |
| 400 |
will generate a KRL file at the location specified via the |
| 401 |
.Fl f |
| 402 |
flag that revokes every key or certificate presented on the command line. |
| 403 |
Keys/certificates to be revoked may be specified by public key file or |
| 404 |
using the format described in the |
| 405 |
.Sx KEY REVOCATION LISTS |
| 406 |
section. |
| 407 |
.It Fl L |
| 408 |
Prints the contents of one or more certificates. |
| 409 |
.It Fl l |
| 410 |
Show fingerprint of specified public key file. |
| 411 |
.Nm |
| 412 |
will try to find the matching public key file and prints its fingerprint. |
| 413 |
If combined with |
| 414 |
.Fl v , |
| 415 |
a visual ASCII art representation of the key is supplied with the |
| 416 |
fingerprint. |
| 417 |
.It Fl M Cm generate |
| 418 |
Generate candidate Diffie-Hellman Group Exchange (DH-GEX) parameters for |
| 419 |
eventual use by the |
| 420 |
.Sq diffie-hellman-group-exchange-* |
| 421 |
key exchange methods. |
| 422 |
The numbers generated by this operation must be further screened before |
| 423 |
use. |
| 424 |
See the |
| 425 |
.Sx MODULI GENERATION |
| 426 |
section for more information. |
| 427 |
.It Fl M Cm screen |
| 428 |
Screen candidate parameters for Diffie-Hellman Group Exchange. |
| 429 |
This will accept a list of candidate numbers and test that they are |
| 430 |
safe (Sophie Germain) primes with acceptable group generators. |
| 431 |
The results of this operation may be added to the |
| 432 |
.Pa /etc/ssh/moduli |
| 433 |
file. |
| 434 |
See the |
| 435 |
.Sx MODULI GENERATION |
| 436 |
section for more information. |
| 437 |
.It Fl m Ar key_format |
| 438 |
Specify a key format for key generation, the |
| 439 |
.Fl i |
| 440 |
(import), |
| 441 |
.Fl e |
| 442 |
(export) conversion options, and the |
| 443 |
.Fl p |
| 444 |
change passphrase operation. |
| 445 |
The latter may be used to convert between OpenSSH private key and PEM |
| 446 |
private key formats. |
| 447 |
The supported key formats are: |
| 448 |
.Dq RFC4716 |
| 449 |
(RFC 4716/SSH2 public or private key), |
| 450 |
.Dq PKCS8 |
| 451 |
(PKCS8 public or private key) |
| 452 |
or |
| 453 |
.Dq PEM |
| 454 |
(PEM public key). |
| 455 |
By default OpenSSH will write newly-generated private keys in its own |
| 456 |
format, but when converting public keys for export the default format is |
| 457 |
.Dq RFC4716 . |
| 458 |
Setting a format of |
| 459 |
.Dq PEM |
| 460 |
when generating or updating a supported private key type will cause the |
| 461 |
key to be stored in the legacy PEM private key format. |
| 462 |
.It Fl N Ar new_passphrase |
| 463 |
Provides the new passphrase. |
| 464 |
.It Fl n Ar principals |
| 465 |
Specify one or more principals (user or host names) to be included in |
| 466 |
a certificate when signing a key. |
| 467 |
Multiple principals may be specified, separated by commas. |
| 468 |
See the |
| 469 |
.Sx CERTIFICATES |
| 470 |
section for details. |
| 471 |
.It Fl O Ar option |
| 472 |
Specify a key/value option. |
| 473 |
These are specific to the operation that |
| 474 |
.Nm |
| 475 |
has been requested to perform. |
| 476 |
.Pp |
| 477 |
When signing certificates, one of the options listed in the |
| 478 |
.Sx CERTIFICATES |
| 479 |
section may be specified here. |
| 480 |
.Pp |
| 481 |
When performing moduli generation or screening, one of the options |
| 482 |
listed in the |
| 483 |
.Sx MODULI GENERATION |
| 484 |
section may be specified. |
| 485 |
.Pp |
| 486 |
When generating FIDO authenticator-backed keys, the options listed in the |
| 487 |
.Sx FIDO AUTHENTICATOR |
| 488 |
section may be specified. |
| 489 |
.Pp |
| 490 |
When performing signature-related options using the |
| 491 |
.Fl Y |
| 492 |
flag, the following options are accepted: |
| 493 |
.Bl -tag -width Ds |
| 494 |
.It Cm hashalg Ns = Ns Ar algorithm |
| 495 |
Selects the hash algorithm to use for hashing the message to be signed. |
| 496 |
Valid algorithms are |
| 497 |
.Dq sha256 |
| 498 |
and |
| 499 |
.Dq sha512. |
| 500 |
The default is |
| 501 |
.Dq sha512. |
| 502 |
.It Cm print-pubkey |
| 503 |
Print the full public key to standard output after signature verification. |
| 504 |
.It Cm verify-time Ns = Ns Ar timestamp |
| 505 |
Specifies a time to use when validating signatures instead of the current |
| 506 |
time. |
| 507 |
The time may be specified as a date or time in the YYYYMMDD[Z] or |
| 508 |
in YYYYMMDDHHMM[SS][Z] formats. |
| 509 |
Dates and times will be interpreted in the current system time zone unless |
| 510 |
suffixed with a Z character, which causes them to be interpreted in the |
| 511 |
UTC time zone. |
| 512 |
.El |
| 513 |
.Pp |
| 514 |
When generating SSHFP DNS records from public keys using the |
| 515 |
.Fl r |
| 516 |
flag, the following options are accepted: |
| 517 |
.Bl -tag -width Ds |
| 518 |
.It Cm hashalg Ns = Ns Ar algorithm |
| 519 |
Selects a hash algorithm to use when printing SSHFP records using the |
| 520 |
.Fl D |
| 521 |
flag. |
| 522 |
Valid algorithms are |
| 523 |
.Dq sha1 |
| 524 |
and |
| 525 |
.Dq sha256 . |
| 526 |
The default is to print both. |
| 527 |
.El |
| 528 |
.Pp |
| 529 |
The |
| 530 |
.Fl O |
| 531 |
option may be specified multiple times. |
| 532 |
.It Fl P Ar passphrase |
| 533 |
Provides the (old) passphrase. |
| 534 |
.It Fl p |
| 535 |
Requests changing the passphrase of a private key file instead of |
| 536 |
creating a new private key. |
| 537 |
The program will prompt for the file |
| 538 |
containing the private key, for the old passphrase, and twice for the |
| 539 |
new passphrase. |
| 540 |
.It Fl Q |
| 541 |
Test whether keys have been revoked in a KRL. |
| 542 |
If the |
| 543 |
.Fl l |
| 544 |
option is also specified then the contents of the KRL will be printed. |
| 545 |
.It Fl q |
| 546 |
Silence |
| 547 |
.Nm ssh-keygen . |
| 548 |
.It Fl R Ar hostname | [hostname]:port |
| 549 |
Removes all keys belonging to the specified |
| 550 |
.Ar hostname |
| 551 |
(with optional port number) |
| 552 |
from a |
| 553 |
.Pa known_hosts |
| 554 |
file. |
| 555 |
This option is useful to delete hashed hosts (see the |
| 556 |
.Fl H |
| 557 |
option above). |
| 558 |
.It Fl r Ar hostname |
| 559 |
Print the SSHFP fingerprint resource record named |
| 560 |
.Ar hostname |
| 561 |
for the specified public key file. |
| 562 |
.It Fl s Ar ca_key |
| 563 |
Certify (sign) a public key using the specified CA key. |
| 564 |
See the |
| 565 |
.Sx CERTIFICATES |
| 566 |
section for details. |
| 567 |
.Pp |
| 568 |
When generating a KRL, |
| 569 |
.Fl s |
| 570 |
specifies a path to a CA public key file used to revoke certificates directly |
| 571 |
by key ID or serial number. |
| 572 |
See the |
| 573 |
.Sx KEY REVOCATION LISTS |
| 574 |
section for details. |
| 575 |
.It Fl t Cm ecdsa | ecdsa-sk | ed25519 | ed25519-sk | rsa |
| 576 |
Specifies the type of key to create. |
| 577 |
The possible values are |
| 578 |
.Dq ecdsa , |
| 579 |
.Dq ecdsa-sk , |
| 580 |
.Dq ed25519 (the default), |
| 581 |
.Dq ed25519-sk , |
| 582 |
or |
| 583 |
.Dq rsa . |
| 584 |
.Pp |
| 585 |
This flag may also be used to specify the desired signature type when |
| 586 |
signing certificates using an RSA CA key. |
| 587 |
The available RSA signature variants are |
| 588 |
.Dq ssh-rsa |
| 589 |
(SHA1 signatures, not recommended), |
| 590 |
.Dq rsa-sha2-256 , |
| 591 |
and |
| 592 |
.Dq rsa-sha2-512 |
| 593 |
(the default for RSA keys). |
| 594 |
.It Fl U |
| 595 |
When used in combination with |
| 596 |
.Fl s |
| 597 |
or |
| 598 |
.Fl Y Cm sign , |
| 599 |
this option indicates that a CA key resides in an |
| 600 |
.Xr ssh-agent 1 . |
| 601 |
See the |
| 602 |
.Sx CERTIFICATES |
| 603 |
section for more information. |
| 604 |
.It Fl u |
| 605 |
Update a KRL. |
| 606 |
When specified with |
| 607 |
.Fl k , |
| 608 |
keys listed via the command line are added to the existing KRL rather than |
| 609 |
a new KRL being created. |
| 610 |
.It Fl V Ar validity_interval |
| 611 |
Specify a validity interval when signing a certificate. |
| 612 |
A validity interval may consist of a single time, indicating that the |
| 613 |
certificate is valid beginning now and expiring at that time, or may consist |
| 614 |
of two times separated by a colon to indicate an explicit time interval. |
| 615 |
.Pp |
| 616 |
The start time may be specified as: |
| 617 |
.Bl -bullet -compact |
| 618 |
.It |
| 619 |
The string |
| 620 |
.Dq always |
| 621 |
to indicate the certificate has no specified start time. |
| 622 |
.It |
| 623 |
A date or time in the system time zone formatted as YYYYMMDD or |
| 624 |
YYYYMMDDHHMM[SS]. |
| 625 |
.It |
| 626 |
A date or time in the UTC time zone as YYYYMMDDZ or YYYYMMDDHHMM[SS]Z. |
| 627 |
.It |
| 628 |
A relative time before the current system time consisting of a minus sign |
| 629 |
followed by an interval in the format described in the |
| 630 |
TIME FORMATS section of |
| 631 |
.Xr sshd_config 5 . |
| 632 |
.It |
| 633 |
A raw seconds since epoch (Jan 1 1970 00:00:00 UTC) as a hexadecimal |
| 634 |
number beginning with |
| 635 |
.Dq 0x . |
| 636 |
.El |
| 637 |
.Pp |
| 638 |
The end time may be specified similarly to the start time: |
| 639 |
.Bl -bullet -compact |
| 640 |
.It |
| 641 |
The string |
| 642 |
.Dq forever |
| 643 |
to indicate the certificate has no specified end time. |
| 644 |
.It |
| 645 |
A date or time in the system time zone formatted as YYYYMMDD or |
| 646 |
YYYYMMDDHHMM[SS]. |
| 647 |
.It |
| 648 |
A date or time in the UTC time zone as YYYYMMDDZ or YYYYMMDDHHMM[SS]Z. |
| 649 |
.It |
| 650 |
A relative time after the current system time consisting of a plus sign |
| 651 |
followed by an interval in the format described in the |
| 652 |
TIME FORMATS section of |
| 653 |
.Xr sshd_config 5 . |
| 654 |
.It |
| 655 |
A raw seconds since epoch (Jan 1 1970 00:00:00 UTC) as a hexadecimal |
| 656 |
number beginning with |
| 657 |
.Dq 0x . |
| 658 |
.El |
| 659 |
.Pp |
| 660 |
For example: |
| 661 |
.Bl -tag -width Ds |
| 662 |
.It +52w1d |
| 663 |
Valid from now to 52 weeks and one day from now. |
| 664 |
.It -4w:+4w |
| 665 |
Valid from four weeks ago to four weeks from now. |
| 666 |
.It 20100101123000:20110101123000 |
| 667 |
Valid from 12:30 PM, January 1st, 2010 to 12:30 PM, January 1st, 2011. |
| 668 |
.It 20100101123000Z:20110101123000Z |
| 669 |
Similar, but interpreted in the UTC time zone rather than the system time zone. |
| 670 |
.It -1d:20110101 |
| 671 |
Valid from yesterday to midnight, January 1st, 2011. |
| 672 |
.It 0x1:0x2000000000 |
| 673 |
Valid from roughly early 1970 to May 2033. |
| 674 |
.It -1m:forever |
| 675 |
Valid from one minute ago and never expiring. |
| 676 |
.El |
| 677 |
.It Fl v |
| 678 |
Verbose mode. |
| 679 |
Causes |
| 680 |
.Nm |
| 681 |
to print debugging messages about its progress. |
| 682 |
This is helpful for debugging moduli generation. |
| 683 |
Multiple |
| 684 |
.Fl v |
| 685 |
options increase the verbosity. |
| 686 |
The maximum is 3. |
| 687 |
.It Fl w Ar provider |
| 688 |
Specifies a path to a library that will be used when creating |
| 689 |
FIDO authenticator-hosted keys, overriding the default of using |
| 690 |
the internal USB HID support. |
| 691 |
.It Fl Y Cm find-principals |
| 692 |
Find the principal(s) associated with the public key of a signature, |
| 693 |
provided using the |
| 694 |
.Fl s |
| 695 |
flag in an authorized signers file provided using the |
| 696 |
.Fl f |
| 697 |
flag. |
| 698 |
The format of the allowed signers file is documented in the |
| 699 |
.Sx ALLOWED SIGNERS |
| 700 |
section below. |
| 701 |
If one or more matching principals are found, they are returned on |
| 702 |
standard output. |
| 703 |
.It Fl Y Cm match-principals |
| 704 |
Find principal matching the principal name provided using the |
| 705 |
.Fl I |
| 706 |
flag in the authorized signers file specified using the |
| 707 |
.Fl f |
| 708 |
flag. |
| 709 |
If one or more matching principals are found, they are returned on |
| 710 |
standard output. |
| 711 |
.It Fl Y Cm check-novalidate |
| 712 |
Checks that a signature generated using |
| 713 |
.Nm |
| 714 |
.Fl Y Cm sign |
| 715 |
has a valid structure. |
| 716 |
This does not validate if a signature comes from an authorized signer. |
| 717 |
When testing a signature, |
| 718 |
.Nm |
| 719 |
accepts a message on standard input and a signature namespace using |
| 720 |
.Fl n . |
| 721 |
A file containing the corresponding signature must also be supplied using the |
| 722 |
.Fl s |
| 723 |
flag. |
| 724 |
Successful testing of the signature is signalled by |
| 725 |
.Nm |
| 726 |
returning a zero exit status. |
| 727 |
.It Fl Y Cm sign |
| 728 |
Cryptographically sign a file or some data using an SSH key. |
| 729 |
When signing, |
| 730 |
.Nm |
| 731 |
accepts zero or more files to sign on the command-line - if no files |
| 732 |
are specified then |
| 733 |
.Nm |
| 734 |
will sign data presented on standard input. |
| 735 |
Signatures are written to the path of the input file with |
| 736 |
.Dq .sig |
| 737 |
appended, or to standard output if the message to be signed was read from |
| 738 |
standard input. |
| 739 |
.Pp |
| 740 |
The key used for signing is specified using the |
| 741 |
.Fl f |
| 742 |
option and may refer to either a private key, or a public key with the private |
| 743 |
half available via |
| 744 |
.Xr ssh-agent 1 . |
| 745 |
An additional signature namespace, used to prevent signature confusion across |
| 746 |
different domains of use (e.g. file signing vs email signing) must be provided |
| 747 |
via the |
| 748 |
.Fl n |
| 749 |
flag. |
| 750 |
Namespaces are arbitrary strings, and may include: |
| 751 |
.Dq file |
| 752 |
for file signing, |
| 753 |
.Dq email |
| 754 |
for email signing. |
| 755 |
For custom uses, it is recommended to use names following a |
| 756 |
[email protected] pattern to generate unambiguous namespaces. |
| 757 |
.It Fl Y Cm verify |
| 758 |
Request to verify a signature generated using |
| 759 |
.Nm |
| 760 |
.Fl Y Cm sign |
| 761 |
as described above. |
| 762 |
When verifying a signature, |
| 763 |
.Nm |
| 764 |
accepts a message on standard input and a signature namespace using |
| 765 |
.Fl n . |
| 766 |
A file containing the corresponding signature must also be supplied using the |
| 767 |
.Fl s |
| 768 |
flag, along with the identity of the signer using |
| 769 |
.Fl I |
| 770 |
and a list of allowed signers via the |
| 771 |
.Fl f |
| 772 |
flag. |
| 773 |
The format of the allowed signers file is documented in the |
| 774 |
.Sx ALLOWED SIGNERS |
| 775 |
section below. |
| 776 |
A file containing revoked keys can be passed using the |
| 777 |
.Fl r |
| 778 |
flag. |
| 779 |
The revocation file may be a KRL or a one-per-line list of public keys. |
| 780 |
Successful verification by an authorized signer is signalled by |
| 781 |
.Nm |
| 782 |
returning a zero exit status. |
| 783 |
.It Fl y |
| 784 |
This option will read a private |
| 785 |
OpenSSH format file and print an OpenSSH public key to stdout. |
| 786 |
.It Fl Z Ar cipher |
| 787 |
Specifies the cipher to use for encryption when writing an OpenSSH-format |
| 788 |
private key file. |
| 789 |
The list of available ciphers may be obtained using |
| 790 |
.Qq ssh -Q cipher . |
| 791 |
The default is |
| 792 |
.Dq aes256-ctr . |
| 793 |
.It Fl z Ar serial_number |
| 794 |
Specifies a serial number to be embedded in the certificate to distinguish |
| 795 |
this certificate from others from the same CA. |
| 796 |
If the |
| 797 |
.Ar serial_number |
| 798 |
is prefixed with a |
| 799 |
.Sq + |
| 800 |
character, then the serial number will be incremented for each certificate |
| 801 |
signed on a single command-line. |
| 802 |
The default serial number is zero. |
| 803 |
.Pp |
| 804 |
When generating a KRL, the |
| 805 |
.Fl z |
| 806 |
flag is used to specify a KRL version number. |
| 807 |
.El |
| 808 |
.Sh MODULI GENERATION |
| 809 |
.Nm |
| 810 |
may be used to generate groups for the Diffie-Hellman Group Exchange |
| 811 |
(DH-GEX) protocol. |
| 812 |
Generating these groups is a two-step process: first, candidate |
| 813 |
primes are generated using a fast, but memory intensive process. |
| 814 |
These candidate primes are then tested for suitability (a CPU-intensive |
| 815 |
process). |
| 816 |
.Pp |
| 817 |
Generation of primes is performed using the |
| 818 |
.Fl M Cm generate |
| 819 |
option. |
| 820 |
The desired length of the primes may be specified by the |
| 821 |
.Fl O Cm bits |
| 822 |
option. |
| 823 |
For example: |
| 824 |
.Pp |
| 825 |
.Dl # ssh-keygen -M generate -O bits=2048 moduli-2048.candidates |
| 826 |
.Pp |
| 827 |
By default, the search for primes begins at a random point in the |
| 828 |
desired length range. |
| 829 |
This may be overridden using the |
| 830 |
.Fl O Cm start |
| 831 |
option, which specifies a different start point (in hex). |
| 832 |
.Pp |
| 833 |
Once a set of candidates have been generated, they must be screened for |
| 834 |
suitability. |
| 835 |
This may be performed using the |
| 836 |
.Fl M Cm screen |
| 837 |
option. |
| 838 |
In this mode |
| 839 |
.Nm |
| 840 |
will read candidates from standard input (or a file specified using the |
| 841 |
.Fl f |
| 842 |
option). |
| 843 |
For example: |
| 844 |
.Pp |
| 845 |
.Dl # ssh-keygen -M screen -f moduli-2048.candidates moduli-2048 |
| 846 |
.Pp |
| 847 |
By default, each candidate will be subjected to 100 primality tests. |
| 848 |
This may be overridden using the |
| 849 |
.Fl O Cm prime-tests |
| 850 |
option. |
| 851 |
The DH generator value will be chosen automatically for the |
| 852 |
prime under consideration. |
| 853 |
If a specific generator is desired, it may be requested using the |
| 854 |
.Fl O Cm generator |
| 855 |
option. |
| 856 |
Valid generator values are 2, 3, and 5. |
| 857 |
.Pp |
| 858 |
Screened DH groups may be installed in |
| 859 |
.Pa /etc/ssh/moduli . |
| 860 |
It is important that this file contains moduli of a range of bit lengths. |
| 861 |
.Pp |
| 862 |
A number of options are available for moduli generation and screening via the |
| 863 |
.Fl O |
| 864 |
flag: |
| 865 |
.Bl -tag -width Ds |
| 866 |
.It Ic lines Ns = Ns Ar number |
| 867 |
Exit after screening the specified number of lines while performing DH |
| 868 |
candidate screening. |
| 869 |
.It Ic start-line Ns = Ns Ar line-number |
| 870 |
Start screening at the specified line number while performing DH candidate |
| 871 |
screening. |
| 872 |
.It Ic checkpoint Ns = Ns Ar filename |
| 873 |
Write the last line processed to the specified file while performing DH |
| 874 |
candidate screening. |
| 875 |
This will be used to skip lines in the input file that have already been |
| 876 |
processed if the job is restarted. |
| 877 |
.It Ic start Ns = Ns Ar hex-value |
| 878 |
Specify start point (in hex) when generating candidate moduli for DH-GEX. |
| 879 |
.It Ic generator Ns = Ns Ar value |
| 880 |
Specify desired generator (in decimal) when testing candidate moduli for DH-GEX. |
| 881 |
.El |
| 882 |
.Sh CERTIFICATES |
| 883 |
.Nm |
| 884 |
supports signing of keys to produce certificates that may be used for |
| 885 |
user or host authentication. |
| 886 |
Certificates consist of a public key, some identity information, zero or |
| 887 |
more principal (user or host) names and a set of options that |
| 888 |
are signed by a Certification Authority (CA) key. |
| 889 |
Clients or servers may then trust only the CA key and verify its signature |
| 890 |
on a certificate rather than trusting many user/host keys. |
| 891 |
Note that OpenSSH certificates are a different, and much simpler, format to |
| 892 |
the X.509 certificates used in |
| 893 |
.Xr ssl 8 . |
| 894 |
.Pp |
| 895 |
.Nm |
| 896 |
supports two types of certificates: user and host. |
| 897 |
User certificates authenticate users to servers, whereas host certificates |
| 898 |
authenticate server hosts to users. |
| 899 |
To generate a user certificate: |
| 900 |
.Pp |
| 901 |
.Dl $ ssh-keygen -s /path/to/ca_key -I id -n user \e |
| 902 |
.Dl \ \ \ \ \ \ /path/to/user_key.pub |
| 903 |
.Pp |
| 904 |
The resultant certificate will be placed in |
| 905 |
.Pa /path/to/user_key-cert.pub . |
| 906 |
The argument to |
| 907 |
.Fl I |
| 908 |
is a key identifier that will be used in logs and may be used to revoke |
| 909 |
keys. |
| 910 |
The argument to |
| 911 |
.Fl n |
| 912 |
is one or more (comma-separated) principals, typically usernames, that |
| 913 |
the certificate represents. |
| 914 |
A host certificate requires the |
| 915 |
.Fl h |
| 916 |
option: |
| 917 |
.Pp |
| 918 |
.Dl $ ssh-keygen -s /path/to/ca_key -I id -h -n foo.example.org \e |
| 919 |
.Dl \ \ \ \ \ \ /path/to/host_key.pub |
| 920 |
.Pp |
| 921 |
For host certificates, the principals specified using the |
| 922 |
.Fl n |
| 923 |
argument are hostnames and may contain wildcard characters. |
| 924 |
.Pp |
| 925 |
The host certificate will be output to |
| 926 |
.Pa /path/to/host_key-cert.pub . |
| 927 |
.Pp |
| 928 |
It is possible to sign using a CA key stored in a PKCS#11 token by |
| 929 |
providing the token library using |
| 930 |
.Fl D |
| 931 |
and identifying the CA key by providing its public half as an argument |
| 932 |
to |
| 933 |
.Fl s : |
| 934 |
.Pp |
| 935 |
.Dl $ ssh-keygen -s ca_key.pub -D libpkcs11.so -I id -n user \e |
| 936 |
.Dl \ \ \ \ \ \ user_key.pub |
| 937 |
.Pp |
| 938 |
Similarly, it is possible for the CA key to be hosted in an |
| 939 |
.Xr ssh-agent 1 . |
| 940 |
This is indicated by the |
| 941 |
.Fl U |
| 942 |
flag and, again, the CA key must be identified by its public half. |
| 943 |
.Pp |
| 944 |
.Dl $ ssh-keygen -Us ca_key.pub -I id -n user user_key.pub |
| 945 |
.Pp |
| 946 |
In all cases, |
| 947 |
.Ar key_id |
| 948 |
is a "key identifier" that is logged by the server when the certificate |
| 949 |
is used for authentication. |
| 950 |
.Pp |
| 951 |
Certificates are limited to be valid for a set of principal (user/host) |
| 952 |
names. |
| 953 |
To generate a certificate for a specified set of principals: |
| 954 |
.Pp |
| 955 |
.Dl $ ssh-keygen -s ca_key -I id -n user1,user2 user_key.pub |
| 956 |
.Dl $ ssh-keygen -s ca_key -I id -h -n host.domain host_key.pub |
| 957 |
.Pp |
| 958 |
Additional limitations on the validity and use of user certificates may |
| 959 |
be specified through certificate options. |
| 960 |
A certificate option may disable features of the SSH session, may be |
| 961 |
valid only when presented from particular source addresses or may |
| 962 |
force the use of a specific command. |
| 963 |
.Pp |
| 964 |
The options that are valid for user certificates are: |
| 965 |
.Pp |
| 966 |
.Bl -tag -width Ds -compact |
| 967 |
.It Ic clear |
| 968 |
Clear all enabled permissions. |
| 969 |
This is useful for clearing the default set of permissions so permissions may |
| 970 |
be added individually. |
| 971 |
.Pp |
| 972 |
.It Ic critical : Ns Ar name Ns Op Ns = Ns Ar contents |
| 973 |
.It Ic extension : Ns Ar name Ns Op Ns = Ns Ar contents |
| 974 |
Includes an arbitrary certificate critical option or extension. |
| 975 |
The specified |
| 976 |
.Ar name |
| 977 |
should include a domain suffix, e.g.\& |
| 978 |
.Dq [email protected] . |
| 979 |
If |
| 980 |
.Ar contents |
| 981 |
is specified then it is included as the contents of the extension/option |
| 982 |
encoded as a string, otherwise the extension/option is created with no |
| 983 |
contents (usually indicating a flag). |
| 984 |
Extensions may be ignored by a client or server that does not recognise them, |
| 985 |
whereas unknown critical options will cause the certificate to be refused. |
| 986 |
.Pp |
| 987 |
.It Ic force-command Ns = Ns Ar command |
| 988 |
Forces the execution of |
| 989 |
.Ar command |
| 990 |
instead of any shell or command specified by the user when |
| 991 |
the certificate is used for authentication. |
| 992 |
.Pp |
| 993 |
.It Ic no-agent-forwarding |
| 994 |
Disable |
| 995 |
.Xr ssh-agent 1 |
| 996 |
forwarding (permitted by default). |
| 997 |
.Pp |
| 998 |
.It Ic no-port-forwarding |
| 999 |
Disable port forwarding (permitted by default). |
| 1000 |
.Pp |
| 1001 |
.It Ic no-pty |
| 1002 |
Disable PTY allocation (permitted by default). |
| 1003 |
.Pp |
| 1004 |
.It Ic no-user-rc |
| 1005 |
Disable execution of |
| 1006 |
.Pa ~/.ssh/rc |
| 1007 |
by |
| 1008 |
.Xr sshd 8 |
| 1009 |
(permitted by default). |
| 1010 |
.Pp |
| 1011 |
.It Ic no-x11-forwarding |
| 1012 |
Disable X11 forwarding (permitted by default). |
| 1013 |
.Pp |
| 1014 |
.It Ic permit-agent-forwarding |
| 1015 |
Allows |
| 1016 |
.Xr ssh-agent 1 |
| 1017 |
forwarding. |
| 1018 |
.Pp |
| 1019 |
.It Ic permit-port-forwarding |
| 1020 |
Allows port forwarding. |
| 1021 |
.Pp |
| 1022 |
.It Ic permit-pty |
| 1023 |
Allows PTY allocation. |
| 1024 |
.Pp |
| 1025 |
.It Ic permit-user-rc |
| 1026 |
Allows execution of |
| 1027 |
.Pa ~/.ssh/rc |
| 1028 |
by |
| 1029 |
.Xr sshd 8 . |
| 1030 |
.Pp |
| 1031 |
.It Ic permit-X11-forwarding |
| 1032 |
Allows X11 forwarding. |
| 1033 |
.Pp |
| 1034 |
.It Ic no-touch-required |
| 1035 |
Do not require signatures made using this key include demonstration |
| 1036 |
of user presence (e.g. by having the user touch the authenticator). |
| 1037 |
This option only makes sense for the FIDO authenticator algorithms |
| 1038 |
.Cm ecdsa-sk |
| 1039 |
and |
| 1040 |
.Cm ed25519-sk . |
| 1041 |
.Pp |
| 1042 |
.It Ic source-address Ns = Ns Ar address_list |
| 1043 |
Restrict the source addresses from which the certificate is considered valid. |
| 1044 |
The |
| 1045 |
.Ar address_list |
| 1046 |
is a comma-separated list of one or more address/netmask pairs in CIDR |
| 1047 |
format. |
| 1048 |
.Pp |
| 1049 |
.It Ic verify-required |
| 1050 |
Require signatures made using this key indicate that the user was first |
| 1051 |
verified, e.g. by PIN or on-token biometrics. |
| 1052 |
This option only makes sense for the FIDO authenticator algorithms |
| 1053 |
.Cm ecdsa-sk |
| 1054 |
and |
| 1055 |
.Cm ed25519-sk . |
| 1056 |
.El |
| 1057 |
.Pp |
| 1058 |
At present, no standard options are valid for host keys. |
| 1059 |
.Pp |
| 1060 |
Finally, certificates may be defined with a validity lifetime. |
| 1061 |
The |
| 1062 |
.Fl V |
| 1063 |
option allows specification of certificate start and end times. |
| 1064 |
A certificate that is presented at a time outside this range will not be |
| 1065 |
considered valid. |
| 1066 |
By default, certificates are valid from the |
| 1067 |
.Ux |
| 1068 |
Epoch to the distant future. |
| 1069 |
.Pp |
| 1070 |
For certificates to be used for user or host authentication, the CA |
| 1071 |
public key must be trusted by |
| 1072 |
.Xr sshd 8 |
| 1073 |
or |
| 1074 |
.Xr ssh 1 . |
| 1075 |
Refer to those manual pages for details. |
| 1076 |
.Sh FIDO AUTHENTICATOR |
| 1077 |
.Nm |
| 1078 |
is able to generate FIDO authenticator-backed keys, after which |
| 1079 |
they may be used much like any other key type supported by OpenSSH, so |
| 1080 |
long as the hardware authenticator is attached when the keys are used. |
| 1081 |
FIDO authenticators generally require the user to explicitly authorise |
| 1082 |
operations by touching or tapping them. |
| 1083 |
FIDO keys consist of two parts: a key handle part stored in the |
| 1084 |
private key file on disk, and a per-device private key that is unique |
| 1085 |
to each FIDO authenticator and that cannot be exported from the |
| 1086 |
authenticator hardware. |
| 1087 |
These are combined by the hardware at authentication time to derive |
| 1088 |
the real key that is used to sign authentication challenges. |
| 1089 |
Supported key types are |
| 1090 |
.Cm ecdsa-sk |
| 1091 |
and |
| 1092 |
.Cm ed25519-sk . |
| 1093 |
.Pp |
| 1094 |
The options that are valid for FIDO keys are: |
| 1095 |
.Bl -tag -width Ds |
| 1096 |
.It Cm application |
| 1097 |
Override the default FIDO application/origin string of |
| 1098 |
.Dq ssh: . |
| 1099 |
This may be useful when generating host or domain-specific resident keys. |
| 1100 |
The specified application string must begin with |
| 1101 |
.Dq ssh: . |
| 1102 |
.It Cm challenge Ns = Ns Ar path |
| 1103 |
Specifies a path to a challenge string that will be passed to the |
| 1104 |
FIDO authenticator during key generation. |
| 1105 |
The challenge string may be used as part of an out-of-band |
| 1106 |
protocol for key enrollment |
| 1107 |
(a random challenge is used by default). |
| 1108 |
.It Cm device |
| 1109 |
Explicitly specify a |
| 1110 |
.Xr fido 4 |
| 1111 |
device to use, rather than letting the authenticator middleware select one. |
| 1112 |
.It Cm no-touch-required |
| 1113 |
Indicate that the generated private key should not require touch |
| 1114 |
events (user presence) when making signatures. |
| 1115 |
Note that |
| 1116 |
.Xr sshd 8 |
| 1117 |
will refuse such signatures by default, unless overridden via |
| 1118 |
an authorized_keys option. |
| 1119 |
.It Cm resident |
| 1120 |
Indicate that the key handle should be stored on the FIDO |
| 1121 |
authenticator itself. |
| 1122 |
This makes it easier to use the authenticator on multiple computers. |
| 1123 |
Resident keys may be supported on FIDO2 authenticators and typically |
| 1124 |
require that a PIN be set on the authenticator prior to generation. |
| 1125 |
Resident keys may be loaded off the authenticator using |
| 1126 |
.Xr ssh-add 1 . |
| 1127 |
Storing both parts of a key on a FIDO authenticator increases the likelihood |
| 1128 |
of an attacker being able to use a stolen authenticator device. |
| 1129 |
.It Cm user |
| 1130 |
A username to be associated with a resident key, |
| 1131 |
overriding the empty default username. |
| 1132 |
Specifying a username may be useful when generating multiple resident keys |
| 1133 |
for the same application name. |
| 1134 |
.It Cm verify-required |
| 1135 |
Indicate that this private key should require user verification for |
| 1136 |
each signature. |
| 1137 |
Not all FIDO authenticators support this option. |
| 1138 |
Currently PIN authentication is the only supported verification method, |
| 1139 |
but other methods may be supported in the future. |
| 1140 |
.It Cm write-attestation Ns = Ns Ar path |
| 1141 |
May be used at key generation time to record the attestation data |
| 1142 |
returned from FIDO authenticators during key generation. |
| 1143 |
This information is potentially sensitive. |
| 1144 |
By default, this information is discarded. |
| 1145 |
.El |
| 1146 |
.Sh KEY REVOCATION LISTS |
| 1147 |
.Nm |
| 1148 |
is able to manage OpenSSH format Key Revocation Lists (KRLs). |
| 1149 |
These binary files specify keys or certificates to be revoked using a |
| 1150 |
compact format, taking as little as one bit per certificate if they are being |
| 1151 |
revoked by serial number. |
| 1152 |
.Pp |
| 1153 |
KRLs may be generated using the |
| 1154 |
.Fl k |
| 1155 |
flag. |
| 1156 |
This option reads one or more files from the command line and generates a new |
| 1157 |
KRL. |
| 1158 |
The files may either contain a KRL specification (see below) or public keys, |
| 1159 |
listed one per line. |
| 1160 |
Plain public keys are revoked by listing their hash or contents in the KRL and |
| 1161 |
certificates revoked by serial number or key ID (if the serial is zero or |
| 1162 |
not available). |
| 1163 |
.Pp |
| 1164 |
Revoking keys using a KRL specification offers explicit control over the |
| 1165 |
types of record used to revoke keys and may be used to directly revoke |
| 1166 |
certificates by serial number or key ID without having the complete original |
| 1167 |
certificate on hand. |
| 1168 |
A KRL specification consists of lines containing one of the following directives |
| 1169 |
followed by a colon and some directive-specific information. |
| 1170 |
.Bl -tag -width Ds |
| 1171 |
.It Cm serial : Ar serial_number Ns Op - Ns Ar serial_number |
| 1172 |
Revokes a certificate with the specified serial number. |
| 1173 |
Serial numbers are 64-bit values, not including zero and may be expressed |
| 1174 |
in decimal, hex or octal. |
| 1175 |
If two serial numbers are specified separated by a hyphen, then the range |
| 1176 |
of serial numbers including and between each is revoked. |
| 1177 |
The CA key must have been specified on the |
| 1178 |
.Nm |
| 1179 |
command line using the |
| 1180 |
.Fl s |
| 1181 |
option. |
| 1182 |
.It Cm id : Ar key_id |
| 1183 |
Revokes a certificate with the specified key ID string. |
| 1184 |
The CA key must have been specified on the |
| 1185 |
.Nm |
| 1186 |
command line using the |
| 1187 |
.Fl s |
| 1188 |
option. |
| 1189 |
.It Cm key : Ar public_key |
| 1190 |
Revokes the specified key. |
| 1191 |
If a certificate is listed, then it is revoked as a plain public key. |
| 1192 |
.It Cm sha1 : Ar public_key |
| 1193 |
Revokes the specified key by including its SHA1 hash in the KRL. |
| 1194 |
.It Cm sha256 : Ar public_key |
| 1195 |
Revokes the specified key by including its SHA256 hash in the KRL. |
| 1196 |
KRLs that revoke keys by SHA256 hash are not supported by OpenSSH versions |
| 1197 |
prior to 7.9. |
| 1198 |
.It Cm hash : Ar fingerprint |
| 1199 |
Revokes a key using a fingerprint hash, as obtained from an |
| 1200 |
.Xr sshd 8 |
| 1201 |
authentication log message or the |
| 1202 |
.Nm |
| 1203 |
.Fl l |
| 1204 |
flag. |
| 1205 |
Only SHA256 fingerprints are supported here and resultant KRLs are |
| 1206 |
not supported by OpenSSH versions prior to 7.9. |
| 1207 |
.El |
| 1208 |
.Pp |
| 1209 |
KRLs may be updated using the |
| 1210 |
.Fl u |
| 1211 |
flag in addition to |
| 1212 |
.Fl k . |
| 1213 |
When this option is specified, keys listed via the command line are merged into |
| 1214 |
the KRL, adding to those already there. |
| 1215 |
.Pp |
| 1216 |
It is also possible, given a KRL, to test whether it revokes a particular key |
| 1217 |
(or keys). |
| 1218 |
The |
| 1219 |
.Fl Q |
| 1220 |
flag will query an existing KRL, testing each key specified on the command line. |
| 1221 |
If any key listed on the command line has been revoked (or an error encountered) |
| 1222 |
then |
| 1223 |
.Nm |
| 1224 |
will exit with a non-zero exit status. |
| 1225 |
A zero exit status will only be returned if no key was revoked. |
| 1226 |
.Sh ALLOWED SIGNERS |
| 1227 |
When verifying signatures, |
| 1228 |
.Nm |
| 1229 |
uses a simple list of identities and keys to determine whether a signature |
| 1230 |
comes from an authorized source. |
| 1231 |
This "allowed signers" file uses a format patterned after the |
| 1232 |
AUTHORIZED_KEYS FILE FORMAT described in |
| 1233 |
.Xr sshd 8 . |
| 1234 |
Each line of the file contains the following space-separated fields: |
| 1235 |
principals, options, keytype, base64-encoded key. |
| 1236 |
Empty lines and lines starting with a |
| 1237 |
.Ql # |
| 1238 |
are ignored as comments. |
| 1239 |
.Pp |
| 1240 |
The principals field is a pattern-list (see PATTERNS in |
| 1241 |
.Xr ssh_config 5 ) |
| 1242 |
consisting of one or more comma-separated USER@DOMAIN identity patterns |
| 1243 |
that are accepted for signing. |
| 1244 |
When verifying, the identity presented via the |
| 1245 |
.Fl I |
| 1246 |
option must match a principals pattern in order for the corresponding key to be |
| 1247 |
considered acceptable for verification. |
| 1248 |
.Pp |
| 1249 |
The options (if present) consist of comma-separated option specifications. |
| 1250 |
No spaces are permitted, except within double quotes. |
| 1251 |
The following option specifications are supported (note that option keywords |
| 1252 |
are case-insensitive): |
| 1253 |
.Bl -tag -width Ds |
| 1254 |
.It Cm cert-authority |
| 1255 |
Indicates that this key is accepted as a certificate authority (CA) and |
| 1256 |
that certificates signed by this CA may be accepted for verification. |
| 1257 |
.It Cm namespaces Ns = Ns "namespace-list" |
| 1258 |
Specifies a pattern-list of namespaces that are accepted for this key. |
| 1259 |
If this option is present, the signature namespace embedded in the |
| 1260 |
signature object and presented on the verification command-line must |
| 1261 |
match the specified list before the key will be considered acceptable. |
| 1262 |
.It Cm valid-after Ns = Ns "timestamp" |
| 1263 |
Indicates that the key is valid for use at or after the specified timestamp, |
| 1264 |
which may be a date or time in the YYYYMMDD[Z] or YYYYMMDDHHMM[SS][Z] formats. |
| 1265 |
Dates and times will be interpreted in the current system time zone unless |
| 1266 |
suffixed with a Z character, which causes them to be interpreted in the UTC |
| 1267 |
time zone. |
| 1268 |
.It Cm valid-before Ns = Ns "timestamp" |
| 1269 |
Indicates that the key is valid for use at or before the specified timestamp. |
| 1270 |
.El |
| 1271 |
.Pp |
| 1272 |
When verifying signatures made by certificates, the expected principal |
| 1273 |
name must match both the principals pattern in the allowed signers file and |
| 1274 |
the principals embedded in the certificate itself. |
| 1275 |
.Pp |
| 1276 |
An example allowed signers file: |
| 1277 |
.Bd -literal -offset 3n |
| 1278 |
# Comments allowed at start of line |
| 1279 |
[email protected],[email protected] ssh-rsa AAAAX1... |
| 1280 |
# A certificate authority, trusted for all principals in a domain. |
| 1281 |
*@example.com cert-authority ssh-ed25519 AAAB4... |
| 1282 |
# A key that is accepted only for file signing. |
| 1283 |
[email protected] namespaces="file" ssh-ed25519 AAA41... |
| 1284 |
.Ed |
| 1285 |
.Sh ENVIRONMENT |
| 1286 |
.Bl -tag -width Ds |
| 1287 |
.It Ev SSH_SK_PROVIDER |
| 1288 |
Specifies a path to a library that will be used when loading any |
| 1289 |
FIDO authenticator-hosted keys, overriding the default of using |
| 1290 |
the built-in USB HID support. |
| 1291 |
.El |
| 1292 |
.Sh FILES |
| 1293 |
.Bl -tag -width Ds -compact |
| 1294 |
.It Pa ~/.ssh/id_ecdsa |
| 1295 |
.It Pa ~/.ssh/id_ecdsa_sk |
| 1296 |
.It Pa ~/.ssh/id_ed25519 |
| 1297 |
.It Pa ~/.ssh/id_ed25519_sk |
| 1298 |
.It Pa ~/.ssh/id_rsa |
| 1299 |
Contains the ECDSA, authenticator-hosted ECDSA, Ed25519, |
| 1300 |
authenticator-hosted Ed25519 or RSA authentication identity of the user. |
| 1301 |
This file should not be readable by anyone but the user. |
| 1302 |
It is possible to |
| 1303 |
specify a passphrase when generating the key; that passphrase will be |
| 1304 |
used to encrypt the private part of this file using 128-bit AES. |
| 1305 |
This file is not automatically accessed by |
| 1306 |
.Nm |
| 1307 |
but it is offered as the default file for the private key. |
| 1308 |
.Xr ssh 1 |
| 1309 |
will read this file when a login attempt is made. |
| 1310 |
.Pp |
| 1311 |
.It Pa ~/.ssh/id_ecdsa.pub |
| 1312 |
.It Pa ~/.ssh/id_ecdsa_sk.pub |
| 1313 |
.It Pa ~/.ssh/id_ed25519.pub |
| 1314 |
.It Pa ~/.ssh/id_ed25519_sk.pub |
| 1315 |
.It Pa ~/.ssh/id_rsa.pub |
| 1316 |
Contains the ECDSA, authenticator-hosted ECDSA, Ed25519, |
| 1317 |
authenticator-hosted Ed25519 or RSA public key for authentication. |
| 1318 |
The contents of this file should be added to |
| 1319 |
.Pa ~/.ssh/authorized_keys |
| 1320 |
on all machines |
| 1321 |
where the user wishes to log in using public key authentication. |
| 1322 |
There is no need to keep the contents of this file secret. |
| 1323 |
.Pp |
| 1324 |
.It Pa /etc/ssh/moduli |
| 1325 |
Contains Diffie-Hellman groups used for DH-GEX. |
| 1326 |
The file format is described in |
| 1327 |
.Xr moduli 5 . |
| 1328 |
.El |
| 1329 |
.Sh SEE ALSO |
| 1330 |
.Xr ssh 1 , |
| 1331 |
.Xr ssh-add 1 , |
| 1332 |
.Xr ssh-agent 1 , |
| 1333 |
.Xr moduli 5 , |
| 1334 |
.Xr sshd 8 |
| 1335 |
.Rs |
| 1336 |
.%R RFC 4716 |
| 1337 |
.%T "The Secure Shell (SSH) Public Key File Format" |
| 1338 |
.%D 2006 |
| 1339 |
.Re |
| 1340 |
.Sh AUTHORS |
| 1341 |
OpenSSH is a derivative of the original and free |
| 1342 |
ssh 1.2.12 release by Tatu Ylonen. |
| 1343 |
Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos, |
| 1344 |
Theo de Raadt and Dug Song |
| 1345 |
removed many bugs, re-added newer features and |
| 1346 |
created OpenSSH. |
| 1347 |
Markus Friedl contributed the support for SSH |
| 1348 |
protocol versions 1.5 and 2.0. |