1.\" 2.\" Author: Tatu Ylonen <ylo@cs.hut.fi> 3.\" Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4.\" All rights reserved 5.\" 6.\" As far as I am concerned, the code I have written for this software 7.\" can be used freely for any purpose. Any derived versions of this 8.\" software must be clearly marked as such, and if the derived work is 9.\" incompatible with the protocol description in the RFC file, it must be 10.\" called by a name other than "ssh" or "Secure Shell". 11.\" 12.\" Copyright (c) 1999,2000 Markus Friedl. All rights reserved. 13.\" Copyright (c) 1999 Aaron Campbell. All rights reserved. 14.\" Copyright (c) 1999 Theo de Raadt. All rights reserved. 15.\" 16.\" Redistribution and use in source and binary forms, with or without 17.\" modification, are permitted provided that the following conditions 18.\" are met: 19.\" 1. Redistributions of source code must retain the above copyright 20.\" notice, this list of conditions and the following disclaimer. 21.\" 2. Redistributions in binary form must reproduce the above copyright 22.\" notice, this list of conditions and the following disclaimer in the 23.\" documentation and/or other materials provided with the distribution. 24.\" 25.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 26.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 27.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 28.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 29.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 30.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 31.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 32.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 34.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35.\" 36.\" $OpenBSD: sshd.8,v 1.279 2015/05/01 07:11:47 djm Exp $ 37.\" $FreeBSD$ 38.Dd $Mdocdate: May 1 2015 $ 39.Dt SSHD 8 40.Os 41.Sh NAME 42.Nm sshd 43.Nd OpenSSH SSH daemon 44.Sh SYNOPSIS 45.Nm sshd 46.Bk -words 47.Op Fl 46DdeiqTt 48.Op Fl b Ar bits 49.Op Fl C Ar connection_spec 50.Op Fl c Ar host_certificate_file 51.Op Fl E Ar log_file 52.Op Fl f Ar config_file 53.Op Fl g Ar login_grace_time 54.Op Fl h Ar host_key_file 55.Op Fl k Ar key_gen_time 56.Op Fl o Ar option 57.Op Fl p Ar port 58.Op Fl u Ar len 59.Ek 60.Sh DESCRIPTION 61.Nm 62(OpenSSH Daemon) is the daemon program for 63.Xr ssh 1 . 64Together these programs replace rlogin and rsh, 65and provide secure encrypted communications between two untrusted hosts 66over an insecure network. 67.Pp 68.Nm 69listens for connections from clients. 70It is normally started at boot from 71.Pa /etc/rc.d/sshd . 72It forks a new 73daemon for each incoming connection. 74The forked daemons handle 75key exchange, encryption, authentication, command execution, 76and data exchange. 77.Pp 78.Nm 79can be configured using command-line options or a configuration file 80(by default 81.Xr sshd_config 5 ) ; 82command-line options override values specified in the 83configuration file. 84.Nm 85rereads its configuration file when it receives a hangup signal, 86.Dv SIGHUP , 87by executing itself with the name and options it was started with, e.g.\& 88.Pa /usr/sbin/sshd . 89.Pp 90The options are as follows: 91.Bl -tag -width Ds 92.It Fl 4 93Forces 94.Nm 95to use IPv4 addresses only. 96.It Fl 6 97Forces 98.Nm 99to use IPv6 addresses only. 100.It Fl b Ar bits 101Specifies the number of bits in the ephemeral protocol version 1 102server key (default 1024). 103.It Fl C Ar connection_spec 104Specify the connection parameters to use for the 105.Fl T 106extended test mode. 107If provided, any 108.Cm Match 109directives in the configuration file 110that would apply to the specified user, host, and address will be set before 111the configuration is written to standard output. 112The connection parameters are supplied as keyword=value pairs. 113The keywords are 114.Dq user , 115.Dq host , 116.Dq laddr , 117.Dq lport , 118and 119.Dq addr . 120All are required and may be supplied in any order, either with multiple 121.Fl C 122options or as a comma-separated list. 123.It Fl c Ar host_certificate_file 124Specifies a path to a certificate file to identify 125.Nm 126during key exchange. 127The certificate file must match a host key file specified using the 128.Fl h 129option or the 130.Cm HostKey 131configuration directive. 132.It Fl D 133When this option is specified, 134.Nm 135will not detach and does not become a daemon. 136This allows easy monitoring of 137.Nm sshd . 138.It Fl d 139Debug mode. 140The server sends verbose debug output to standard error, 141and does not put itself in the background. 142The server also will not fork and will only process one connection. 143This option is only intended for debugging for the server. 144Multiple 145.Fl d 146options increase the debugging level. 147Maximum is 3. 148.It Fl E Ar log_file 149Append debug logs to 150.Ar log_file 151instead of the system log. 152.It Fl e 153Write debug logs to standard error instead of the system log. 154.It Fl f Ar config_file 155Specifies the name of the configuration file. 156The default is 157.Pa /etc/ssh/sshd_config . 158.Nm 159refuses to start if there is no configuration file. 160.It Fl g Ar login_grace_time 161Gives the grace time for clients to authenticate themselves (default 162120 seconds). 163If the client fails to authenticate the user within 164this many seconds, the server disconnects and exits. 165A value of zero indicates no limit. 166.It Fl h Ar host_key_file 167Specifies a file from which a host key is read. 168This option must be given if 169.Nm 170is not run as root (as the normal 171host key files are normally not readable by anyone but root). 172The default is 173.Pa /etc/ssh/ssh_host_key 174for protocol version 1, and 175.Pa /etc/ssh/ssh_host_dsa_key , 176.Pa /etc/ssh/ssh_host_ecdsa_key . 177.Pa /etc/ssh/ssh_host_ed25519_key 178and 179.Pa /etc/ssh/ssh_host_rsa_key 180for protocol version 2. 181It is possible to have multiple host key files for 182the different protocol versions and host key algorithms. 183.It Fl i 184Specifies that 185.Nm 186is being run from 187.Xr inetd 8 . 188.Nm 189is normally not run 190from inetd because it needs to generate the server key before it can 191respond to the client, and this may take tens of seconds. 192Clients would have to wait too long if the key was regenerated every time. 193However, with small key sizes (e.g. 512) using 194.Nm 195from inetd may 196be feasible. 197.It Fl k Ar key_gen_time 198Specifies how often the ephemeral protocol version 1 server key is 199regenerated (default 3600 seconds, or one hour). 200The motivation for regenerating the key fairly 201often is that the key is not stored anywhere, and after about an hour 202it becomes impossible to recover the key for decrypting intercepted 203communications even if the machine is cracked into or physically 204seized. 205A value of zero indicates that the key will never be regenerated. 206.It Fl o Ar option 207Can be used to give options in the format used in the configuration file. 208This is useful for specifying options for which there is no separate 209command-line flag. 210For full details of the options, and their values, see 211.Xr sshd_config 5 . 212.It Fl p Ar port 213Specifies the port on which the server listens for connections 214(default 22). 215Multiple port options are permitted. 216Ports specified in the configuration file with the 217.Cm Port 218option are ignored when a command-line port is specified. 219Ports specified using the 220.Cm ListenAddress 221option override command-line ports. 222.It Fl q 223Quiet mode. 224Nothing is sent to the system log. 225Normally the beginning, 226authentication, and termination of each connection is logged. 227.It Fl T 228Extended test mode. 229Check the validity of the configuration file, output the effective configuration 230to stdout and then exit. 231Optionally, 232.Cm Match 233rules may be applied by specifying the connection parameters using one or more 234.Fl C 235options. 236.It Fl t 237Test mode. 238Only check the validity of the configuration file and sanity of the keys. 239This is useful for updating 240.Nm 241reliably as configuration options may change. 242.It Fl u Ar len 243This option is used to specify the size of the field 244in the 245.Li utmp 246structure that holds the remote host name. 247If the resolved host name is longer than 248.Ar len , 249the dotted decimal value will be used instead. 250This allows hosts with very long host names that 251overflow this field to still be uniquely identified. 252Specifying 253.Fl u0 254indicates that only dotted decimal addresses 255should be put into the 256.Pa utmp 257file. 258.Fl u0 259may also be used to prevent 260.Nm 261from making DNS requests unless the authentication 262mechanism or configuration requires it. 263Authentication mechanisms that may require DNS include 264.Cm RhostsRSAAuthentication , 265.Cm HostbasedAuthentication , 266and using a 267.Cm from="pattern-list" 268option in a key file. 269Configuration options that require DNS include using a 270USER@HOST pattern in 271.Cm AllowUsers 272or 273.Cm DenyUsers . 274.El 275.Sh AUTHENTICATION 276The OpenSSH SSH daemon supports SSH protocols 1 and 2. 277The default is to use protocol 2 only, 278though this can be changed via the 279.Cm Protocol 280option in 281.Xr sshd_config 5 . 282Protocol 2 supports DSA, ECDSA, Ed25519 and RSA keys; 283protocol 1 only supports RSA keys. 284For both protocols, 285each host has a host-specific key, 286normally 2048 bits, 287used to identify the host. 288.Pp 289Forward security for protocol 1 is provided through 290an additional server key, 291normally 768 bits, 292generated when the server starts. 293This key is normally regenerated every hour if it has been used, and 294is never stored on disk. 295Whenever a client connects, the daemon responds with its public 296host and server keys. 297The client compares the 298RSA host key against its own database to verify that it has not changed. 299The client then generates a 256-bit random number. 300It encrypts this 301random number using both the host key and the server key, and sends 302the encrypted number to the server. 303Both sides then use this 304random number as a session key which is used to encrypt all further 305communications in the session. 306The rest of the session is encrypted 307using a conventional cipher, currently Blowfish or 3DES, with 3DES 308being used by default. 309The client selects the encryption algorithm 310to use from those offered by the server. 311.Pp 312For protocol 2, 313forward security is provided through a Diffie-Hellman key agreement. 314This key agreement results in a shared session key. 315The rest of the session is encrypted using a symmetric cipher, currently 316128-bit AES, Blowfish, 3DES, CAST128, Arcfour, 192-bit AES, or 256-bit AES. 317The client selects the encryption algorithm 318to use from those offered by the server. 319Additionally, session integrity is provided 320through a cryptographic message authentication code 321(hmac-md5, hmac-sha1, umac-64, umac-128, hmac-ripemd160, 322hmac-sha2-256 or hmac-sha2-512). 323.Pp 324Finally, the server and the client enter an authentication dialog. 325The client tries to authenticate itself using 326host-based authentication, 327public key authentication, 328challenge-response authentication, 329or password authentication. 330.Pp 331Regardless of the authentication type, the account is checked to 332ensure that it is accessible. An account is not accessible if it is 333locked, listed in 334.Cm DenyUsers 335or its group is listed in 336.Cm DenyGroups 337\&. The definition of a locked account is system dependant. Some platforms 338have their own account database (eg AIX) and some modify the passwd field ( 339.Ql \&*LK\&* 340on Solaris and UnixWare, 341.Ql \&* 342on HP-UX, containing 343.Ql Nologin 344on Tru64, 345a leading 346.Ql \&*LOCKED\&* 347on FreeBSD and a leading 348.Ql \&! 349on most Linuxes). 350If there is a requirement to disable password authentication 351for the account while allowing still public-key, then the passwd field 352should be set to something other than these values (eg 353.Ql NP 354or 355.Ql \&*NP\&* 356). 357.Pp 358If the client successfully authenticates itself, a dialog for 359preparing the session is entered. 360At this time the client may request 361things like allocating a pseudo-tty, forwarding X11 connections, 362forwarding TCP connections, or forwarding the authentication agent 363connection over the secure channel. 364.Pp 365After this, the client either requests a shell or execution of a command. 366The sides then enter session mode. 367In this mode, either side may send 368data at any time, and such data is forwarded to/from the shell or 369command on the server side, and the user terminal in the client side. 370.Pp 371When the user program terminates and all forwarded X11 and other 372connections have been closed, the server sends command exit status to 373the client, and both sides exit. 374.Sh LOGIN PROCESS 375When a user successfully logs in, 376.Nm 377does the following: 378.Bl -enum -offset indent 379.It 380If the login is on a tty, and no command has been specified, 381prints last login time and 382.Pa /etc/motd 383(unless prevented in the configuration file or by 384.Pa ~/.hushlogin ; 385see the 386.Sx FILES 387section). 388.It 389If the login is on a tty, records login time. 390.It 391Checks 392.Pa /etc/nologin and 393.Pa /var/run/nologin ; 394if one exists, it prints the contents and quits 395(unless root). 396.It 397Changes to run with normal user privileges. 398.It 399Sets up basic environment. 400.It 401Reads the file 402.Pa ~/.ssh/environment , 403if it exists, and users are allowed to change their environment. 404See the 405.Cm PermitUserEnvironment 406option in 407.Xr sshd_config 5 . 408.It 409Changes to user's home directory. 410.It 411If 412.Pa ~/.ssh/rc 413exists and the 414.Xr sshd_config 5 415.Cm PermitUserRC 416option is set, runs it; else if 417.Pa /etc/ssh/sshrc 418exists, runs 419it; otherwise runs 420.Xr xauth 1 . 421The 422.Dq rc 423files are given the X11 424authentication protocol and cookie in standard input. 425See 426.Sx SSHRC , 427below. 428.It 429Runs user's shell or command. 430All commands are run under the user's login shell as specified in the 431system password database. 432.El 433.Sh SSHRC 434If the file 435.Pa ~/.ssh/rc 436exists, 437.Xr sh 1 438runs it after reading the 439environment files but before starting the user's shell or command. 440It must not produce any output on stdout; stderr must be used 441instead. 442If X11 forwarding is in use, it will receive the "proto cookie" pair in 443its standard input (and 444.Ev DISPLAY 445in its environment). 446The script must call 447.Xr xauth 1 448because 449.Nm 450will not run xauth automatically to add X11 cookies. 451.Pp 452The primary purpose of this file is to run any initialization routines 453which may be needed before the user's home directory becomes 454accessible; AFS is a particular example of such an environment. 455.Pp 456This file will probably contain some initialization code followed by 457something similar to: 458.Bd -literal -offset 3n 459if read proto cookie && [ -n "$DISPLAY" ]; then 460 if [ `echo $DISPLAY | cut -c1-10` = 'localhost:' ]; then 461 # X11UseLocalhost=yes 462 echo add unix:`echo $DISPLAY | 463 cut -c11-` $proto $cookie 464 else 465 # X11UseLocalhost=no 466 echo add $DISPLAY $proto $cookie 467 fi | xauth -q - 468fi 469.Ed 470.Pp 471If this file does not exist, 472.Pa /etc/ssh/sshrc 473is run, and if that 474does not exist either, xauth is used to add the cookie. 475.Sh AUTHORIZED_KEYS FILE FORMAT 476.Cm AuthorizedKeysFile 477specifies the files containing public keys for 478public key authentication; 479if none is specified, the default is 480.Pa ~/.ssh/authorized_keys 481and 482.Pa ~/.ssh/authorized_keys2 . 483Each line of the file contains one 484key (empty lines and lines starting with a 485.Ql # 486are ignored as 487comments). 488Protocol 1 public keys consist of the following space-separated fields: 489options, bits, exponent, modulus, comment. 490Protocol 2 public key consist of: 491options, keytype, base64-encoded key, comment. 492The options field is optional; 493its presence is determined by whether the line starts 494with a number or not (the options field never starts with a number). 495The bits, exponent, modulus, and comment fields give the RSA key for 496protocol version 1; the 497comment field is not used for anything (but may be convenient for the 498user to identify the key). 499For protocol version 2 the keytype is 500.Dq ecdsa-sha2-nistp256 , 501.Dq ecdsa-sha2-nistp384 , 502.Dq ecdsa-sha2-nistp521 , 503.Dq ssh-ed25519 , 504.Dq ssh-dss 505or 506.Dq ssh-rsa . 507.Pp 508Note that lines in this file are usually several hundred bytes long 509(because of the size of the public key encoding) up to a limit of 5108 kilobytes, which permits DSA keys up to 8 kilobits and RSA 511keys up to 16 kilobits. 512You don't want to type them in; instead, copy the 513.Pa identity.pub , 514.Pa id_dsa.pub , 515.Pa id_ecdsa.pub , 516.Pa id_ed25519.pub , 517or the 518.Pa id_rsa.pub 519file and edit it. 520.Pp 521.Nm 522enforces a minimum RSA key modulus size for protocol 1 523and protocol 2 keys of 768 bits. 524.Pp 525The options (if present) consist of comma-separated option 526specifications. 527No spaces are permitted, except within double quotes. 528The following option specifications are supported (note 529that option keywords are case-insensitive): 530.Bl -tag -width Ds 531.It Cm cert-authority 532Specifies that the listed key is a certification authority (CA) that is 533trusted to validate signed certificates for user authentication. 534.Pp 535Certificates may encode access restrictions similar to these key options. 536If both certificate restrictions and key options are present, the most 537restrictive union of the two is applied. 538.It Cm command="command" 539Specifies that the command is executed whenever this key is used for 540authentication. 541The command supplied by the user (if any) is ignored. 542The command is run on a pty if the client requests a pty; 543otherwise it is run without a tty. 544If an 8-bit clean channel is required, 545one must not request a pty or should specify 546.Cm no-pty . 547A quote may be included in the command by quoting it with a backslash. 548This option might be useful 549to restrict certain public keys to perform just a specific operation. 550An example might be a key that permits remote backups but nothing else. 551Note that the client may specify TCP and/or X11 552forwarding unless they are explicitly prohibited. 553The command originally supplied by the client is available in the 554.Ev SSH_ORIGINAL_COMMAND 555environment variable. 556Note that this option applies to shell, command or subsystem execution. 557Also note that this command may be superseded by either a 558.Xr sshd_config 5 559.Cm ForceCommand 560directive or a command embedded in a certificate. 561.It Cm environment="NAME=value" 562Specifies that the string is to be added to the environment when 563logging in using this key. 564Environment variables set this way 565override other default environment values. 566Multiple options of this type are permitted. 567Environment processing is disabled by default and is 568controlled via the 569.Cm PermitUserEnvironment 570option. 571This option is automatically disabled if 572.Cm UseLogin 573is enabled. 574.It Cm from="pattern-list" 575Specifies that in addition to public key authentication, either the canonical 576name of the remote host or its IP address must be present in the 577comma-separated list of patterns. 578See PATTERNS in 579.Xr ssh_config 5 580for more information on patterns. 581.Pp 582In addition to the wildcard matching that may be applied to hostnames or 583addresses, a 584.Cm from 585stanza may match IP addresses using CIDR address/masklen notation. 586.Pp 587The purpose of this option is to optionally increase security: public key 588authentication by itself does not trust the network or name servers or 589anything (but the key); however, if somebody somehow steals the key, the key 590permits an intruder to log in from anywhere in the world. 591This additional option makes using a stolen key more difficult (name 592servers and/or routers would have to be compromised in addition to 593just the key). 594.It Cm no-agent-forwarding 595Forbids authentication agent forwarding when this key is used for 596authentication. 597.It Cm no-port-forwarding 598Forbids TCP forwarding when this key is used for authentication. 599Any port forward requests by the client will return an error. 600This might be used, e.g. in connection with the 601.Cm command 602option. 603.It Cm no-pty 604Prevents tty allocation (a request to allocate a pty will fail). 605.It Cm no-user-rc 606Disables execution of 607.Pa ~/.ssh/rc . 608.It Cm no-X11-forwarding 609Forbids X11 forwarding when this key is used for authentication. 610Any X11 forward requests by the client will return an error. 611.It Cm permitopen="host:port" 612Limit local port forwarding with 613.Xr ssh 1 614.Fl L 615such that it may only connect to the specified host and port. 616IPv6 addresses can be specified by enclosing the address in square brackets. 617Multiple 618.Cm permitopen 619options may be applied separated by commas. 620No pattern matching is performed on the specified hostnames, 621they must be literal domains or addresses. 622A port specification of 623.Cm * 624matches any port. 625.It Cm principals="principals" 626On a 627.Cm cert-authority 628line, specifies allowed principals for certificate authentication as a 629comma-separated list. 630At least one name from the list must appear in the certificate's 631list of principals for the certificate to be accepted. 632This option is ignored for keys that are not marked as trusted certificate 633signers using the 634.Cm cert-authority 635option. 636.It Cm tunnel="n" 637Force a 638.Xr tun 4 639device on the server. 640Without this option, the next available device will be used if 641the client requests a tunnel. 642.El 643.Pp 644An example authorized_keys file: 645.Bd -literal -offset 3n 646# Comments allowed at start of line 647ssh-rsa AAAAB3Nza...LiPk== user@example.net 648from="*.sales.example.net,!pc.sales.example.net" ssh-rsa 649AAAAB2...19Q== john@example.net 650command="dump /home",no-pty,no-port-forwarding ssh-dss 651AAAAC3...51R== example.net 652permitopen="192.0.2.1:80",permitopen="192.0.2.2:25" ssh-dss 653AAAAB5...21S== 654tunnel="0",command="sh /etc/netstart tun0" ssh-rsa AAAA...== 655jane@example.net 656.Ed 657.Sh SSH_KNOWN_HOSTS FILE FORMAT 658The 659.Pa /etc/ssh/ssh_known_hosts 660and 661.Pa ~/.ssh/known_hosts 662files contain host public keys for all known hosts. 663The global file should 664be prepared by the administrator (optional), and the per-user file is 665maintained automatically: whenever the user connects from an unknown host, 666its key is added to the per-user file. 667.Pp 668Each line in these files contains the following fields: markers (optional), 669hostnames, bits, exponent, modulus, comment. 670The fields are separated by spaces. 671.Pp 672The marker is optional, but if it is present then it must be one of 673.Dq @cert-authority , 674to indicate that the line contains a certification authority (CA) key, 675or 676.Dq @revoked , 677to indicate that the key contained on the line is revoked and must not ever 678be accepted. 679Only one marker should be used on a key line. 680.Pp 681Hostnames is a comma-separated list of patterns 682.Pf ( Ql * 683and 684.Ql \&? 685act as 686wildcards); each pattern in turn is matched against the canonical host 687name (when authenticating a client) or against the user-supplied 688name (when authenticating a server). 689A pattern may also be preceded by 690.Ql \&! 691to indicate negation: if the host name matches a negated 692pattern, it is not accepted (by that line) even if it matched another 693pattern on the line. 694A hostname or address may optionally be enclosed within 695.Ql \&[ 696and 697.Ql \&] 698brackets then followed by 699.Ql \&: 700and a non-standard port number. 701.Pp 702Alternately, hostnames may be stored in a hashed form which hides host names 703and addresses should the file's contents be disclosed. 704Hashed hostnames start with a 705.Ql | 706character. 707Only one hashed hostname may appear on a single line and none of the above 708negation or wildcard operators may be applied. 709.Pp 710Bits, exponent, and modulus are taken directly from the RSA host key; they 711can be obtained, for example, from 712.Pa /etc/ssh/ssh_host_key.pub . 713The optional comment field continues to the end of the line, and is not used. 714.Pp 715Lines starting with 716.Ql # 717and empty lines are ignored as comments. 718.Pp 719When performing host authentication, authentication is accepted if any 720matching line has the proper key; either one that matches exactly or, 721if the server has presented a certificate for authentication, the key 722of the certification authority that signed the certificate. 723For a key to be trusted as a certification authority, it must use the 724.Dq @cert-authority 725marker described above. 726.Pp 727The known hosts file also provides a facility to mark keys as revoked, 728for example when it is known that the associated private key has been 729stolen. 730Revoked keys are specified by including the 731.Dq @revoked 732marker at the beginning of the key line, and are never accepted for 733authentication or as certification authorities, but instead will 734produce a warning from 735.Xr ssh 1 736when they are encountered. 737.Pp 738It is permissible (but not 739recommended) to have several lines or different host keys for the same 740names. 741This will inevitably happen when short forms of host names 742from different domains are put in the file. 743It is possible 744that the files contain conflicting information; authentication is 745accepted if valid information can be found from either file. 746.Pp 747Note that the lines in these files are typically hundreds of characters 748long, and you definitely don't want to type in the host keys by hand. 749Rather, generate them by a script, 750.Xr ssh-keyscan 1 751or by taking 752.Pa /etc/ssh/ssh_host_key.pub 753and adding the host names at the front. 754.Xr ssh-keygen 1 755also offers some basic automated editing for 756.Pa ~/.ssh/known_hosts 757including removing hosts matching a host name and converting all host 758names to their hashed representations. 759.Pp 760An example ssh_known_hosts file: 761.Bd -literal -offset 3n 762# Comments allowed at start of line 763closenet,...,192.0.2.53 1024 37 159...93 closenet.example.net 764cvs.example.net,192.0.2.10 ssh-rsa AAAA1234.....= 765# A hashed hostname 766|1|JfKTdBh7rNbXkVAQCRp4OQoPfmI=|USECr3SWf1JUPsms5AqfD5QfxkM= ssh-rsa 767AAAA1234.....= 768# A revoked key 769@revoked * ssh-rsa AAAAB5W... 770# A CA key, accepted for any host in *.mydomain.com or *.mydomain.org 771@cert-authority *.mydomain.org,*.mydomain.com ssh-rsa AAAAB5W... 772.Ed 773.Sh FILES 774.Bl -tag -width Ds -compact 775.It Pa ~/.hushlogin 776This file is used to suppress printing the last login time and 777.Pa /etc/motd , 778if 779.Cm PrintLastLog 780and 781.Cm PrintMotd , 782respectively, 783are enabled. 784It does not suppress printing of the banner specified by 785.Cm Banner . 786.Pp 787.It Pa ~/.rhosts 788This file is used for host-based authentication (see 789.Xr ssh 1 790for more information). 791On some machines this file may need to be 792world-readable if the user's home directory is on an NFS partition, 793because 794.Nm 795reads it as root. 796Additionally, this file must be owned by the user, 797and must not have write permissions for anyone else. 798The recommended 799permission for most machines is read/write for the user, and not 800accessible by others. 801.Pp 802.It Pa ~/.shosts 803This file is used in exactly the same way as 804.Pa .rhosts , 805but allows host-based authentication without permitting login with 806rlogin/rsh. 807.Pp 808.It Pa ~/.ssh/ 809This directory is the default location for all user-specific configuration 810and authentication information. 811There is no general requirement to keep the entire contents of this directory 812secret, but the recommended permissions are read/write/execute for the user, 813and not accessible by others. 814.Pp 815.It Pa ~/.ssh/authorized_keys 816Lists the public keys (DSA, ECDSA, Ed25519, RSA) 817that can be used for logging in as this user. 818The format of this file is described above. 819The content of the file is not highly sensitive, but the recommended 820permissions are read/write for the user, and not accessible by others. 821.Pp 822If this file, the 823.Pa ~/.ssh 824directory, or the user's home directory are writable 825by other users, then the file could be modified or replaced by unauthorized 826users. 827In this case, 828.Nm 829will not allow it to be used unless the 830.Cm StrictModes 831option has been set to 832.Dq no . 833.Pp 834.It Pa ~/.ssh/environment 835This file is read into the environment at login (if it exists). 836It can only contain empty lines, comment lines (that start with 837.Ql # ) , 838and assignment lines of the form name=value. 839The file should be writable 840only by the user; it need not be readable by anyone else. 841Environment processing is disabled by default and is 842controlled via the 843.Cm PermitUserEnvironment 844option. 845.Pp 846.It Pa ~/.ssh/known_hosts 847Contains a list of host keys for all hosts the user has logged into 848that are not already in the systemwide list of known host keys. 849The format of this file is described above. 850This file should be writable only by root/the owner and 851can, but need not be, world-readable. 852.Pp 853.It Pa ~/.ssh/rc 854Contains initialization routines to be run before 855the user's home directory becomes accessible. 856This file should be writable only by the user, and need not be 857readable by anyone else. 858.Pp 859.It Pa /etc/hosts.allow 860.It Pa /etc/hosts.deny 861Access controls that should be enforced by tcp-wrappers are defined here. 862Further details are described in 863.Xr hosts_access 5 . 864.Pp 865.It Pa /etc/hosts.equiv 866This file is for host-based authentication (see 867.Xr ssh 1 ) . 868It should only be writable by root. 869.Pp 870.It Pa /etc/moduli 871Contains Diffie-Hellman groups used for the "Diffie-Hellman Group Exchange". 872The file format is described in 873.Xr moduli 5 . 874.Pp 875.It Pa /etc/motd 876See 877.Xr motd 5 . 878.Pp 879.It Pa /etc/nologin 880If this file exists, 881.Nm 882refuses to let anyone except root log in. 883The contents of the file 884are displayed to anyone trying to log in, and non-root connections are 885refused. 886The file should be world-readable. 887.Pp 888.It Pa /etc/shosts.equiv 889This file is used in exactly the same way as 890.Pa hosts.equiv , 891but allows host-based authentication without permitting login with 892rlogin/rsh. 893.Pp 894.It Pa /etc/ssh/ssh_host_key 895.It Pa /etc/ssh/ssh_host_dsa_key 896.It Pa /etc/ssh/ssh_host_ecdsa_key 897.It Pa /etc/ssh/ssh_host_ed25519_key 898.It Pa /etc/ssh/ssh_host_rsa_key 899These files contain the private parts of the host keys. 900These files should only be owned by root, readable only by root, and not 901accessible to others. 902Note that 903.Nm 904does not start if these files are group/world-accessible. 905.Pp 906.It Pa /etc/ssh/ssh_host_key.pub 907.It Pa /etc/ssh/ssh_host_dsa_key.pub 908.It Pa /etc/ssh/ssh_host_ecdsa_key.pub 909.It Pa /etc/ssh/ssh_host_ed25519_key.pub 910.It Pa /etc/ssh/ssh_host_rsa_key.pub 911These files contain the public parts of the host keys. 912These files should be world-readable but writable only by 913root. 914Their contents should match the respective private parts. 915These files are not 916really used for anything; they are provided for the convenience of 917the user so their contents can be copied to known hosts files. 918These files are created using 919.Xr ssh-keygen 1 . 920.Pp 921.It Pa /etc/ssh/ssh_known_hosts 922Systemwide list of known host keys. 923This file should be prepared by the 924system administrator to contain the public host keys of all machines in the 925organization. 926The format of this file is described above. 927This file should be writable only by root/the owner and 928should be world-readable. 929.Pp 930.It Pa /etc/ssh/sshd_config 931Contains configuration data for 932.Nm sshd . 933The file format and configuration options are described in 934.Xr sshd_config 5 . 935.Pp 936.It Pa /etc/ssh/sshrc 937Similar to 938.Pa ~/.ssh/rc , 939it can be used to specify 940machine-specific login-time initializations globally. 941This file should be writable only by root, and should be world-readable. 942.Pp 943.It Pa /var/empty 944.Xr chroot 2 945directory used by 946.Nm 947during privilege separation in the pre-authentication phase. 948The directory should not contain any files and must be owned by root 949and not group or world-writable. 950.Pp 951.It Pa /var/run/sshd.pid 952Contains the process ID of the 953.Nm 954listening for connections (if there are several daemons running 955concurrently for different ports, this contains the process ID of the one 956started last). 957The content of this file is not sensitive; it can be world-readable. 958.El 959.Sh SEE ALSO 960.Xr scp 1 , 961.Xr sftp 1 , 962.Xr ssh 1 , 963.Xr ssh-add 1 , 964.Xr ssh-agent 1 , 965.Xr ssh-keygen 1 , 966.Xr ssh-keyscan 1 , 967.Xr chroot 2 , 968.Xr hosts_access 5 , 969.Xr login.conf 5 , 970.Xr moduli 5 , 971.Xr sshd_config 5 , 972.Xr inetd 8 , 973.Xr sftp-server 8 974.Sh AUTHORS 975OpenSSH is a derivative of the original and free 976ssh 1.2.12 release by Tatu Ylonen. 977Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos, 978Theo de Raadt and Dug Song 979removed many bugs, re-added newer features and 980created OpenSSH. 981Markus Friedl contributed the support for SSH 982protocol versions 1.5 and 2.0. 983Niels Provos and Markus Friedl contributed support 984for privilege separation. 985