1.\" $OpenBSD: ssh-keygen.1,v 1.179 2019/11/30 07:07:59 jmc Exp $ 2.\" 3.\" Author: Tatu Ylonen <ylo@cs.hut.fi> 4.\" Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, 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: November 30 2019 $ 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 b Ar bits 48.Op Fl C Ar comment 49.Op Fl f Ar output_keyfile 50.Op Fl m Ar format 51.Op Fl t Cm dsa | ecdsa | ecdsa-sk | ed25519 | ed25519-sk | rsa 52.Op Fl N Ar new_passphrase 53.Op Fl w Ar provider 54.Op Fl x Ar flags 55.Nm ssh-keygen 56.Fl p 57.Op Fl f Ar keyfile 58.Op Fl m Ar format 59.Op Fl N Ar new_passphrase 60.Op Fl P Ar old_passphrase 61.Nm ssh-keygen 62.Fl i 63.Op Fl f Ar input_keyfile 64.Op Fl m Ar key_format 65.Nm ssh-keygen 66.Fl e 67.Op Fl f Ar input_keyfile 68.Op Fl m Ar key_format 69.Nm ssh-keygen 70.Fl y 71.Op Fl f Ar input_keyfile 72.Nm ssh-keygen 73.Fl c 74.Op Fl C Ar comment 75.Op Fl f Ar keyfile 76.Op Fl P Ar passphrase 77.Nm ssh-keygen 78.Fl l 79.Op Fl v 80.Op Fl E Ar fingerprint_hash 81.Op Fl f Ar input_keyfile 82.Nm ssh-keygen 83.Fl B 84.Op Fl f Ar input_keyfile 85.Nm ssh-keygen 86.Fl D Ar pkcs11 87.Nm ssh-keygen 88.Fl F Ar hostname 89.Op Fl lv 90.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 98.Fl r Ar hostname 99.Op Fl g 100.Op Fl f Ar input_keyfile 101.Nm ssh-keygen 102.Fl G Ar output_file 103.Op Fl v 104.Op Fl b Ar bits 105.Op Fl M Ar memory 106.Op Fl S Ar start_point 107.Nm ssh-keygen 108.Fl f Ar input_file 109.Fl T Ar output_file 110.Op Fl v 111.Op Fl a Ar rounds 112.Op Fl J Ar num_lines 113.Op Fl j Ar start_line 114.Op Fl K Ar checkpt 115.Op Fl W Ar generator 116.Nm ssh-keygen 117.Fl I Ar certificate_identity 118.Fl s Ar ca_key 119.Op Fl hU 120.Op Fl D Ar pkcs11_provider 121.Op Fl n Ar principals 122.Op Fl O Ar option 123.Op Fl V Ar validity_interval 124.Op Fl z Ar serial_number 125.Ar 126.Nm ssh-keygen 127.Fl L 128.Op Fl f Ar input_keyfile 129.Nm ssh-keygen 130.Fl A 131.Op Fl f Ar prefix_path 132.Nm ssh-keygen 133.Fl k 134.Fl f Ar krl_file 135.Op Fl u 136.Op Fl s Ar ca_public 137.Op Fl z Ar version_number 138.Ar 139.Nm ssh-keygen 140.Fl Q 141.Fl f Ar krl_file 142.Ar 143.Nm ssh-keygen 144.Fl Y Cm check-novalidate 145.Fl n Ar namespace 146.Fl s Ar signature_file 147.Nm ssh-keygen 148.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 154.Fl f Ar allowed_signers_file 155.Fl I Ar signer_identity 156.Fl n Ar namespace 157.Fl s Ar signature_file 158.Op Fl r Ar revocation_file 159.Sh DESCRIPTION 160.Nm 161generates, manages and converts authentication keys for 162.Xr ssh 1 . 163.Nm 164can create keys for use by SSH protocol version 2. 165.Pp 166The type of key to be generated is specified with the 167.Fl t 168option. 169If invoked without any arguments, 170.Nm 171will generate an RSA key. 172.Pp 173.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 180Finally, 181.Nm 182can be used to generate and update Key Revocation Lists, and to test whether 183given keys have been revoked by one. 184See the 185.Sx KEY REVOCATION LISTS 186section for details. 187.Pp 188Normally each user wishing to use SSH 189with public key authentication runs this once to create the authentication 190key in 191.Pa ~/.ssh/id_dsa , 192.Pa ~/.ssh/id_ecdsa , 193.Pa ~/.ssh/id_ecdsa_sk , 194.Pa ~/.ssh/id_ed25519 , 195.Pa ~/.ssh/id_ed25519_sk 196or 197.Pa ~/.ssh/id_rsa . 198Additionally, the system administrator may use this to generate host keys, 199as seen in 200.Pa /etc/rc . 201.Pp 202Normally this program generates the key and asks for a file in which 203to store the private key. 204The public key is stored in a file with the same name but 205.Dq .pub 206appended. 207The program also asks for a passphrase. 208The passphrase may be empty to indicate no passphrase 209(host keys must have an empty passphrase), or it may be a string of 210arbitrary length. 211A 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 215not simple sentences or otherwise easily guessable (English 216prose has only 1-2 bits of entropy per character, and provides very bad 217passphrases), and contain a mix of upper and lowercase letters, 218numbers, and non-alphanumeric characters. 219The passphrase can be changed later by using the 220.Fl p 221option. 222.Pp 223There is no way to recover a lost passphrase. 224If the passphrase is lost or forgotten, a new key must be generated 225and the corresponding public key copied to other machines. 226.Pp 227.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. 233The comment is initialized to 234.Dq user@host 235when the key is created, but can be changed using the 236.Fl c 237option. 238.Pp 239It 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 249After a key is generated, instructions below detail where the keys 250should be placed to be activated. 251.Pp 252The options are as follows: 253.Bl -tag -width Ds 254.It Fl A 255For each of the key types (rsa, dsa, ecdsa and ed25519) 256for which host keys 257do not exist, generate the host keys with the default key file path, 258an empty passphrase, default bits for the key type, and default comment. 259If 260.Fl f 261has also been specified, its argument is used as a prefix to the 262default path for the resulting host key files. 263This is used by 264.Pa /etc/rc 265to generate new host keys. 266.It Fl a Ar rounds 267When saving a private key, this option specifies the number of KDF 268(key derivation function) rounds used. 269Higher numbers result in slower passphrase verification and increased 270resistance to brute-force password cracking (should the keys be stolen). 271.Pp 272When screening DH-GEX candidates (using the 273.Fl T 274command), 275this option specifies the number of primality tests to perform. 276.It Fl B 277Show the bubblebabble digest of specified private or public key file. 278.It Fl b Ar bits 279Specifies the number of bits in the key to create. 280For RSA keys, the minimum size is 1024 bits and the default is 3072 bits. 281Generally, 3072 bits is considered sufficient. 282DSA keys must be exactly 1024 bits as specified by FIPS 186-2. 283For ECDSA keys, the 284.Fl b 285flag determines the key length by selecting from one of three elliptic 286curve sizes: 256, 384 or 521 bits. 287Attempting to use bit lengths other than these three values for ECDSA keys 288will fail. 289ECDSA-SK, Ed25519 and Ed25519-SK keys have a fixed length and the 290.Fl b 291flag will be ignored. 292.It Fl C Ar comment 293Provides a new comment. 294.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 297the passphrase if the key has one, and for the new comment. 298.It Fl D Ar pkcs11 299Download the public keys provided by the PKCS#11 shared library 300.Ar pkcs11 . 301When 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). 306.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 . 314.It Fl e 315This option will read a private or public OpenSSH key file and 316print to stdout a public key in one of the formats specified by the 317.Fl m 318option. 319The default export format is 320.Dq RFC4716 . 321This option allows exporting OpenSSH keys for use by other programs, including 322several commercial SSH implementations. 323.It Fl F Ar hostname | [hostname]:port 324Search for the specified 325.Ar hostname 326(with optional port number) 327in 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. 342.It Fl g 343Use generic DNS format when printing fingerprint resource records using the 344.Fl r 345command. 346.It Fl H 347Hash a 348.Pa known_hosts 349file. 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. 353These 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. 361.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. 367.It Fl I Ar certificate_identity 368Specify the key identity when signing a public key. 369Please see the 370.Sx CERTIFICATES 371section for details. 372.It Fl i 373This option will read an unencrypted private (or public) key file 374in the format specified by the 375.Fl m 376option and print an OpenSSH compatible private 377(or public) key to stdout. 378This option allows importing keys from other software, including several 379commercial SSH implementations. 380The default import format is 381.Dq RFC4716 . 382.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. 392.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. 400.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 406flag that revokes every key or certificate presented on the command line. 407Keys/certificates to be revoked may be specified by public key file or 408using the format described in the 409.Sx KEY REVOCATION LISTS 410section. 411.It Fl L 412Prints the contents of one or more certificates. 413.It Fl l 414Show fingerprint of specified public key file. 415For RSA and DSA keys 416.Nm 417tries to find the matching public key file and prints its fingerprint. 418If combined with 419.Fl v , 420a visual ASCII art representation of the key is supplied with the 421fingerprint. 422.It Fl M Ar memory 423Specify the amount of memory to use (in megabytes) when generating 424candidate moduli for DH-GEX. 425.It Fl m Ar key_format 426Specify a key format for key generation, the 427.Fl i 428(import), 429.Fl e 430(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. 435The supported key formats are: 436.Dq RFC4716 437(RFC 4716/SSH2 public or private key), 438.Dq PKCS8 439(PKCS8 public or private key) 440or 441.Dq PEM 442(PEM public key). 443By default OpenSSH will write newly-generated private keys in its own 444format, but when converting public keys for export the default format is 445.Dq RFC4716 . 446Setting 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. 450.It Fl N Ar new_passphrase 451Provides the new passphrase. 452.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. 459.It Fl O Ar option 460Specify a certificate option when signing a key. 461This option may be specified multiple times. 462See also the 463.Sx CERTIFICATES 464section for further details. 465.Pp 466At present, no standard options are valid for host keys. 467The options that are valid for user certificates are: 468.Pp 469.Bl -tag -width Ds -compact 470.It Ic clear 471Clear all enabled permissions. 472This is useful for clearing the default set of permissions so permissions may 473be added individually. 474.Pp 475.It Ic critical : Ns Ar name Ns Op Ns = Ns Ar contents 476.It Ic extension : Ns Ar name Ns Op Ns = Ns Ar contents 477Includes an arbitrary certificate critical option or extension. 478The specified 479.Ar name 480should include a domain suffix, e.g.\& 481.Dq name@example.com . 482If 483.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. 489.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 534.It Ic permit-X11-forwarding 535Allows X11 forwarding. 536.Pp 537.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 545.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 552.It Fl P Ar passphrase 553Provides the (old) passphrase. 554.It Fl p 555Requests changing the passphrase of a private key file instead of 556creating a new private key. 557The program will prompt for the file 558containing the private key, for the old passphrase, and twice for the 559new passphrase. 560.It Fl Q 561Test whether keys have been revoked in a KRL. 562.It Fl q 563Silence 564.Nm ssh-keygen . 565.It Fl R Ar hostname | [hostname]:port 566Removes all keys belonging to the specified 567.Ar hostname 568(with optional port number) 569from a 570.Pa known_hosts 571file. 572This option is useful to delete hashed hosts (see the 573.Fl H 574option above). 575.It Fl r Ar hostname 576Print the SSHFP fingerprint resource record named 577.Ar hostname 578for the specified public key file. 579.It Fl S Ar start 580Specify start point (in hex) when generating candidate moduli for DH-GEX. 581.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. 586.Pp 587When generating a KRL, 588.Fl s 589specifies a path to a CA public key file used to revoke certificates directly 590by key ID or serial number. 591See the 592.Sx KEY REVOCATION LISTS 593section for details. 594.It Fl T Ar output_file 595Test DH group exchange candidate primes (generated using the 596.Fl G 597option) for safety. 598.It Fl t Cm dsa | ecdsa | ecdsa-sk | ed25519 | ed25519-sk | rsa 599Specifies the type of key to create. 600The possible values are 601.Dq dsa , 602.Dq ecdsa , 603.Dq ecdsa-sk , 604.Dq ed25519 , 605.Dq ed25519-sk , 606or 607.Dq rsa . 608.Pp 609This flag may also be used to specify the desired signature type when 610signing certificates using an RSA CA key. 611The available RSA signature variants are 612.Dq ssh-rsa 613(SHA1 signatures, not recommended), 614.Dq rsa-sha2-256 , 615and 616.Dq rsa-sha2-512 617(the default). 618.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. 626.It Fl u 627Update a KRL. 628When specified with 629.Fl k , 630keys listed via the command line are added to the existing KRL rather than 631a new KRL being created. 632.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. 637.Pp 638The start time may be specified as the string 639.Dq always 640to indicate the certificate has no specified start time, 641a date in YYYYMMDD format, a time in YYYYMMDDHHMM[SS] format, 642a relative time (to the current time) consisting of a minus sign followed by 643an interval in the format described in the 644TIME FORMATS section of 645.Xr sshd_config 5 . 646.Pp 647The end time may be specified as a YYYYMMDD date, a YYYYMMDDHHMM[SS] time, 648a relative time starting with a plus character or the string 649.Dq forever 650to indicate that the certificate has no expirty date. 651.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). 661.Dq -1m:forever 662(valid from one minute ago and never expiring). 663.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. 673.It Fl W Ar generator 674Specify desired generator when testing candidate moduli for DH-GEX. 675.It Fl w Ar provider 676Specifies a path to a security key provider library that will be used when 677creating any security key-hosted keys, overriding the default of the 678internal support for USB HID keys. 679.It Fl x Ar flags 680Specifies the security key flags to use when enrolling a security key-hosted 681key. 682Flags 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. 691.It Fl y 692This option will read a private 693OpenSSH format file and print an OpenSSH public key to stdout. 694.It Fl Y Cm sign 695Cryptographically 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. 724.It Fl Y Cm verify 725Request to verify a signature generated using 726.Nm 727.Fl Y Cm sign 728as 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 745flag. 746The revocation file may be a KRL or a one-per-line list of public keys. 747Successful verification by an authorized signer is signalled by 748.Nm 749returning a zero exit status. 750.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 762flag. 763Successful testing of the signature is signalled by 764.Nm 765returning a zero exit status. 766.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. 769If 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. 775The default serial number is zero. 776.Pp 777When generating a KRL, the 778.Fl z 779flag is used to specify a KRL version number. 780.El 781.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 798.Dl # ssh-keygen -G moduli-2048.candidates -b 2048 799.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 806Once a set of candidates have been generated, they must be screened for 807suitability. 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 818.Dl # ssh-keygen -T moduli-2048 -f moduli-2048.candidates 819.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. 829Valid generator values are 2, 3, and 5. 830.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. 835.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 840more principal (user or host) names and a set of options that 841are 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 851authenticate server hosts to users. 852To generate a user certificate: 853.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 857.Pa /path/to/user_key-cert.pub . 858A 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 865.Pa /path/to/host_key-cert.pub . 866.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 874.Dl $ ssh-keygen -s ca_key.pub -D libpkcs11.so -I key_id user_key.pub 875.Pp 876Similarly, 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 884In all cases, 885.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 895.Dl "$ ssh-keygen -s ca_key -I key_id -h -n host.domain host_key.pub" 896.Pp 897Additional limitations on the validity and use of user certificates may 898be specified through certificate options. 899A certificate option may disable features of the SSH session, may be 900valid only when presented from particular source addresses or may 901force the use of a specific command. 902For a list of valid certificate options, see the documentation for the 903.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. 912By default, certificates are valid from 913.Ux 914Epoch to the distant future. 915.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. 922.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 926compact format, taking as little as one bit per certificate if they are being 927revoked by serial number. 928.Pp 929KRLs may be generated using the 930.Fl k 931flag. 932This option reads one or more files from the command line and generates a new 933KRL. 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 947.It Cm serial : Ar serial_number Ns Op - Ns Ar serial_number 948Revokes a certificate with the specified serial number. 949Serial numbers are 64-bit values, not including zero and may be expressed 950in 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 955command line using the 956.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 962command line using the 963.Fl s 964option. 965.It Cm key : Ar public_key 966Revokes the specified key. 967If a certificate is listed, then it is revoked as a plain public key. 968.It Cm sha1 : Ar public_key 969Revokes 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 975Revokes a key using a fingerprint hash, as obtained from a 976.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. 983.El 984.Pp 985KRLs may be updated using the 986.Fl u 987flag in addition to 988.Fl k . 989When this option is specified, keys listed via the command line are merged into 990the 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 996flag will query an existing KRL, testing each key specified on the command line. 997If any key listed on the command line has been revoked (or an error encountered) 998then 999.Nm 1000will exit with a non-zero exit status. 1001A zero exit status will only be returned if no key was revoked. 1002.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 1009.Xr sshd 8 . 1010Each 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 1021.Fl I 1022option must match a principals pattern in order for the corresponding key to be 1023considered 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. 1035If this option is present, the signature namespace embedded in the 1036signature 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 1053.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 1059.Sh FILES 1060.Bl -tag -width Ds -compact 1061.It Pa ~/.ssh/id_dsa 1062.It Pa ~/.ssh/id_ecdsa 1063.It Pa ~/.ssh/id_ecdsa_sk 1064.It Pa ~/.ssh/id_ed25519 1065.It Pa ~/.ssh/id_ed25519_sk 1066.It Pa ~/.ssh/id_rsa 1067Contains the DSA, ECDSA, security key-hosted ECDSA, Ed25519, 1068security key-hosted Ed25519 or RSA authentication identity of the user. 1069This 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 1072used to encrypt the private part of this file using 128-bit AES. 1073This file is not automatically accessed by 1074.Nm 1075but it is offered as the default file for the private key. 1076.Xr ssh 1 1077will read this file when a login attempt is made. 1078.Pp 1079.It Pa ~/.ssh/id_dsa.pub 1080.It Pa ~/.ssh/id_ecdsa.pub 1081.It Pa ~/.ssh/id_ecdsa_sk.pub 1082.It Pa ~/.ssh/id_ed25519.pub 1083.It Pa ~/.ssh/id_ed25519_sk.pub 1084.It Pa ~/.ssh/id_rsa.pub 1085Contains the DSA, ECDSA, security key-hosted ECDSA, Ed25519, 1086security key-hosted Ed25519 or RSA public key for authentication. 1087The contents of this file should be added to 1088.Pa ~/.ssh/authorized_keys 1089on all machines 1090where the user wishes to log in using public key authentication. 1091There is no need to keep the contents of this file secret. 1092.Pp 1093.It Pa /etc/moduli 1094Contains Diffie-Hellman groups used for DH-GEX. 1095The file format is described in 1096.Xr moduli 5 . 1097.El 1098.Sh SEE ALSO 1099.Xr ssh 1 , 1100.Xr ssh-add 1 , 1101.Xr ssh-agent 1 , 1102.Xr moduli 5 , 1103.Xr sshd 8 1104.Rs 1105.%R RFC 4716 1106.%T "The Secure Shell (SSH) Public Key File Format" 1107.%D 2006 1108.Re 1109.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. 1118