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