часть .. третья вроде
соединение между компьютерами, используя unix shell ssh с запросом пароля и не спрашивая пароль, проверяя ключи.
обычно нужно для доступа к сайту или серверу vps , там и описание есть и примеры настройки.
чтобы расшифровать статью с непонятных слов на чужом языке ее надо скормить яндекс переводчику. А если срочно – отнести в бюро переводов за 5000р распечатав на 30 листах бумаги.
еще более правильно – выучить язык на котором разговаривают программисты. Чаще это русский и китайский уже, не только индийский вариант инглиш.. так во многих профессиях.
- с шифрованием доигрались – цепочкой операций теперь расшифровывается бухгалтерская книга у криптовалют.. а если – хакер смотрит на старую сидюшку года 2006 на которой шариковой ручкой подписано резольвер ша 256, она из за этого с третьего раза читается. надеюсь что как говорят наши заокеанские друзья конкуренты что фейк. (иначе первой крипте каюк или кранты)
причина изменения нескольких настроек – новые версии программ, и повышеная безопасность по большей части из за перестраховки. в третьем и четвертом абзаце не считая оглавление причина почему разные типы серверов например 2014 года и 2022 вроде бы linux а не связываются.
SSH keys
Reason: The intro and Background section ignore the server perspective. (Discuss in Talk:SSH keys) SSH keys can serve as a means of identifying yourself to an SSH server using public-key cryptography and challenge-response authentication. The major advantage of key-based authentication is that, in contrast to password authentication, it is not prone to brute-force attacks, and you do not expose valid credentials if the server has been compromised (see RFC 4251 9.4.4).
Furthermore, SSH key authentication can be more convenient than the more traditional password authentication. When used with a program known as an SSH agent, SSH keys can allow you to connect to a server, or multiple servers, without having to remember or enter your password for each system.
Key-based authentication is not without its drawbacks and may not be appropriate for all environments, but in many circumstances it can offer some strong advantages. A general understanding of how SSH keys work will help you decide how and when to use them to meet your needs.
This article assumes you already have a basic understanding of the Secure Shell protocol and have installed the openssh package.
Contents
better – install FreeBSD and read the .. manual.
FreeBSD Manual Pages
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 |
SSH-KEYGEN(1) FreeBSD General Commands Manual SSH-KEYGEN(1) <a href="https://www.freebsd.org/cgi/man.cgi?query=ssh-keygen&sektion=1&format=html#end"><strong>NAME</strong></a> <strong>ssh-keygen</strong> -- OpenSSH authentication key utility <a href="https://www.freebsd.org/cgi/man.cgi?query=ssh-keygen&sektion=1&format=html#end"><strong>SYNOPSIS</strong></a> <strong>ssh-keygen</strong> [<strong>-q</strong>] [<strong>-a</strong> <em>rounds</em>] [<strong>-b</strong> <em>bits</em>] [<strong>-C</strong> <em>comment</em>] [<strong>-f</strong> <em>output</em>_<em>keyfile</em>] [<strong>-m</strong> <em>format</em>] [<strong>-N</strong> <em>new</em>_<em>passphrase</em>] [<strong>-O</strong> <em>option</em>] [<strong>-t</strong> <strong>dsa</strong> | <strong>ecdsa</strong> | <strong>ecdsa-sk</strong> | <strong>ed25519</strong> | <strong>ed25519-sk</strong> | <strong>rsa</strong>] [<strong>-w</strong> <em>provider</em>] [<strong>-Z</strong> <em>cipher</em>] <strong>ssh-keygen</strong> <strong>-p</strong> [<strong>-a</strong> <em>rounds</em>] [<strong>-f</strong> <em>keyfile</em>] [<strong>-m</strong> <em>format</em>] [<strong>-N</strong> <em>new</em>_<em>passphrase</em>] [<strong>-P</strong> <em>old</em>_<em>passphrase</em>] [<strong>-Z</strong> <em>cipher</em>] <strong>ssh-keygen</strong> <strong>-i</strong> [<strong>-f</strong> <em>input</em>_<em>keyfile</em>] [<strong>-m</strong> <em>key</em>_<em>format</em>] <strong>ssh-keygen</strong> <strong>-e</strong> [<strong>-f</strong> <em>input</em>_<em>keyfile</em>] [<strong>-m</strong> <em>key</em>_<em>format</em>] <strong>ssh-keygen</strong> <strong>-y</strong> [<strong>-f</strong> <em>input</em>_<em>keyfile</em>] <strong>ssh-keygen</strong> <strong>-c</strong> [<strong>-a</strong> <em>rounds</em>] [<strong>-C</strong> <em>comment</em>] [<strong>-f</strong> <em>keyfile</em>] [<strong>-P</strong> <em>passphrase</em>] <strong>ssh-keygen</strong> <strong>-l</strong> [<strong>-v</strong>] [<strong>-E</strong> <em>fingerprint</em>_<em>hash</em>] [<strong>-f</strong> <em>input</em>_<em>keyfile</em>] <strong>ssh-keygen</strong> <strong>-B</strong> [<strong>-f</strong> <em>input</em>_<em>keyfile</em>] <strong>ssh-keygen</strong> <strong>-D</strong> <em>pkcs11</em> <strong>ssh-keygen</strong> <strong>-F</strong> <em>hostname</em> [<strong>-lv</strong>] [<strong>-f</strong> <em>known</em>_<em>hosts</em>_<em>file</em>] <strong>ssh-keygen</strong> <strong>-H</strong> [<strong>-f</strong> <em>known</em>_<em>hosts</em>_<em>file</em>] <strong>ssh-keygen</strong> <strong>-K</strong> [<strong>-a</strong> <em>rounds</em>] [<strong>-w</strong> <em>provider</em>] <strong>ssh-keygen</strong> <strong>-R</strong> <em>hostname</em> [<strong>-f</strong> <em>known</em>_<em>hosts</em>_<em>file</em>] <strong>ssh-keygen</strong> <strong>-r</strong> <em>hostname</em> [<strong>-g</strong>] [<strong>-f</strong> <em>input</em>_<em>keyfile</em>] <strong>ssh-keygen</strong> <strong>-M</strong> <strong>generate</strong> [<strong>-O</strong> <em>option</em>] <em>output</em>_<em>file</em> <strong>ssh-keygen</strong> <strong>-M</strong> <strong>screen</strong> [<strong>-f</strong> <em>input</em>_<em>file</em>] [<strong>-O</strong> <em>option</em>] <em>output</em>_<em>file</em> <strong>ssh-keygen</strong> <strong>-I</strong> <em>certificate</em>_<em>identity</em> <strong>-s</strong> <em>ca</em>_<em>key</em> [<strong>-hU</strong>] [<strong>-D</strong> <em>pkcs11</em>_<em>provider</em>] [<strong>-n</strong> <em>principals</em>] [<strong>-O</strong> <em>option</em>] [<strong>-V</strong> <em>validity</em>_<em>interval</em>] [<strong>-z</strong> <em>serial</em>_<em>number</em>] <em>file</em> <em>...</em> <strong>ssh-keygen</strong> <strong>-L</strong> [<strong>-f</strong> <em>input</em>_<em>keyfile</em>] <strong>ssh-keygen</strong> <strong>-A</strong> [<strong>-a</strong> <em>rounds</em>] [<strong>-f</strong> <em>prefix</em>_<em>path</em>] <strong>ssh-keygen</strong> <strong>-k</strong> <strong>-f</strong> <em>krl</em>_<em>file</em> [<strong>-u</strong>] [<strong>-s</strong> <em>ca</em>_<em>public</em>] [<strong>-z</strong> <em>version</em>_<em>number</em>] <em>file</em> <em>...</em> <strong>ssh-keygen</strong> <strong>-Q</strong> [<strong>-l</strong>] <strong>-f</strong> <em>krl</em>_<em>file</em> <em>file</em> <em>...</em> <strong>ssh-keygen</strong> <strong>-Y</strong> <strong>find-principals</strong> [<strong>-O</strong> <em>option</em>] <strong>-s</strong> <em>signature</em>_<em>file</em> <strong>-f</strong> <em>allowed</em>_<em>signers</em>_<em>file</em> <strong>ssh-keygen</strong> <strong>-Y</strong> <strong>check-novalidate</strong> [<strong>-O</strong> <em>option</em>] <strong>-n</strong> <em>namespace</em> <strong>-s</strong> <em>signature</em>_<em>file</em> <strong>ssh-keygen</strong> <strong>-Y</strong> <strong>sign</strong> <strong>-f</strong> <em>key</em>_<em>file</em> <strong>-n</strong> <em>namespace</em> <em>file</em> <em>...</em> <strong>ssh-keygen</strong> <strong>-Y</strong> <strong>verify</strong> [<strong>-O</strong> <em>option</em>] <strong>-f</strong> <em>allowed</em>_<em>signers</em>_<em>file</em> <strong>-I</strong> <em>signer</em>_<em>identity</em> <strong>-n</strong> <em>namespace</em> <strong>-s</strong> <em>signature</em>_<em>file</em> [<strong>-r</strong> <em>revocation</em>_<em>file</em>] <a href="https://www.freebsd.org/cgi/man.cgi?query=ssh-keygen&sektion=1&format=html#end"><strong>DESCRIPTION</strong></a> <strong>ssh-keygen</strong> generates, manages and converts authentication keys for <a href="https://www.freebsd.org/cgi/man.cgi?query=ssh&sektion=1&apropos=0&manpath=FreeBSD+13.1-RELEASE+and+Ports">ssh(1)</a>. <strong>ssh-keygen</strong> can create keys for use by SSH protocol version 2. The type of key to be generated is specified with the <strong>-t</strong> option. If in- voked without any arguments, <strong>ssh-keygen</strong> will generate an RSA key. <strong>ssh-keygen</strong> is also used to generate groups for use in Diffie-Hellman group exchange (DH-GEX). See the <em>MODULI</em> <em>GENERATION</em> section for details. Finally, <strong>ssh-keygen</strong> can be used to generate and update Key Revocation Lists, and to test whether given keys have been revoked by one. See the <em>KEY</em> <em>REVOCATION</em> <em>LISTS</em> section for details. Normally each user wishing to use SSH with public key authentication runs this once to create the authentication key in <em>~/.ssh/id</em>_<em>dsa</em>, <em>~/.ssh/id</em>_<em>ecdsa</em>, <em>~/.ssh/id</em>_<em>ecdsa</em>_<em>sk</em>, <em>~/.ssh/id</em>_<em>ed25519</em>, <em>~/.ssh/id</em>_<em>ed25519</em>_<em>sk</em> or <em>~/.ssh/id</em>_<em>rsa</em>. Additionally, the system adminis- trator may use this to generate host keys, as seen in <em>/etc/rc</em>. Normally this program generates the key and asks for a file in which to store the private key. The public key is stored in a file with the same name but ".pub" appended. The program also asks for a passphrase. The passphrase may be empty to indicate no passphrase (host keys must have an empty passphrase), or it may be a string of arbitrary length. A passphrase is similar to a password, except it can be a phrase with a se- ries of words, punctuation, numbers, whitespace, or any string of charac- ters you want. Good passphrases are 10-30 characters long, are not sim- ple sentences or otherwise easily guessable (English prose has only 1-2 bits of entropy per character, and provides very bad passphrases), and contain a mix of upper and lowercase letters, numbers, and non-alphanu- meric characters. The passphrase can be changed later by using the <strong>-p</strong> option. There is no way to recover a lost passphrase. If the passphrase is lost or forgotten, a new key must be generated and the corresponding public key copied to other machines. <strong>ssh-keygen</strong> will by default write keys in an OpenSSH-specific format. This format is preferred as it offers better protection for keys at rest as well as allowing storage of key comments within the private key file itself. The key comment may be useful to help identify the key. The comment is initialized to "user@host" when the key is created, but can be changed using the <strong>-c</strong> option. It is still possible for <strong>ssh-keygen</strong> to write the previously-used PEM for- mat private keys using the <strong>-m</strong> flag. This may be used when generating new keys, and existing new-format keys may be converted using this option in conjunction with the <strong>-p</strong> (change passphrase) flag. After a key is generated, <strong>ssh-keygen</strong> will ask where the keys should be placed to be activated. The options are as follows: <strong>-A</strong> For each of the key types (rsa, dsa, ecdsa and ed25519) for which host keys do not exist, generate the host keys with the default key file path, an empty passphrase, default bits for the key type, and default comment. If <strong>-f</strong> has also been specified, its argument is used as a prefix to the default path for the result- ing host key files. This is used by <em>/etc/rc</em> to generate new host keys. <strong>-a</strong> <em>rounds</em> When saving a private key, this option specifies the number of KDF (key derivation function, currently <a href="https://www.freebsd.org/cgi/man.cgi?query=bcrypt_pbkdf&sektion=3&apropos=0&manpath=FreeBSD+13.1-RELEASE+and+Ports">bcrypt_pbkdf(3)</a>) rounds used. Higher numbers result in slower passphrase verification and increased resistance to brute-force password cracking (should the keys be stolen). The default is 16 rounds. <strong>-B</strong> Show the bubblebabble digest of specified private or public key file. <strong>-b</strong> <em>bits</em> Specifies the number of bits in the key to create. For RSA keys, the minimum size is 1024 bits and the default is 3072 bits. Gen- erally, 3072 bits is considered sufficient. DSA keys must be ex- actly 1024 bits as specified by FIPS 186-2. For ECDSA keys, the <strong>-b</strong> flag determines the key length by selecting from one of three elliptic curve sizes: 256, 384 or 521 bits. Attempting to use bit lengths other than these three values for ECDSA keys will fail. ECDSA-SK, Ed25519 and Ed25519-SK keys have a fixed length and the <strong>-b</strong> flag will be ignored. <strong>-C</strong> <em>comment</em> Provides a new comment. <strong>-c</strong> Requests changing the comment in the private and public key files. The program will prompt for the file containing the pri- vate keys, for the passphrase if the key has one, and for the new comment. <strong>-D</strong> <em>pkcs11</em> Download the public keys provided by the PKCS#11 shared library <em>pkcs11</em>. When used in combination with <strong>-s</strong>, this option indicates that a CA key resides in a PKCS#11 token (see the <em>CERTIFICATES</em> section for details). <strong>-E</strong> <em>fingerprint</em>_<em>hash</em> Specifies the hash algorithm used when displaying key finger- prints. Valid options are: "md5" and "sha256". The default is "sha256". <strong>-e</strong> This option will read a private or public OpenSSH key file and print to stdout a public key in one of the formats specified by the <strong>-m</strong> option. The default export format is "RFC4716". This op- tion allows exporting OpenSSH keys for use by other programs, in- cluding several commercial SSH implementations. <strong>-F</strong> <em>hostname</em> | <em>[hostname]:port</em> Search for the specified <em>hostname</em> (with optional port number) in a <em>known</em>_<em>hosts</em> file, listing any occurrences found. This option is useful to find hashed host names or addresses and may also be used in conjunction with the <strong>-H</strong> option to print found keys in a hashed format. <strong>-f</strong> <em>filename</em> Specifies the filename of the key file. <strong>-g</strong> Use generic DNS format when printing fingerprint resource records using the <strong>-r</strong> command. <strong>-H</strong> Hash a <em>known</em>_<em>hosts</em> file. This replaces all hostnames and ad- dresses with hashed representations within the specified file; the original content is moved to a file with a .old suffix. These hashes may be used normally by <strong>ssh</strong> and <strong>sshd</strong>, but they do not reveal identifying information should the file's contents be disclosed. This option will not modify existing hashed hostnames and is therefore safe to use on files that mix hashed and non- hashed names. <strong>-h</strong> When signing a key, create a host certificate instead of a user certificate. Please see the <em>CERTIFICATES</em> section for details. <strong>-I</strong> <em>certificate</em>_<em>identity</em> Specify the key identity when signing a public key. Please see the <em>CERTIFICATES</em> section for details. <strong>-i</strong> This option will read an unencrypted private (or public) key file in the format specified by the <strong>-m</strong> option and print an OpenSSH compatible private (or public) key to stdout. This option allows importing keys from other software, including several commercial SSH implementations. The default import format is "RFC4716". <strong>-K</strong> Download resident keys from a FIDO authenticator. Public and private key files will be written to the current directory for each downloaded key. If multiple FIDO authenticators are at- tached, keys will be downloaded from the first touched authenti- cator. <strong>-k</strong> Generate a KRL file. In this mode, <strong>ssh-keygen</strong> will generate a KRL file at the location specified via the <strong>-f</strong> flag that revokes every key or certificate presented on the command line. Keys/certificates to be revoked may be specified by public key file or using the format described in the <em>KEY</em> <em>REVOCATION</em> <em>LISTS</em> section. <strong>-L</strong> Prints the contents of one or more certificates. <strong>-l</strong> Show fingerprint of specified public key file. For RSA and DSA keys <strong>ssh-keygen</strong> tries to find the matching public key file and prints its fingerprint. If combined with <strong>-v</strong>, a visual ASCII art representation of the key is supplied with the fingerprint. <strong>-M</strong> <strong>generate</strong> Generate candidate Diffie-Hellman Group Exchange (DH-GEX) parame- ters for eventual use by the `diffie-hellman-group-exchange-*' key exchange methods. The numbers generated by this operation must be further screened before use. See the <em>MODULI</em> <em>GENERATION</em> section for more information. <strong>-M</strong> <strong>screen</strong> Screen candidate parameters for Diffie-Hellman Group Exchange. This will accept a list of candidate numbers and test that they are safe (Sophie Germain) primes with acceptable group genera- tors. The results of this operation may be added to the <em>/etc/moduli</em> file. See the <em>MODULI</em> <em>GENERATION</em> section for more in- formation. <strong>-m</strong> <em>key</em>_<em>format</em> Specify a key format for key generation, the <strong>-i</strong> (import), <strong>-e</strong> (ex- port) conversion options, and the <strong>-p</strong> change passphrase operation. The latter may be used to convert between OpenSSH private key and PEM private key formats. The supported key formats are: "RFC4716" (RFC 4716/SSH2 public or private key), "PKCS8" (PKCS8 public or private key) or "PEM" (PEM public key). By default OpenSSH will write newly-generated private keys in its own for- mat, but when converting public keys for export the default for- mat is "RFC4716". Setting a format of "PEM" when generating or updating a supported private key type will cause the key to be stored in the legacy PEM private key format. <strong>-N</strong> <em>new</em>_<em>passphrase</em> Provides the new passphrase. <strong>-n</strong> <em>principals</em> Specify one or more principals (user or host names) to be in- cluded in a certificate when signing a key. Multiple principals may be specified, separated by commas. Please see the <em>CERTIFICATES</em> section for details. <strong>-O</strong> <em>option</em> Specify a key/value option. These are specific to the operation that <strong>ssh-keygen</strong> has been requested to perform. When signing certificates, one of the options listed in the <em>CERTIFICATES</em> section may be specified here. When performing moduli generation or screening, one of the op- tions listed in the <em>MODULI</em> <em>GENERATION</em> section may be specified. When generating a key that will be hosted on a FIDO authentica- tor, this flag may be used to specify key-specific options. Those supported at present are: <strong>application</strong> Override the default FIDO application/origin string of "ssh:". This may be useful when generating host or do- main-specific resident keys. The specified application string must begin with "ssh:". <strong>challenge</strong>=<em>path</em> Specifies a path to a challenge string that will be passed to the FIDO token during key generation. The challenge string may be used as part of an out-of-band protocol for key enrollment (a random challenge is used by default). <strong>device</strong> Explicitly specify a <a href="https://www.freebsd.org/cgi/man.cgi?query=fido&sektion=4&apropos=0&manpath=FreeBSD+13.1-RELEASE+and+Ports">fido(4)</a> device to use, rather than letting the token middleware select one. <strong>no-touch-required</strong> Indicate that the generated private key should not re- quire touch events (user presence) when making signa- tures. Note that <a href="https://www.freebsd.org/cgi/man.cgi?query=sshd&sektion=8&apropos=0&manpath=FreeBSD+13.1-RELEASE+and+Ports">sshd(8)</a> will refuse such signatures by default, unless overridden via an authorized_keys option. <strong>resident</strong> Indicate that the key should be stored on the FIDO au- thenticator itself. Resident keys may be supported on FIDO2 tokens and typically require that a PIN be set on the token prior to generation. Resident keys may be loaded off the token using <a href="https://www.freebsd.org/cgi/man.cgi?query=ssh-add&sektion=1&apropos=0&manpath=FreeBSD+13.1-RELEASE+and+Ports">ssh-add(1)</a>. <strong>user</strong> A username to be associated with a resident key, overrid- ing the empty default username. Specifying a username may be useful when generating multiple resident keys for the same application name. <strong>verify-required</strong> Indicate that this private key should require user veri- fication for each signature. Not all FIDO tokens support this option. Currently PIN authentication is the only supported verification method, but other methods may be supported in the future. <strong>write-attestation</strong>=<em>path</em> May be used at key generation time to record the attesta- tion data returned from FIDO tokens during key genera- tion. Please note that this information is potentially sensitive. By default, this information is discarded. When performing signature-related options using the <strong>-Y</strong> flag, the following options are accepted: <strong>print-pubkey</strong> Print the full public key to standard output after signa- ture verification. <strong>verify-time</strong>=<em>timestamp</em> Specifies a time to use when validating signatures in- stead of the current time. The time may be specified as a date in YYYYMMDD format or a time in YYYYMMDDHHMM[SS] format. The <strong>-O</strong> option may be specified multiple times. <strong>-P</strong> <em>passphrase</em> Provides the (old) passphrase. <strong>-p</strong> Requests changing the passphrase of a private key file instead of creating a new private key. The program will prompt for the file containing the private key, for the old passphrase, and twice for the new passphrase. <strong>-Q</strong> Test whether keys have been revoked in a KRL. If the <strong>-l</strong> option is also specified then the contents of the KRL will be printed. <strong>-q</strong> Silence <strong>ssh-keygen</strong>. <strong>-R</strong> <em>hostname</em> | <em>[hostname]:port</em> Removes all keys belonging to the specified <em>hostname</em> (with op- tional port number) from a <em>known</em>_<em>hosts</em> file. This option is use- ful to delete hashed hosts (see the <strong>-H</strong> option above). <strong>-r</strong> <em>hostname</em> Print the SSHFP fingerprint resource record named <em>hostname</em> for the specified public key file. <strong>-s</strong> <em>ca</em>_<em>key</em> Certify (sign) a public key using the specified CA key. Please see the <em>CERTIFICATES</em> section for details. When generating a KRL, <strong>-s</strong> specifies a path to a CA public key file used to revoke certificates directly by key ID or serial number. See the <em>KEY</em> <em>REVOCATION</em> <em>LISTS</em> section for details. <strong>-t</strong> <strong>dsa</strong> | <strong>ecdsa</strong> | <strong>ecdsa-sk</strong> | <strong>ed25519</strong> | <strong>ed25519-sk</strong> | <strong>rsa</strong> Specifies the type of key to create. The possible values are "dsa", "ecdsa", "ecdsa-sk", "ed25519", "ed25519-sk", or "rsa". This flag may also be used to specify the desired signature type when signing certificates using an RSA CA key. The available RSA signature variants are "ssh-rsa" (SHA1 signatures, not recom- mended), "rsa-sha2-256", and "rsa-sha2-512" (the default). <strong>-U</strong> When used in combination with <strong>-s</strong>, this option indicates that a CA key resides in a <a href="https://www.freebsd.org/cgi/man.cgi?query=ssh-agent&sektion=1&apropos=0&manpath=FreeBSD+13.1-RELEASE+and+Ports">ssh-agent(1)</a>. See the <em>CERTIFICATES</em> section for more information. <strong>-u</strong> Update a KRL. When specified with <strong>-k</strong>, keys listed via the com- mand line are added to the existing KRL rather than a new KRL be- ing created. <strong>-V</strong> <em>validity</em>_<em>interval</em> Specify a validity interval when signing a certificate. A valid- ity interval may consist of a single time, indicating that the certificate is valid beginning now and expiring at that time, or may consist of two times separated by a colon to indicate an ex- plicit time interval. The start time may be specified as the string "always" to indi- cate the certificate has no specified start time, a date in YYYYMMDD format, a time in YYYYMMDDHHMM[SS] format, a relative time (to the current time) consisting of a minus sign followed by an interval in the format described in the TIME FORMATS section of <a href="https://www.freebsd.org/cgi/man.cgi?query=sshd_config&sektion=5&apropos=0&manpath=FreeBSD+13.1-RELEASE+and+Ports">sshd_config(5)</a>. The end time may be specified as a YYYYMMDD date, a YYYYMMD- DHHMM[SS] time, a relative time starting with a plus character or the string "forever" to indicate that the certificate has no ex- piry date. For example: "+52w1d" (valid from now to 52 weeks and one day from now), "-4w:+4w" (valid from four weeks ago to four weeks from now), "20100101123000:20110101123000" (valid from 12:30 PM, January 1st, 2010 to 12:30 PM, January 1st, 2011), "-1d:20110101" (valid from yesterday to midnight, January 1st, 2011), "-1m:forever" (valid from one minute ago and never expiring). <strong>-v</strong> Verbose mode. Causes <strong>ssh-keygen</strong> to print debugging messages about its progress. This is helpful for debugging moduli genera- tion. Multiple <strong>-v</strong> options increase the verbosity. The maximum is 3. <strong>-w</strong> <em>provider</em> Specifies a path to a library that will be used when creating FIDO authenticator-hosted keys, overriding the default of using the internal USB HID support. <strong>-Y</strong> <strong>find-principals</strong> Find the principal(s) associated with the public key of a signa- ture, provided using the <strong>-s</strong> flag in an authorized signers file provided using the <strong>-f</strong> flag. The format of the allowed signers file is documented in the <em>ALLOWED</em> <em>SIGNERS</em> section below. If one or more matching principals are found, they are returned on stan- dard output. <strong>-Y</strong> <strong>check-novalidate</strong> Checks that a signature generated using <strong>ssh-keygen</strong> <strong>-Y</strong> <strong>sign</strong> has a valid structure. This does not validate if a signature comes from an authorized signer. When testing a signature, <strong>ssh-keygen</strong> accepts a message on standard input and a signature namespace us- ing <strong>-n</strong>. A file containing the corresponding signature must also be supplied using the <strong>-s</strong> flag. Successful testing of the signa- ture is signalled by <strong>ssh-keygen</strong> returning a zero exit status. <strong>-Y</strong> <strong>sign</strong> Cryptographically sign a file or some data using a SSH key. When signing, <strong>ssh-keygen</strong> accepts zero or more files to sign on the command-line - if no files are specified then <strong>ssh-keygen</strong> will sign data presented on standard input. Signatures are written to the path of the input file with ".sig" appended, or to standard output if the message to be signed was read from standard input. The key used for signing is specified using the <strong>-f</strong> option and may refer to either a private key, or a public key with the private half available via <a href="https://www.freebsd.org/cgi/man.cgi?query=ssh-agent&sektion=1&apropos=0&manpath=FreeBSD+13.1-RELEASE+and+Ports">ssh-agent(1)</a>. An additional signature name- space, used to prevent signature confusion across different do- mains of use (e.g. file signing vs email signing) must be pro- vided via the <strong>-n</strong> flag. Namespaces are arbitrary strings, and may include: "file" for file signing, "email" for email signing. For custom uses, it is recommended to use names following a NAME- SPACE@YOUR.DOMAIN pattern to generate unambiguous namespaces. <strong>-Y</strong> <strong>verify</strong> Request to verify a signature generated using <strong>ssh-keygen</strong> <strong>-Y</strong> <strong>sign</strong> as described above. When verifying a signature, <strong>ssh-keygen</strong> ac- cepts a message on standard input and a signature namespace using <strong>-n</strong>. A file containing the corresponding signature must also be supplied using the <strong>-s</strong> flag, along with the identity of the signer using <strong>-I</strong> and a list of allowed signers via the <strong>-f</strong> flag. The for- mat of the allowed signers file is documented in the <em>ALLOWED</em> <em>SIGNERS</em> section below. A file containing revoked keys can be passed using the <strong>-r</strong> flag. The revocation file may be a KRL or a one-per-line list of public keys. Successful verification by an authorized signer is signalled by <strong>ssh-keygen</strong> returning a zero exit status. <strong>-y</strong> This option will read a private OpenSSH format file and print an OpenSSH public key to stdout. <strong>-Z</strong> <em>cipher</em> Specifies the cipher to use for encryption when writing an OpenSSH-format private key file. The list of available ciphers may be obtained using "ssh -Q cipher". The default is "aes256-ctr". <strong>-z</strong> <em>serial</em>_<em>number</em> Specifies a serial number to be embedded in the certificate to distinguish this certificate from others from the same CA. If the <em>serial</em>_<em>number</em> is prefixed with a `+' character, then the se- rial number will be incremented for each certificate signed on a single command-line. The default serial number is zero. When generating a KRL, the <strong>-z</strong> flag is used to specify a KRL ver- sion number. <a href="https://www.freebsd.org/cgi/man.cgi?query=ssh-keygen&sektion=1&format=html#end"><strong>MODULI GENERATION</strong></a> <strong>ssh-keygen</strong> may be used to generate groups for the Diffie-Hellman Group Exchange (DH-GEX) protocol. Generating these groups is a two-step process: first, candidate primes are generated using a fast, but memory intensive process. These candidate primes are then tested for suitabil- ity (a CPU-intensive process). Generation of primes is performed using the <strong>-M</strong> <strong>generate</strong> option. The de- sired length of the primes may be specified by the <strong>-O</strong> <strong>bits</strong> option. For example: # ssh-keygen -M generate -O bits=2048 moduli-2048.candidates By default, the search for primes begins at a random point in the desired length range. This may be overridden using the <strong>-O</strong> <strong>start</strong> option, which specifies a different start point (in hex). Once a set of candidates have been generated, they must be screened for suitability. This may be performed using the <strong>-M</strong> <strong>screen</strong> option. In this mode <strong>ssh-keygen</strong> will read candidates from standard input (or a file spec- ified using the <strong>-f</strong> option). For example: # ssh-keygen -M screen -f moduli-2048.candidates moduli-2048 By default, each candidate will be subjected to 100 primality tests. This may be overridden using the <strong>-O</strong> <strong>prime-tests</strong> option. The DH generator value will be chosen automatically for the prime under consideration. If a specific generator is desired, it may be requested using the <strong>-O</strong> <strong>generator</strong> option. Valid generator values are 2, 3, and 5. Screened DH groups may be installed in <em>/etc/moduli</em>. It is important that this file contains moduli of a range of bit lengths. A number of options are available for moduli generation and screening via the <strong>-O</strong> flag: <strong>lines</strong>=<em>number</em> Exit after screening the specified number of lines while perform- ing DH candidate screening. <strong>start-line</strong>=<em>line-number</em> Start screening at the specified line number while performing DH candidate screening. <strong>checkpoint</strong>=<em>filename</em> Write the last line processed to the specified file while per- forming DH candidate screening. This will be used to skip lines in the input file that have already been processed if the job is restarted. <strong>memory</strong>=<em>mbytes</em> Specify the amount of memory to use (in megabytes) when generat- ing candidate moduli for DH-GEX. <strong>start</strong>=<em>hex-value</em> Specify start point (in hex) when generating candidate moduli for DH-GEX. <strong>generator</strong>=<em>value</em> Specify desired generator (in decimal) when testing candidate moduli for DH-GEX. <a href="https://www.freebsd.org/cgi/man.cgi?query=ssh-keygen&sektion=1&format=html#end"><strong>CERTIFICATES</strong></a> <strong>ssh-keygen</strong> supports signing of keys to produce certificates that may be used for user or host authentication. Certificates consist of a public key, some identity information, zero or more principal (user or host) names and a set of options that are signed by a Certification Authority (CA) key. Clients or servers may then trust only the CA key and verify its signature on a certificate rather than trusting many user/host keys. Note that OpenSSH certificates are a different, and much simpler, format to the X.509 certificates used in <a href="https://www.freebsd.org/cgi/man.cgi?query=ssl&sektion=8&apropos=0&manpath=FreeBSD+13.1-RELEASE+and+Ports">ssl(8)</a>. <strong>ssh-keygen</strong> supports two types of certificates: user and host. User cer- tificates authenticate users to servers, whereas host certificates au- thenticate server hosts to users. To generate a user certificate: $ ssh-keygen -s /path/to/ca_key -I key_id /path/to/user_key.pub The resultant certificate will be placed in <em>/path/to/user</em>_<em>key-cert.pub</em>. A host certificate requires the <strong>-h</strong> option: $ ssh-keygen -s /path/to/ca_key -I key_id -h /path/to/host_key.pub The host certificate will be output to <em>/path/to/host</em>_<em>key-cert.pub</em>. It is possible to sign using a CA key stored in a PKCS#11 token by pro- viding the token library using <strong>-D</strong> and identifying the CA key by providing its public half as an argument to <strong>-s</strong>: $ ssh-keygen -s ca_key.pub -D libpkcs11.so -I key_id user_key.pub Similarly, it is possible for the CA key to be hosted in a <a href="https://www.freebsd.org/cgi/man.cgi?query=ssh-agent&sektion=1&apropos=0&manpath=FreeBSD+13.1-RELEASE+and+Ports">ssh-agent(1)</a>. This is indicated by the <strong>-U</strong> flag and, again, the CA key must be identi- fied by its public half. $ ssh-keygen -Us ca_key.pub -I key_id user_key.pub In all cases, <em>key</em>_<em>id</em> is a "key identifier" that is logged by the server when the certificate is used for authentication. Certificates may be limited to be valid for a set of principal (user/host) names. By default, generated certificates are valid for all users or hosts. To generate a certificate for a specified set of princi- pals: $ ssh-keygen -s ca_key -I key_id -n user1,user2 user_key.pub $ ssh-keygen -s ca_key -I key_id -h -n host.domain host_key.pub Additional limitations on the validity and use of user certificates may be specified through certificate options. A certificate option may dis- able features of the SSH session, may be valid only when presented from particular source addresses or may force the use of a specific command. The options that are valid for user certificates are: <strong>clear</strong> Clear all enabled permissions. This is useful for clearing the default set of permissions so permissions may be added individu- ally. <strong>critical</strong>:<em>name</em>[=<em>contents</em>] <strong>extension</strong>:<em>name</em>[=<em>contents</em>] Includes an arbitrary certificate critical option or extension. The specified <em>name</em> should include a domain suffix, e.g. "name@example.com". If <em>contents</em> is specified then it is included as the contents of the extension/option encoded as a string, oth- erwise the extension/option is created with no contents (usually indicating a flag). Extensions may be ignored by a client or server that does not recognise them, whereas unknown critical op- tions will cause the certificate to be refused. <strong>force-command</strong>=<em>command</em> Forces the execution of <em>command</em> instead of any shell or command specified by the user when the certificate is used for authenti- cation. <strong>no-agent-forwarding</strong> Disable <a href="https://www.freebsd.org/cgi/man.cgi?query=ssh-agent&sektion=1&apropos=0&manpath=FreeBSD+13.1-RELEASE+and+Ports">ssh-agent(1)</a> forwarding (permitted by default). <strong>no-port-forwarding</strong> Disable port forwarding (permitted by default). <strong>no-pty</strong> Disable PTY allocation (permitted by default). <strong>no-user-rc</strong> Disable execution of <em>~/.ssh/rc</em> by <a href="https://www.freebsd.org/cgi/man.cgi?query=sshd&sektion=8&apropos=0&manpath=FreeBSD+13.1-RELEASE+and+Ports">sshd(8)</a> (permitted by default). <strong>no-x11-forwarding</strong> Disable X11 forwarding (permitted by default). <strong>permit-agent-forwarding</strong> Allows <a href="https://www.freebsd.org/cgi/man.cgi?query=ssh-agent&sektion=1&apropos=0&manpath=FreeBSD+13.1-RELEASE+and+Ports">ssh-agent(1)</a> forwarding. <strong>permit-port-forwarding</strong> Allows port forwarding. <strong>permit-pty</strong> Allows PTY allocation. <strong>permit-user-rc</strong> Allows execution of <em>~/.ssh/rc</em> by <a href="https://www.freebsd.org/cgi/man.cgi?query=sshd&sektion=8&apropos=0&manpath=FreeBSD+13.1-RELEASE+and+Ports">sshd(8)</a>. <strong>permit-X11-forwarding</strong> Allows X11 forwarding. <strong>no-touch-required</strong> Do not require signatures made using this key include demonstra- tion of user presence (e.g. by having the user touch the authen- ticator). This option only makes sense for the FIDO authentica- tor algorithms <strong>ecdsa-sk</strong> and <strong>ed25519-sk</strong>. <strong>source-address</strong>=<em>address</em>_<em>list</em> Restrict the source addresses from which the certificate is con- sidered valid. The <em>address</em>_<em>list</em> is a comma-separated list of one or more address/netmask pairs in CIDR format. <strong>verify-required</strong> Require signatures made using this key indicate that the user was first verified. This option only makes sense for the FIDO au- thenticator algorithms <strong>ecdsa-sk</strong> and <strong>ed25519-sk</strong>. Currently PIN authentication is the only supported verification method, but other methods may be supported in the future. At present, no standard options are valid for host keys. Finally, certificates may be defined with a validity lifetime. The <strong>-V</strong> option allows specification of certificate start and end times. A cer- tificate that is presented at a time outside this range will not be con- sidered valid. By default, certificates are valid from the UNIX Epoch to the distant future. For certificates to be used for user or host authentication, the CA pub- lic key must be trusted by <a href="https://www.freebsd.org/cgi/man.cgi?query=sshd&sektion=8&apropos=0&manpath=FreeBSD+13.1-RELEASE+and+Ports">sshd(8)</a> or <a href="https://www.freebsd.org/cgi/man.cgi?query=ssh&sektion=1&apropos=0&manpath=FreeBSD+13.1-RELEASE+and+Ports">ssh(1)</a>. Please refer to those man- ual pages for details. <a href="https://www.freebsd.org/cgi/man.cgi?query=ssh-keygen&sektion=1&format=html#end"><strong>KEY REVOCATION LISTS</strong></a> <strong>ssh-keygen</strong> is able to manage OpenSSH format Key Revocation Lists (KRLs). These binary files specify keys or certificates to be revoked using a compact format, taking as little as one bit per certificate if they are being revoked by serial number. KRLs may be generated using the <strong>-k</strong> flag. This option reads one or more files from the command line and generates a new KRL. The files may ei- ther contain a KRL specification (see below) or public keys, listed one per line. Plain public keys are revoked by listing their hash or con- tents in the KRL and certificates revoked by serial number or key ID (if the serial is zero or not available). Revoking keys using a KRL specification offers explicit control over the types of record used to revoke keys and may be used to directly revoke certificates by serial number or key ID without having the complete orig- inal certificate on hand. A KRL specification consists of lines contain- ing one of the following directives followed by a colon and some direc- tive-specific information. <strong>serial</strong>: <em>serial</em>_<em>number</em>[-<em>serial</em>_<em>number</em>] Revokes a certificate with the specified serial number. Serial numbers are 64-bit values, not including zero and may be ex- pressed in decimal, hex or octal. If two serial numbers are specified separated by a hyphen, then the range of serial numbers including and between each is revoked. The CA key must have been specified on the <strong>ssh-keygen</strong> command line using the <strong>-s</strong> option. <strong>id</strong>: <em>key</em>_<em>id</em> Revokes a certificate with the specified key ID string. The CA key must have been specified on the <strong>ssh-keygen</strong> command line using the <strong>-s</strong> option. <strong>key</strong>: <em>public</em>_<em>key</em> Revokes the specified key. If a certificate is listed, then it is revoked as a plain public key. <strong>sha1</strong>: <em>public</em>_<em>key</em> Revokes the specified key by including its SHA1 hash in the KRL. <strong>sha256</strong>: <em>public</em>_<em>key</em> Revokes the specified key by including its SHA256 hash in the KRL. KRLs that revoke keys by SHA256 hash are not supported by OpenSSH versions prior to 7.9. <strong>hash</strong>: <em>fingerprint</em> Revokes a key using a fingerprint hash, as obtained from a <a href="https://www.freebsd.org/cgi/man.cgi?query=sshd&sektion=8&apropos=0&manpath=FreeBSD+13.1-RELEASE+and+Ports" target="_blank" rel="noreferrer noopener">sshd(8)</a> authentication log message or the <strong>ssh-keygen</strong> <strong>-l</strong> flag. Only SHA256 fingerprints are supported here and resultant KRLs are not supported by OpenSSH versions prior to 7.9. KRLs may be updated using the <strong>-u</strong> flag in addition to <strong>-k</strong>. When this op- tion is specified, keys listed via the command line are merged into the KRL, adding to those already there. It is also possible, given a KRL, to test whether it revokes a particular key (or keys). The <strong>-Q</strong> flag will query an existing KRL, testing each key specified on the command line. If any key listed on the command line has been revoked (or an error encountered) then <strong>ssh-keygen</strong> will exit with a non-zero exit status. A zero exit status will only be returned if no key was revoked. <a href="https://www.freebsd.org/cgi/man.cgi?query=ssh-keygen&sektion=1&format=html#end"><strong>ALLOWED SIGNERS</strong></a> When verifying signatures, <strong>ssh-keygen</strong> uses a simple list of identities and keys to determine whether a signature comes from an authorized source. This "allowed signers" file uses a format patterned after the AUTHORIZED_KEYS FILE FORMAT described in <a href="https://www.freebsd.org/cgi/man.cgi?query=sshd&sektion=8&apropos=0&manpath=FreeBSD+13.1-RELEASE+and+Ports">sshd(8)</a>. Each line of the file contains the following space-separated fields: principals, options, key- type, base64-encoded key. Empty lines and lines starting with a `#' are ignored as comments. The principals field is a pattern-list (see PATTERNS in <a href="https://www.freebsd.org/cgi/man.cgi?query=ssh_config&sektion=5&apropos=0&manpath=FreeBSD+13.1-RELEASE+and+Ports" target="_blank" rel="noreferrer noopener">ssh_config(5)</a>) consisting of one or more comma-separated USER@DOMAIN identity patterns that are accepted for signing. When verifying, the identity presented via the <strong>-I</strong> option must match a principals pattern in order for the corre- sponding key to be considered acceptable for verification. The options (if present) consist of comma-separated option specifica- tions. No spaces are permitted, except within double quotes. The fol- lowing option specifications are supported (note that option keywords are case-insensitive): <strong>cert-authority</strong> Indicates that this key is accepted as a certificate authority (CA) and that certificates signed by this CA may be accepted for verification. <strong>namespaces</strong>=namespace-list Specifies a pattern-list of namespaces that are accepted for this key. If this option is present, the signature namespace embedded in the signature object and presented on the verification com- mand-line must match the specified list before the key will be considered acceptable. <strong>valid-after</strong>=timestamp Indicates that the key is valid for use at or after the specified timestamp, which may be a date in YYYYMMDD format or a time in YYYYMMDDHHMM[SS] format. <strong>valid-before</strong>=timestamp Indicates that the key is valid for use at or before the speci- fied timestamp. When verifying signatures made by certificates, the expected principal name must match both the principals pattern in the allowed signers file and the principals embedded in the certificate itself. An example allowed signers file: # Comments allowed at start of line user1@example.com,user2@example.com ssh-rsa AAAAX1... # A certificate authority, trusted for all principals in a domain. *@example.com cert-authority ssh-ed25519 AAAB4... # A key that is accepted only for file signing. user2@example.com namespaces="file" ssh-ed25519 AAA41... <a href="https://www.freebsd.org/cgi/man.cgi?query=ssh-keygen&sektion=1&format=html#end"><strong>ENVIRONMENT</strong></a> SSH_SK_PROVIDER Specifies a path to a library that will be used when loading any FIDO authenticator-hosted keys, overriding the default of using the built-in USB HID support. <a href="https://www.freebsd.org/cgi/man.cgi?query=ssh-keygen&sektion=1&format=html#end"><strong>FILES</strong></a> ~/.ssh/id_dsa ~/.ssh/id_ecdsa ~/.ssh/id_ecdsa_sk ~/.ssh/id_ed25519 ~/.ssh/id_ed25519_sk ~/.ssh/id_rsa Contains the DSA, ECDSA, authenticator-hosted ECDSA, Ed25519, au- thenticator-hosted Ed25519 or RSA authentication identity of the user. This file should not be readable by anyone but the user. It is possible to specify a passphrase when generating the key; that passphrase will be used to encrypt the private part of this file using 128-bit AES. This file is not automatically accessed by <strong>ssh-keygen</strong> but it is offered as the default file for the pri- vate key. <a href="https://www.freebsd.org/cgi/man.cgi?query=ssh&sektion=1&apropos=0&manpath=FreeBSD+13.1-RELEASE+and+Ports">ssh(1)</a> will read this file when a login attempt is made. ~/.ssh/id_dsa.pub ~/.ssh/id_ecdsa.pub ~/.ssh/id_ecdsa_sk.pub ~/.ssh/id_ed25519.pub ~/.ssh/id_ed25519_sk.pub ~/.ssh/id_rsa.pub Contains the DSA, ECDSA, authenticator-hosted ECDSA, Ed25519, au- thenticator-hosted Ed25519 or RSA public key for authentication. The contents of this file should be added to <em>~/.ssh/authorized</em>_<em>keys</em> on all machines where the user wishes to log in using public key authentication. There is no need to keep the contents of this file secret. /etc/moduli Contains Diffie-Hellman groups used for DH-GEX. The file format is described in <a href="https://www.freebsd.org/cgi/man.cgi?query=moduli&sektion=5&apropos=0&manpath=FreeBSD+13.1-RELEASE+and+Ports">moduli(5)</a>. <a href="https://www.freebsd.org/cgi/man.cgi?query=ssh-keygen&sektion=1&format=html#end"><strong>SEE ALSO</strong></a> <a href="https://www.freebsd.org/cgi/man.cgi?query=ssh&sektion=1&apropos=0&manpath=FreeBSD+13.1-RELEASE+and+Ports">ssh(1)</a>, <a href="https://www.freebsd.org/cgi/man.cgi?query=ssh-add&sektion=1&apropos=0&manpath=FreeBSD+13.1-RELEASE+and+Ports">ssh-add(1)</a>, <a href="https://www.freebsd.org/cgi/man.cgi?query=ssh-agent&sektion=1&apropos=0&manpath=FreeBSD+13.1-RELEASE+and+Ports">ssh-agent(1)</a>, <a href="https://www.freebsd.org/cgi/man.cgi?query=moduli&sektion=5&apropos=0&manpath=FreeBSD+13.1-RELEASE+and+Ports">moduli(5)</a>, <a href="https://www.freebsd.org/cgi/man.cgi?query=sshd&sektion=8&apropos=0&manpath=FreeBSD+13.1-RELEASE+and+Ports">sshd(8)</a> <em>The</em> <em>Secure</em> <em>Shell</em> <em>(SSH)</em> <em>Public</em> <em>Key</em> <em>File</em> <em>Format</em>, RFC 4716, 2006. <a href="https://www.freebsd.org/cgi/man.cgi?query=ssh-keygen&sektion=1&format=html#end"><strong>AUTHORS</strong></a> OpenSSH is a derivative of the original and free ssh 1.2.12 release by Tatu Ylonen. Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos, Theo de Raadt and Dug Song removed many bugs, re-added newer features and cre- ated OpenSSH. Markus Friedl contributed the support for SSH protocol versions 1.5 and 2.0. FreeBSD 13.0 August 11, 2021 FreeBSD 13.0 |
NAME | SYNOPSIS | DESCRIPTION | MODULI GENERATION | CERTIFICATES | KEY REVOCATION LISTS | ALLOWED SIGNERS | ENVIRONMENT | FILES | SEE ALSO | AUTHORS
Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=ssh-keygen&sektion=1&manpath=FreeBSD+13.1-RELEASE+and+Ports>home | help
Skip site navigation (1)Skip section navigation (2)
FreeBSD Manual Pages
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
MODULI(5) FreeBSD File Formats Manual MODULI(5) <a href="https://www.freebsd.org/cgi/man.cgi?query=moduli&sektion=5&apropos=0&manpath=FreeBSD+13.1-RELEASE+and+Ports#end"><strong>NAME</strong></a> <strong>moduli</strong> -- Diffie-Hellman moduli <a href="https://www.freebsd.org/cgi/man.cgi?query=moduli&sektion=5&apropos=0&manpath=FreeBSD+13.1-RELEASE+and+Ports#end"><strong>DESCRIPTION</strong></a> The <em>/etc/ssh/moduli</em> file contains prime numbers and generators for use by <a href="https://www.freebsd.org/cgi/man.cgi?query=sshd&sektion=8&apropos=0&manpath=FreeBSD+13.1-RELEASE+and+Ports">sshd(8)</a> in the Diffie-Hellman Group Exchange key exchange method. New moduli may be generated with <a href="https://www.freebsd.org/cgi/man.cgi?query=ssh-keygen&sektion=1&apropos=0&manpath=FreeBSD+13.1-RELEASE+and+Ports">ssh-keygen(1)</a> using a two-step process. An initial <em>candidate</em> <em>generation</em> pass, using <strong>ssh-keygen</strong> <strong>-G</strong>, calculates numbers that are likely to be useful. A second <em>primality</em> <em>testing</em> pass, using <strong>ssh-keygen</strong> <strong>-T</strong>, provides a high degree of assurance that the numbers are prime and are safe for use in Diffie-Hellman operations by <a href="https://www.freebsd.org/cgi/man.cgi?query=sshd&sektion=8&apropos=0&manpath=FreeBSD+13.1-RELEASE+and+Ports">sshd(8)</a>. This <strong>moduli</strong> format is used as the output from each pass. The file consists of newline-separated records, one per modulus, contain- ing seven space-separated fields. These fields are as follows: timestamp The time that the modulus was last processed as YYYYM- MDDHHMMSS. type Decimal number specifying the internal structure of the prime modulus. Supported types are: 0 Unknown, not tested. 2 "Safe" prime; (p-1)/2 is also prime. 4 Sophie Germain; 2p+1 is also prime. Moduli candidates initially produced by <a href="https://www.freebsd.org/cgi/man.cgi?query=ssh-keygen&sektion=1&apropos=0&manpath=FreeBSD+13.1-RELEASE+and+Ports">ssh-keygen(1)</a> are Sophie Germain primes (type 4). Further primality testing with <a href="https://www.freebsd.org/cgi/man.cgi?query=ssh-keygen&sektion=1&apropos=0&manpath=FreeBSD+13.1-RELEASE+and+Ports">ssh-keygen(1)</a> produces safe prime moduli (type 2) that are ready for use in <a href="https://www.freebsd.org/cgi/man.cgi?query=sshd&sektion=8&apropos=0&manpath=FreeBSD+13.1-RELEASE+and+Ports">sshd(8)</a>. Other types are not used by OpenSSH. tests Decimal number indicating the type of primality tests that the number has been subjected to represented as a bitmask of the following values: 0x00 Not tested. 0x01 Composite number - not prime. 0x02 Sieve of Eratosthenes. 0x04 Probabilistic Miller-Rabin primality tests. The <a href="https://www.freebsd.org/cgi/man.cgi?query=ssh-keygen&sektion=1&apropos=0&manpath=FreeBSD+13.1-RELEASE+and+Ports">ssh-keygen(1)</a> moduli candidate generation uses the Sieve of Eratosthenes (flag 0x02). Subsequent <a href="https://www.freebsd.org/cgi/man.cgi?query=ssh-keygen&sektion=1&apropos=0&manpath=FreeBSD+13.1-RELEASE+and+Ports">ssh-keygen(1)</a> primality tests are Miller-Rabin tests (flag 0x04). trials Decimal number indicating the number of primality tri- als that have been performed on the modulus. size Decimal number indicating the size of the prime in bits. generator The recommended generator for use with this modulus (hexadecimal). modulus The modulus itself in hexadecimal. When performing Diffie-Hellman Group Exchange, <a href="https://www.freebsd.org/cgi/man.cgi?query=sshd&sektion=8&apropos=0&manpath=FreeBSD+13.1-RELEASE+and+Ports">sshd(8)</a> first estimates the size of the modulus required to produce enough Diffie-Hellman output to sufficiently key the selected symmetric cipher. <a href="https://www.freebsd.org/cgi/man.cgi?query=sshd&sektion=8&apropos=0&manpath=FreeBSD+13.1-RELEASE+and+Ports">sshd(8)</a> then randomly selects a modulus from <em>/etc/ssh/moduli</em> that best meets the size require- ment. <a href="https://www.freebsd.org/cgi/man.cgi?query=moduli&sektion=5&apropos=0&manpath=FreeBSD+13.1-RELEASE+and+Ports#end"><strong>SEE ALSO</strong></a> <a href="https://www.freebsd.org/cgi/man.cgi?query=ssh-keygen&sektion=1&apropos=0&manpath=FreeBSD+13.1-RELEASE+and+Ports">ssh-keygen(1)</a>, <a href="https://www.freebsd.org/cgi/man.cgi?query=sshd&sektion=8&apropos=0&manpath=FreeBSD+13.1-RELEASE+and+Ports">sshd(8)</a> <em>Diffie-Hellman</em> <em>Group</em> <em>Exchange</em> <em>for</em> <em>the</em> <em>Secure</em> <em>Shell</em> <em>(SSH)</em> <em>Transport</em> <em>Layer</em> <em>Protocol</em>, RFC 4419, 2006. FreeBSD 13.0 July 19, 2012 FreeBSD 13.0 |
NAME | DESCRIPTION | SEE ALSO
Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=moduli&sektion=5&manpath=FreeBSD+13.1-RELEASE+and+Ports>home | help
Legal Notices | © 1995-2022 The FreeBSD Project. All rights reserved.
Contact
How to Set Up SSH Keys on CentOS 8
Last Updated: Fri, Mar 13, 2020 CentOS Linux Guides System Admin
Introduction
This guide explains how to create SSH keys, add the public key to your CentOS 8 server, and configure sshd for passwordless login. The IP address 192.0.2.123 is an example.
1. Create an SSH key pair
Create an SSH key pair on your computer with ssh-keygen.
1 |
$ ssh-keygen |
After running this command, you should see the following prompt:
1 2 3 |
Output Generating public/private rsa key pair. Enter file in which to save the key (/your_home/.ssh/id_rsa): |
Press ENTER to save this SSH key pair into the ./ssh subdirectory of your home directory, or specify an alternate path if you want.
After this you should see the following output:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
Output Your identification has been saved in ~/.ssh/id_rsa. Your public key has been saved in ~/.ssh/id_rsa.pub. The key fingerprint is: your_fingerprint_key username@remote_host The key's randomart image is: +--[ RSA 2048]----+ | ..o | | E o= . | | o. o | | .. | | ..S | | o o. | | =o.+. | |. =++.. | |o=++. | +-----------------+ |
You have created a public and private key pair. To view your public key:
1 |
$ cat ~/.ssh/id_rsa.pub |
You will see a very long string that starts with ssh-rsa.
2. Add SSH key to CentOS server
SSH to the server and create the .ssh directory, if it doesn’t already exist:
1 |
$ mkdir -p ~/.ssh |
Add the public key from step 1 to ~/.ssh/authorized_keys. Replace public_key with the contents of id_rsa.pub from step 1.
1 |
$ echo public_key >> ~/.ssh/authorized_keys |
Log out of the server, then log back in:
1 |
$ ssh root@192.0.2.123 |
You will be prompted for your server root password.
3. Disable Password Authentication
Your SSH key-based authentication is configured, but password authentication is still active. To change this you need to make some changes to the file sshd_config which is located in /etc/ssh directory. You can open that file with this command:
1 |
sudo vi /etc/ssh/sshd_config |
In the file, you need to find and change several lines Permit Root Login should be set to yes
1 2 3 |
... PermitRootLogin yes ... |
Password Authentication should be set to no
1 2 3 |
... PasswordAuthentication no ... |
Challenge-Response Authentication should be set to no
1 2 3 |
... ChallengeResponseAuthentication no ... |
Using of Password Authentication Method (PAM) should be set to yes
1 2 3 |
... UsePAM yes ... |
After making these changes, press ESC and then :WQ. For this change to take effect, restart the sshd service:
1 |
sudo systemctl restart sshd.service |
Before closing your terminal, open a new terminal window and run this command
1 |
ssh root@192.0.2.123 |
You should connect to the server without a password. SSH-based authentication is successfully configured and password authentication is disabled.
по – русски
Описание параметров файла конфигурации sshd config
sshd config это файл конфигурации SSH-сервера openssh-server.
Обычное местоположение файла /etc/ssh/sshd_config, но может быть указано и другое в параметрах запуска программы.
Описание параметров
1 2 |
<strong>Port</strong> ПОРТ порт на котором создаётся сервера, по умолчанию 22 |
1 2 3 4 5 6 7 |
<strong>ListenAddress</strong> АДРЕС указание адреса на котором создаётся сервер, по умолчанию сервер принимает подключения на всех сетевых интерфейсах. Возможные варианты ListenAddress :: ListenAddress 0.0.0.0 - создание на всех IP4 адресах ListenAddress 192.168.0.1 - создание только на одном сетевом интерфёйсе ListenAddress 192.168.10.0:48675 - создание только на одном сетевом интерфейсе вместе с портом |
1 2 3 |
<strong>Protocol</strong> 2 указание версии протокола SSH, по умолчанию 2 Внимание! Первая версия протокола SSH небезопасна! |
1 2 3 |
<strong>HostKey</strong> /etc/ssh/ssh_host_rsa_key <strong>HostKey</strong> /etc/ssh/ssh_host_dsa_key (для версии протокола 2) указание названия файлов RSA/DSA ключей и их расположение. |
1 2 3 4 5 |
<strong>UsePrivilegeSeparation</strong> yes установка разделения привилегий. Если указано <em>yes</em> - то сначала создаётся непривилегированный дочерний процесс для входящего сетевого трафика. После успешной авторизации запускается другой процесс с привилегиями вошедшего пользователя. Основная цель разделения привилегий - предотвращение превышения прав доступа. |
1 2 |
<strong>KeyRegenerationInterval</strong> 3600 (для версии протокола 1) установка временного ключа |
1 2 |
<strong>ServerKeyBits</strong> 768 (для версии протокола 1) установка длины ключа |
1 2 3 4 |
<strong>SyslogFacility</strong> AUTH установка типа событий для записи в журнал (/var/log/auth.log) Доступны следующие значения: DAEMON, USER, AUTH, LOCAL0, LOCAL1, LOCAL2, LOCAL3, LOCAL4, LOCAL5, LOCAL6, LOCAL7, где AUTH - авторизация на сервере |
1 2 3 |
<strong>LogLevel</strong> INFO установка детализации событий для записи в журнал (/var/log/auth.log), по умолчанию INFO Доступны следующие события: SILENT, QUIET, FATAL, ERROR, INFO, VERBOSE, DEBUG, DEBUG1, DEBUG2, DEBUG3. |
1 2 |
<strong>LoginGraceTime</strong> 120 установка времени разрыва соединения в секундах, если пользователь не осущствит авторизацию, по умолчанию 120 сек |
1 2 3 4 5 6 7 8 |
<strong>PermitRootLogin</strong> without-password установка разрешения для авторизации суперпользователя Доступны следующие значения: yes - вход суперпользователю разрешён, параметр по умолчанию no - вход суперпользователю запрещён without-password - авторизация суперпользователя по паролю отключена (но возможна по открытому ключу) forced-commands-only - вход суперпользователю по открытому ключу разрешён, но только для выполнения команды (указанному в AuthorizedKeysFile ?!) |
1 2 |
<strong>StrictModes</strong> yes установка проверки у пользователя прав на владение пользовательскими файлами и домашним каталогом перед разращением входа |
1 2 3 4 5 6 |
<strong>AllowUsers</strong> user1 user2 ... установка разрешения доступа к серверу по протоколу SSH только для перечисленных пользователей. Значениями этого параметра могут выступать имена пользователей (не UID!), отделённые друг от друга пробелами. Допускается использование записи вида user@host, что означает разрешёние доступа пользователю user с компьютера host. Причём пользователь и компьютер проверяются отдельно, то естть доступ может быть разрешён только определенным пользователям с определенных компьютеров. |
1 2 3 |
<strong>DenyUsers</strong> user1 user2 ... установка запрета доступа к серверу по протоколу SSH для перечисленных пользователей. Правила формирования имён такие же как у <em>AllowUsers</em> |
1 2 |
<strong>AllowGroups</strong> user1 user2 ... установка разрешения доступа к серверу по протоколу SSH только для перечисленных групп пользователей. |
1 2 |
<strong>DenyGroups</strong> user1 user2 ... установка запрета доступа к серверу по протоколу SSH для перечисленных групп пользователей. |
1 2 |
<strong>RSAAuthentication</strong> yes установка типа аутентификации RSA |
1 2 |
<strong>PubkeyAuthentication</strong> yes включение аутентификации по открытому ключу |
1 2 3 4 5 |
<strong>AuthorizedKeysFile</strong> .ssh/authorized_keys указание имени файла, в котором содержатся публичные ключи, используемые для аутентификации пользователей по открытому ключу. В записи могут присутствовать записи в форме %T, которые заменяются в момент установки соединения, например %% заменяется на %, %h означает домашний каталог пользователя,а %u – имя пользователя. По умолчанию ".ssh/authorized_keys .ssh/authorized_keys2". |
1 2 3 |
<strong>IgnoreRhosts</strong> yes установка игнорирования параметров пользователя из файлов ~/.rhosts and ~/.shosts (параметр для совместимости с программой rhosts) |
1 2 3 4 |
<strong>RhostsRSAAuthentication</strong> no включение поддержки аутентификации RSA для rhosts. Для работы этого параметра ключи узла должны быть присоединены в /etc/ssh_known_hosts (параметр для совместимости с программой rhosts) |
1 2 3 |
<strong>HostbasedAuthentication</strong> no включение поддержки аутентификации Hostbased для rhosts. (параметр для совместимости с программой rhosts) |
1 2 3 |
<strong>IgnoreUserKnownHosts</strong> yes установка игнорирования пользовательскому ~/.ssh/known_hosts для RhostsRSAAuthentication (параметр для совместимости с программой rhosts) |
1 2 |
<strong>PermitEmptyPasswords</strong> no установка разрешения входа с пустым паролем. |
1 2 3 4 |
<strong>ChallengeResponseAuthentication</strong> no включение PAM интерфейса при авторизации. Если задано значение yes, то для всех типов аутентификации помимо обработки модуля сессии и аккаунта PAM, будет использоваться аутентификация на основе запроса-ответа (ChallengeResponseAuthentication и PasswordAuthentication). |
1 2 3 |
<strong>PasswordAuthentication</strong> yes включение авторизации по паролю. Альтернатива аутентификации по ключу хоста. |
1 2 3 4 5 |
<strong>Параметры, отвечающие за аутентификацию Kerberos</strong> #KerberosAuthentication no #KerberosGetAFSToken no #KerberosOrLocalPasswd yes #KerberosTicketCleanup yes |
1 2 3 |
<strong>Параметры, отвечающие за аутентификацию GSSAPI</strong> #GSSAPIAuthentication no #GSSAPICleanupCredentials yes |
1 2 3 |
<strong>X11Forwarding</strong> yes установка разрешения перенаправления портов X-системы через ssh-туннель Будет работать, если на сервере установлен XServer. |
1 2 3 |
<strong>X11DisplayOffset</strong> 10 установка смещения дисплеев X11 при пробросе портов X-системы через ssh туннель Будет работать, если на сервере включён X11Forwarding |
1 2 |
<strong>PrintMotd</strong> no включение вывода при создании ssh-сессии информационного сообщения из файла /etc/motd. |
1 2 3 |
<strong>PrintLastLog</strong> &n |