sshd.0 revision 204861
1180740SdesSSHD(8) OpenBSD System Manager's Manual SSHD(8) 2180740Sdes 3180740SdesNAME 4180740Sdes sshd - OpenSSH SSH daemon 5180740Sdes 6180740SdesSYNOPSIS 7204861Sdes sshd [-46DdeiqTt] [-b bits] [-C connection_spec] 8204861Sdes [-c host_certificate_file] [-f config_file] [-g login_grace_time] 9204861Sdes [-h host_key_file] [-k key_gen_time] [-o option] [-p port] [-u len] 10180740Sdes 11180740SdesDESCRIPTION 12180740Sdes sshd (OpenSSH Daemon) is the daemon program for ssh(1). Together these 13180744Sdes programs replace rlogin(1) and rsh(1), and provide secure encrypted com- 14180744Sdes munications between two untrusted hosts over an insecure network. 15180740Sdes 16180740Sdes sshd listens for connections from clients. It is normally started at 17180740Sdes boot from /etc/rc. It forks a new daemon for each incoming connection. 18180740Sdes The forked daemons handle key exchange, encryption, authentication, com- 19180740Sdes mand execution, and data exchange. 20180740Sdes 21180740Sdes sshd can be configured using command-line options or a configuration file 22180740Sdes (by default sshd_config(5)); command-line options override values speci- 23180740Sdes fied in the configuration file. sshd rereads its configuration file when 24180740Sdes it receives a hangup signal, SIGHUP, by executing itself with the name 25180740Sdes and options it was started with, e.g. /usr/sbin/sshd. 26180740Sdes 27180740Sdes The options are as follows: 28180740Sdes 29180740Sdes -4 Forces sshd to use IPv4 addresses only. 30180740Sdes 31180740Sdes -6 Forces sshd to use IPv6 addresses only. 32180740Sdes 33180740Sdes -b bits 34180740Sdes Specifies the number of bits in the ephemeral protocol version 1 35180750Sdes server key (default 1024). 36180740Sdes 37180750Sdes -C connection_spec 38180750Sdes Specify the connection parameters to use for the -T extended test 39180750Sdes mode. If provided, any Match directives in the configuration 40180750Sdes file that would apply to the specified user, host, and address 41180750Sdes will be set before the configuration is written to standard out- 42180750Sdes put. The connection parameters are supplied as keyword=value 43180750Sdes pairs. The keywords are ``user'', ``host'', and ``addr''. All 44180750Sdes are required and may be supplied in any order, either with multi- 45180750Sdes ple -C options or as a comma-separated list. 46180750Sdes 47204861Sdes -c host_certificate_file 48204861Sdes Specifies a path to a certificate file to identify sshd during 49204861Sdes key exchange. The certificate file must match a host key file 50204861Sdes specified using the -h option or the HostKey configuration direc- 51204861Sdes tive. 52204861Sdes 53180740Sdes -D When this option is specified, sshd will not detach and does not 54180740Sdes become a daemon. This allows easy monitoring of sshd. 55180740Sdes 56204861Sdes -d Debug mode. The server sends verbose debug output to standard 57204861Sdes error, and does not put itself in the background. The server al- 58204861Sdes so will not fork and will only process one connection. This op- 59204861Sdes tion is only intended for debugging for the server. Multiple -d 60204861Sdes options increase the debugging level. Maximum is 3. 61180740Sdes 62180740Sdes -e When this option is specified, sshd will send the output to the 63180740Sdes standard error instead of the system log. 64180740Sdes 65180744Sdes -f config_file 66180740Sdes Specifies the name of the configuration file. The default is 67180740Sdes /etc/ssh/sshd_config. sshd refuses to start if there is no con- 68180740Sdes figuration file. 69180740Sdes 70180740Sdes -g login_grace_time 71180740Sdes Gives the grace time for clients to authenticate themselves (de- 72180740Sdes fault 120 seconds). If the client fails to authenticate the user 73180740Sdes within this many seconds, the server disconnects and exits. A 74180740Sdes value of zero indicates no limit. 75180740Sdes 76180740Sdes -h host_key_file 77180740Sdes Specifies a file from which a host key is read. This option must 78180740Sdes be given if sshd is not run as root (as the normal host key files 79180740Sdes are normally not readable by anyone but root). The default is 80180740Sdes /etc/ssh/ssh_host_key for protocol version 1, and 81180740Sdes /etc/ssh/ssh_host_rsa_key and /etc/ssh/ssh_host_dsa_key for pro- 82180740Sdes tocol version 2. It is possible to have multiple host key files 83180740Sdes for the different protocol versions and host key algorithms. 84180740Sdes 85180740Sdes -i Specifies that sshd is being run from inetd(8). sshd is normally 86180740Sdes not run from inetd because it needs to generate the server key 87180740Sdes before it can respond to the client, and this may take tens of 88180740Sdes seconds. Clients would have to wait too long if the key was re- 89180740Sdes generated every time. However, with small key sizes (e.g. 512) 90180740Sdes using sshd from inetd may be feasible. 91180740Sdes 92180740Sdes -k key_gen_time 93180740Sdes Specifies how often the ephemeral protocol version 1 server key 94180740Sdes is regenerated (default 3600 seconds, or one hour). The motiva- 95180740Sdes tion for regenerating the key fairly often is that the key is not 96180740Sdes stored anywhere, and after about an hour it becomes impossible to 97180740Sdes recover the key for decrypting intercepted communications even if 98180740Sdes the machine is cracked into or physically seized. A value of ze- 99180740Sdes ro indicates that the key will never be regenerated. 100180740Sdes 101180740Sdes -o option 102180740Sdes Can be used to give options in the format used in the configura- 103180740Sdes tion file. This is useful for specifying options for which there 104180740Sdes is no separate command-line flag. For full details of the op- 105180740Sdes tions, and their values, see sshd_config(5). 106180740Sdes 107180740Sdes -p port 108180740Sdes Specifies the port on which the server listens for connections 109180740Sdes (default 22). Multiple port options are permitted. Ports speci- 110180740Sdes fied in the configuration file with the Port option are ignored 111180740Sdes when a command-line port is specified. Ports specified using the 112180740Sdes ListenAddress option override command-line ports. 113180740Sdes 114180740Sdes -q Quiet mode. Nothing is sent to the system log. Normally the be- 115180740Sdes ginning, authentication, and termination of each connection is 116180740Sdes logged. 117180740Sdes 118180750Sdes -T Extended test mode. Check the validity of the configuration 119180750Sdes file, output the effective configuration to stdout and then exit. 120180750Sdes Optionally, Match rules may be applied by specifying the connec- 121180750Sdes tion parameters using one or more -C options. 122180750Sdes 123180740Sdes -t Test mode. Only check the validity of the configuration file and 124180740Sdes sanity of the keys. This is useful for updating sshd reliably as 125180740Sdes configuration options may change. 126180740Sdes 127180740Sdes -u len This option is used to specify the size of the field in the utmp 128180740Sdes structure that holds the remote host name. If the resolved host 129180740Sdes name is longer than len, the dotted decimal value will be used 130180740Sdes instead. This allows hosts with very long host names that over- 131180740Sdes flow this field to still be uniquely identified. Specifying -u0 132180740Sdes indicates that only dotted decimal addresses should be put into 133180740Sdes the utmp file. -u0 may also be used to prevent sshd from making 134180740Sdes DNS requests unless the authentication mechanism or configuration 135180740Sdes requires it. Authentication mechanisms that may require DNS in- 136180740Sdes clude RhostsRSAAuthentication, HostbasedAuthentication, and using 137180740Sdes a from="pattern-list" option in a key file. Configuration op- 138180740Sdes tions that require DNS include using a USER@HOST pattern in 139180740Sdes AllowUsers or DenyUsers. 140180740Sdes 141180740SdesAUTHENTICATION 142204861Sdes The OpenSSH SSH daemon supports SSH protocols 1 and 2. The default is to 143204861Sdes use protocol 2 only, though this can be changed via the Protocol option 144204861Sdes in sshd_config(5). Protocol 2 supports both RSA and DSA keys; protocol 1 145204861Sdes only supports RSA keys. For both protocols, each host has a host-specif- 146204861Sdes ic key, normally 2048 bits, used to identify the host. 147180740Sdes 148180740Sdes Forward security for protocol 1 is provided through an additional server 149180740Sdes key, normally 768 bits, generated when the server starts. This key is 150180740Sdes normally regenerated every hour if it has been used, and is never stored 151180740Sdes on disk. Whenever a client connects, the daemon responds with its public 152180740Sdes host and server keys. The client compares the RSA host key against its 153180740Sdes own database to verify that it has not changed. The client then gener- 154180740Sdes ates a 256-bit random number. It encrypts this random number using both 155180740Sdes the host key and the server key, and sends the encrypted number to the 156180740Sdes server. Both sides then use this random number as a session key which is 157180740Sdes used to encrypt all further communications in the session. The rest of 158180740Sdes the session is encrypted using a conventional cipher, currently Blowfish 159180740Sdes or 3DES, with 3DES being used by default. The client selects the encryp- 160180740Sdes tion algorithm to use from those offered by the server. 161180740Sdes 162180740Sdes For protocol 2, forward security is provided through a Diffie-Hellman key 163180740Sdes agreement. This key agreement results in a shared session key. The rest 164180740Sdes of the session is encrypted using a symmetric cipher, currently 128-bit 165180740Sdes AES, Blowfish, 3DES, CAST128, Arcfour, 192-bit AES, or 256-bit AES. The 166180740Sdes client selects the encryption algorithm to use from those offered by the 167180740Sdes server. Additionally, session integrity is provided through a crypto- 168180744Sdes graphic message authentication code (hmac-md5, hmac-sha1, umac-64 or 169180744Sdes hmac-ripemd160). 170180740Sdes 171180740Sdes Finally, the server and the client enter an authentication dialog. The 172180740Sdes client tries to authenticate itself using host-based authentication, pub- 173180740Sdes lic key authentication, challenge-response authentication, or password 174180740Sdes authentication. 175180740Sdes 176180740Sdes Regardless of the authentication type, the account is checked to ensure 177180740Sdes that it is accessible. An account is not accessible if it is locked, 178180740Sdes listed in DenyUsers or its group is listed in DenyGroups . The defini- 179180740Sdes tion of a locked account is system dependant. Some platforms have their 180180740Sdes own account database (eg AIX) and some modify the passwd field ( `*LK*' 181180740Sdes on Solaris and UnixWare, `*' on HP-UX, containing `Nologin' on Tru64, a 182180744Sdes leading `*LOCKED*' on FreeBSD and a leading `!' on most Linuxes). If 183180744Sdes there is a requirement to disable password authentication for the account 184180744Sdes while allowing still public-key, then the passwd field should be set to 185180744Sdes something other than these values (eg `NP' or `*NP*' ). 186180740Sdes 187180740Sdes If the client successfully authenticates itself, a dialog for preparing 188180740Sdes the session is entered. At this time the client may request things like 189180740Sdes allocating a pseudo-tty, forwarding X11 connections, forwarding TCP con- 190180740Sdes nections, or forwarding the authentication agent connection over the se- 191180740Sdes cure channel. 192180740Sdes 193180740Sdes After this, the client either requests a shell or execution of a command. 194180740Sdes The sides then enter session mode. In this mode, either side may send 195180740Sdes data at any time, and such data is forwarded to/from the shell or command 196180740Sdes on the server side, and the user terminal in the client side. 197180740Sdes 198180740Sdes When the user program terminates and all forwarded X11 and other connec- 199180740Sdes tions have been closed, the server sends command exit status to the 200180740Sdes client, and both sides exit. 201180740Sdes 202180740SdesLOGIN PROCESS 203180740Sdes When a user successfully logs in, sshd does the following: 204180740Sdes 205180740Sdes 1. If the login is on a tty, and no command has been specified, 206180740Sdes prints last login time and /etc/motd (unless prevented in the 207180740Sdes configuration file or by ~/.hushlogin; see the FILES section). 208180740Sdes 209180740Sdes 2. If the login is on a tty, records login time. 210180740Sdes 211180740Sdes 3. Checks /etc/nologin; if it exists, prints contents and quits 212180740Sdes (unless root). 213180740Sdes 214180740Sdes 4. Changes to run with normal user privileges. 215180740Sdes 216180740Sdes 5. Sets up basic environment. 217180740Sdes 218180740Sdes 6. Reads the file ~/.ssh/environment, if it exists, and users are 219180740Sdes allowed to change their environment. See the 220180740Sdes PermitUserEnvironment option in sshd_config(5). 221180740Sdes 222180740Sdes 7. Changes to user's home directory. 223180740Sdes 224180740Sdes 8. If ~/.ssh/rc exists, runs it; else if /etc/ssh/sshrc exists, 225180740Sdes runs it; otherwise runs xauth. The ``rc'' files are given the 226180740Sdes X11 authentication protocol and cookie in standard input. See 227180740Sdes SSHRC, below. 228180740Sdes 229180740Sdes 9. Runs user's shell or command. 230180740Sdes 231180740SdesSSHRC 232180740Sdes If the file ~/.ssh/rc exists, sh(1) runs it after reading the environment 233180740Sdes files but before starting the user's shell or command. It must not pro- 234180740Sdes duce any output on stdout; stderr must be used instead. If X11 forward- 235180740Sdes ing is in use, it will receive the "proto cookie" pair in its standard 236180740Sdes input (and DISPLAY in its environment). The script must call xauth(1) 237180740Sdes because sshd will not run xauth automatically to add X11 cookies. 238180740Sdes 239180740Sdes The primary purpose of this file is to run any initialization routines 240180740Sdes which may be needed before the user's home directory becomes accessible; 241180740Sdes AFS is a particular example of such an environment. 242180740Sdes 243180740Sdes This file will probably contain some initialization code followed by 244180740Sdes something similar to: 245180740Sdes 246180740Sdes if read proto cookie && [ -n "$DISPLAY" ]; then 247180740Sdes if [ `echo $DISPLAY | cut -c1-10` = 'localhost:' ]; then 248180740Sdes # X11UseLocalhost=yes 249180740Sdes echo add unix:`echo $DISPLAY | 250180740Sdes cut -c11-` $proto $cookie 251180740Sdes else 252180740Sdes # X11UseLocalhost=no 253180740Sdes echo add $DISPLAY $proto $cookie 254180740Sdes fi | xauth -q - 255180740Sdes fi 256180740Sdes 257180740Sdes If this file does not exist, /etc/ssh/sshrc is run, and if that does not 258180740Sdes exist either, xauth is used to add the cookie. 259180740Sdes 260180740SdesAUTHORIZED_KEYS FILE FORMAT 261180740Sdes AuthorizedKeysFile specifies the file containing public keys for public 262180740Sdes key authentication; if none is specified, the default is 263180740Sdes ~/.ssh/authorized_keys. Each line of the file contains one key (empty 264180740Sdes lines and lines starting with a `#' are ignored as comments). Protocol 1 265180740Sdes public keys consist of the following space-separated fields: options, 266180740Sdes bits, exponent, modulus, comment. Protocol 2 public key consist of: op- 267180740Sdes tions, keytype, base64-encoded key, comment. The options field is op- 268180740Sdes tional; its presence is determined by whether the line starts with a num- 269180740Sdes ber or not (the options field never starts with a number). The bits, ex- 270180740Sdes ponent, modulus, and comment fields give the RSA key for protocol version 271180740Sdes 1; the comment field is not used for anything (but may be convenient for 272180740Sdes the user to identify the key). For protocol version 2 the keytype is 273180740Sdes ``ssh-dss'' or ``ssh-rsa''. 274180740Sdes 275180740Sdes Note that lines in this file are usually several hundred bytes long (be- 276180740Sdes cause of the size of the public key encoding) up to a limit of 8 kilo- 277180740Sdes bytes, which permits DSA keys up to 8 kilobits and RSA keys up to 16 278180740Sdes kilobits. You don't want to type them in; instead, copy the 279180740Sdes identity.pub, id_dsa.pub, or the id_rsa.pub file and edit it. 280180740Sdes 281180740Sdes sshd enforces a minimum RSA key modulus size for protocol 1 and protocol 282180740Sdes 2 keys of 768 bits. 283180740Sdes 284180740Sdes The options (if present) consist of comma-separated option specifica- 285180740Sdes tions. No spaces are permitted, except within double quotes. The fol- 286180740Sdes lowing option specifications are supported (note that option keywords are 287180740Sdes case-insensitive): 288180740Sdes 289204861Sdes cert-authority 290204861Sdes Specifies that the listed key is a certification authority (CA) 291204861Sdes that is trusted to validate signed certificates for user authen- 292204861Sdes tication. 293204861Sdes 294204861Sdes Certificates may encode access restrictions similar to these key 295204861Sdes options. If both certificate restrictions and key options are 296204861Sdes present, the most restrictive union of the two is applied. 297204861Sdes 298180740Sdes command="command" 299180740Sdes Specifies that the command is executed whenever this key is used 300180740Sdes for authentication. The command supplied by the user (if any) is 301180740Sdes ignored. The command is run on a pty if the client requests a 302180740Sdes pty; otherwise it is run without a tty. If an 8-bit clean chan- 303180740Sdes nel is required, one must not request a pty or should specify no- 304180740Sdes pty. A quote may be included in the command by quoting it with a 305180740Sdes backslash. This option might be useful to restrict certain pub- 306180740Sdes lic keys to perform just a specific operation. An example might 307180740Sdes be a key that permits remote backups but nothing else. Note that 308180740Sdes the client may specify TCP and/or X11 forwarding unless they are 309180740Sdes explicitly prohibited. The command originally supplied by the 310180740Sdes client is available in the SSH_ORIGINAL_COMMAND environment vari- 311180740Sdes able. Note that this option applies to shell, command or subsys- 312204861Sdes tem execution. Also note that this command may be superseded by 313204861Sdes either a sshd_config(5) ForceCommand directive or a command em- 314204861Sdes bedded in a certificate. 315180740Sdes 316180740Sdes environment="NAME=value" 317180740Sdes Specifies that the string is to be added to the environment when 318180740Sdes logging in using this key. Environment variables set this way 319180740Sdes override other default environment values. Multiple options of 320180740Sdes this type are permitted. Environment processing is disabled by 321180740Sdes default and is controlled via the PermitUserEnvironment option. 322180740Sdes This option is automatically disabled if UseLogin is enabled. 323180740Sdes 324180740Sdes from="pattern-list" 325180750Sdes Specifies that in addition to public key authentication, either 326180750Sdes the canonical name of the remote host or its IP address must be 327180750Sdes present in the comma-separated list of patterns. See PATTERNS in 328180750Sdes ssh_config(5) for more information on patterns. 329180740Sdes 330180750Sdes In addition to the wildcard matching that may be applied to host- 331197670Sdes names or addresses, a from stanza may match IP addresses using 332180750Sdes CIDR address/masklen notation. 333180740Sdes 334180750Sdes The purpose of this option is to optionally increase security: 335180750Sdes public key authentication by itself does not trust the network or 336180750Sdes name servers or anything (but the key); however, if somebody 337180750Sdes somehow steals the key, the key permits an intruder to log in 338180750Sdes from anywhere in the world. This additional option makes using a 339180750Sdes stolen key more difficult (name servers and/or routers would have 340180750Sdes to be compromised in addition to just the key). 341180750Sdes 342180740Sdes no-agent-forwarding 343180740Sdes Forbids authentication agent forwarding when this key is used for 344180740Sdes authentication. 345180740Sdes 346180740Sdes no-port-forwarding 347180740Sdes Forbids TCP forwarding when this key is used for authentication. 348180740Sdes Any port forward requests by the client will return an error. 349180740Sdes This might be used, e.g. in connection with the command option. 350180740Sdes 351180740Sdes no-pty Prevents tty allocation (a request to allocate a pty will fail). 352180740Sdes 353180746Sdes no-user-rc 354180746Sdes Disables execution of ~/.ssh/rc. 355180746Sdes 356180740Sdes no-X11-forwarding 357180740Sdes Forbids X11 forwarding when this key is used for authentication. 358180740Sdes Any X11 forward requests by the client will return an error. 359180740Sdes 360180740Sdes permitopen="host:port" 361180740Sdes Limit local ``ssh -L'' port forwarding such that it may only con- 362180740Sdes nect to the specified host and port. IPv6 addresses can be spec- 363180740Sdes ified with an alternative syntax: host/port. Multiple permitopen 364180740Sdes options may be applied separated by commas. No pattern matching 365180740Sdes is performed on the specified hostnames, they must be literal do- 366180740Sdes mains or addresses. 367180740Sdes 368180740Sdes tunnel="n" 369180740Sdes Force a tun(4) device on the server. Without this option, the 370180740Sdes next available device will be used if the client requests a tun- 371180740Sdes nel. 372180740Sdes 373180740Sdes An example authorized_keys file: 374180740Sdes 375180740Sdes # Comments allowed at start of line 376180740Sdes ssh-rsa AAAAB3Nza...LiPk== user@example.net 377180740Sdes from="*.sales.example.net,!pc.sales.example.net" ssh-rsa 378180740Sdes AAAAB2...19Q== john@example.net 379180740Sdes command="dump /home",no-pty,no-port-forwarding ssh-dss 380180740Sdes AAAAC3...51R== example.net 381180740Sdes permitopen="192.0.2.1:80",permitopen="192.0.2.2:25" ssh-dss 382180740Sdes AAAAB5...21S== 383180740Sdes tunnel="0",command="sh /etc/netstart tun0" ssh-rsa AAAA...== 384180740Sdes jane@example.net 385180740Sdes 386180740SdesSSH_KNOWN_HOSTS FILE FORMAT 387180740Sdes The /etc/ssh/ssh_known_hosts and ~/.ssh/known_hosts files contain host 388180740Sdes public keys for all known hosts. The global file should be prepared by 389180740Sdes the administrator (optional), and the per-user file is maintained auto- 390180740Sdes matically: whenever the user connects from an unknown host, its key is 391180740Sdes added to the per-user file. 392180740Sdes 393204861Sdes Each line in these files contains the following fields: markers (option- 394204861Sdes al), hostnames, bits, exponent, modulus, comment. The fields are sepa- 395204861Sdes rated by spaces. 396180740Sdes 397204861Sdes The marker is optional, but if it is present then it must be one of 398204861Sdes ``@cert-authority'', to indicate that the line contains a certification 399204861Sdes authority (CA) key, or ``@revoked'', to indicate that the key contained 400204861Sdes on the line is revoked and must not ever be accepted. Only one marker 401204861Sdes should be used on a key line. 402204861Sdes 403180740Sdes Hostnames is a comma-separated list of patterns (`*' and `?' act as wild- 404180740Sdes cards); each pattern in turn is matched against the canonical host name 405180740Sdes (when authenticating a client) or against the user-supplied name (when 406180740Sdes authenticating a server). A pattern may also be preceded by `!' to indi- 407180740Sdes cate negation: if the host name matches a negated pattern, it is not ac- 408180740Sdes cepted (by that line) even if it matched another pattern on the line. A 409180740Sdes hostname or address may optionally be enclosed within `[' and `]' brack- 410180740Sdes ets then followed by `:' and a non-standard port number. 411180740Sdes 412180740Sdes Alternately, hostnames may be stored in a hashed form which hides host 413180740Sdes names and addresses should the file's contents be disclosed. Hashed 414180740Sdes hostnames start with a `|' character. Only one hashed hostname may ap- 415180740Sdes pear on a single line and none of the above negation or wildcard opera- 416180740Sdes tors may be applied. 417180740Sdes 418180740Sdes Bits, exponent, and modulus are taken directly from the RSA host key; 419180740Sdes they can be obtained, for example, from /etc/ssh/ssh_host_key.pub. The 420180740Sdes optional comment field continues to the end of the line, and is not used. 421180740Sdes 422180740Sdes Lines starting with `#' and empty lines are ignored as comments. 423180740Sdes 424180740Sdes When performing host authentication, authentication is accepted if any 425204861Sdes matching line has the proper key; either one that matches exactly or, if 426204861Sdes the server has presented a certificate for authentication, the key of the 427204861Sdes certification authority that signed the certificate. For a key to be 428204861Sdes trusted as a certification authority, it must use the ``@cert-authority'' 429204861Sdes marker described above. 430180740Sdes 431204861Sdes The known hosts file also provides a facility to mark keys as revoked, 432204861Sdes for example when it is known that the associated private key has been 433204861Sdes stolen. Revoked keys are specified by including the ``@revoked'' marker 434204861Sdes at the beginning of the key line, and are never accepted for authentica- 435204861Sdes tion or as certification authorities, but instead will produce a warning 436204861Sdes from ssh(1) when they are encountered. 437204861Sdes 438204861Sdes It is permissible (but not recommended) to have several lines or differ- 439204861Sdes ent host keys for the same names. This will inevitably happen when short 440204861Sdes forms of host names from different domains are put in the file. It is 441204861Sdes possible that the files contain conflicting information; authentication 442204861Sdes is accepted if valid information can be found from either file. 443204861Sdes 444180740Sdes Note that the lines in these files are typically hundreds of characters 445180740Sdes long, and you definitely don't want to type in the host keys by hand. 446204861Sdes Rather, generate them by a script, ssh-keyscan(1) or by taking 447204861Sdes /etc/ssh/ssh_host_key.pub and adding the host names at the front. 448204861Sdes ssh-keygen(1) also offers some basic automated editing for 449204861Sdes ~/.ssh/known_hosts including removing hosts matching a host name and con- 450204861Sdes verting all host names to their hashed representations. 451180740Sdes 452180740Sdes An example ssh_known_hosts file: 453180740Sdes 454180740Sdes # Comments allowed at start of line 455180740Sdes closenet,...,192.0.2.53 1024 37 159...93 closenet.example.net 456180740Sdes cvs.example.net,192.0.2.10 ssh-rsa AAAA1234.....= 457180740Sdes # A hashed hostname 458180740Sdes |1|JfKTdBh7rNbXkVAQCRp4OQoPfmI=|USECr3SWf1JUPsms5AqfD5QfxkM= ssh-rsa 459180740Sdes AAAA1234.....= 460204861Sdes # A revoked key 461204861Sdes @revoked * ssh-rsa AAAAB5W... 462204861Sdes # A CA key, accepted for any host in *.mydomain.com or *.mydomain.org 463204861Sdes @cert-authority *.mydomain.org,*.mydomain.com ssh-rsa AAAAB5W... 464180740Sdes 465180740SdesFILES 466180740Sdes ~/.hushlogin 467180740Sdes This file is used to suppress printing the last login time and 468180740Sdes /etc/motd, if PrintLastLog and PrintMotd, respectively, are en- 469180740Sdes abled. It does not suppress printing of the banner specified by 470180740Sdes Banner. 471180740Sdes 472180740Sdes ~/.rhosts 473180740Sdes This file is used for host-based authentication (see ssh(1) for 474180740Sdes more information). On some machines this file may need to be 475180740Sdes world-readable if the user's home directory is on an NFS parti- 476180740Sdes tion, because sshd reads it as root. Additionally, this file 477180740Sdes must be owned by the user, and must not have write permissions 478180740Sdes for anyone else. The recommended permission for most machines is 479180740Sdes read/write for the user, and not accessible by others. 480180740Sdes 481180740Sdes ~/.shosts 482180740Sdes This file is used in exactly the same way as .rhosts, but allows 483180740Sdes host-based authentication without permitting login with 484180740Sdes rlogin/rsh. 485180740Sdes 486180746Sdes ~/.ssh/ 487180746Sdes This directory is the default location for all user-specific con- 488180746Sdes figuration and authentication information. There is no general 489180746Sdes requirement to keep the entire contents of this directory secret, 490180746Sdes but the recommended permissions are read/write/execute for the 491180746Sdes user, and not accessible by others. 492180746Sdes 493180740Sdes ~/.ssh/authorized_keys 494180740Sdes Lists the public keys (RSA/DSA) that can be used for logging in 495180740Sdes as this user. The format of this file is described above. The 496180740Sdes content of the file is not highly sensitive, but the recommended 497180740Sdes permissions are read/write for the user, and not accessible by 498180740Sdes others. 499180740Sdes 500180740Sdes If this file, the ~/.ssh directory, or the user's home directory 501180740Sdes are writable by other users, then the file could be modified or 502180740Sdes replaced by unauthorized users. In this case, sshd will not al- 503180740Sdes low it to be used unless the StrictModes option has been set to 504189006Sdes ``no''. 505180740Sdes 506180740Sdes ~/.ssh/environment 507180740Sdes This file is read into the environment at login (if it exists). 508180740Sdes It can only contain empty lines, comment lines (that start with 509180740Sdes `#'), and assignment lines of the form name=value. The file 510180740Sdes should be writable only by the user; it need not be readable by 511180740Sdes anyone else. Environment processing is disabled by default and 512180740Sdes is controlled via the PermitUserEnvironment option. 513180740Sdes 514180740Sdes ~/.ssh/known_hosts 515180740Sdes Contains a list of host keys for all hosts the user has logged 516180740Sdes into that are not already in the systemwide list of known host 517180740Sdes keys. The format of this file is described above. This file 518180740Sdes should be writable only by root/the owner and can, but need not 519180740Sdes be, world-readable. 520180740Sdes 521180740Sdes ~/.ssh/rc 522180740Sdes Contains initialization routines to be run before the user's home 523180740Sdes directory becomes accessible. This file should be writable only 524180740Sdes by the user, and need not be readable by anyone else. 525180740Sdes 526180740Sdes /etc/hosts.allow 527180740Sdes /etc/hosts.deny 528180740Sdes Access controls that should be enforced by tcp-wrappers are de- 529180740Sdes fined here. Further details are described in hosts_access(5). 530180740Sdes 531180740Sdes /etc/hosts.equiv 532180740Sdes This file is for host-based authentication (see ssh(1)). It 533180740Sdes should only be writable by root. 534180740Sdes 535180740Sdes /etc/moduli 536180740Sdes Contains Diffie-Hellman groups used for the "Diffie-Hellman Group 537180740Sdes Exchange". The file format is described in moduli(5). 538180740Sdes 539180740Sdes /etc/motd 540180740Sdes See motd(5). 541180740Sdes 542180740Sdes /etc/nologin 543180740Sdes If this file exists, sshd refuses to let anyone except root log 544180740Sdes in. The contents of the file are displayed to anyone trying to 545180740Sdes log in, and non-root connections are refused. The file should be 546180740Sdes world-readable. 547180740Sdes 548180740Sdes /etc/shosts.equiv 549180740Sdes This file is used in exactly the same way as hosts.equiv, but al- 550180740Sdes lows host-based authentication without permitting login with 551180740Sdes rlogin/rsh. 552180740Sdes 553180740Sdes /etc/ssh/ssh_host_key 554180740Sdes /etc/ssh/ssh_host_dsa_key 555180740Sdes /etc/ssh/ssh_host_rsa_key 556180740Sdes These three files contain the private parts of the host keys. 557180740Sdes These files should only be owned by root, readable only by root, 558180740Sdes and not accessible to others. Note that sshd does not start if 559180740Sdes these files are group/world-accessible. 560180740Sdes 561180740Sdes /etc/ssh/ssh_host_key.pub 562180740Sdes /etc/ssh/ssh_host_dsa_key.pub 563180740Sdes /etc/ssh/ssh_host_rsa_key.pub 564180740Sdes These three files contain the public parts of the host keys. 565180740Sdes These files should be world-readable but writable only by root. 566180740Sdes Their contents should match the respective private parts. These 567180740Sdes files are not really used for anything; they are provided for the 568180740Sdes convenience of the user so their contents can be copied to known 569180740Sdes hosts files. These files are created using ssh-keygen(1). 570180740Sdes 571180744Sdes /etc/ssh/ssh_known_hosts 572180744Sdes Systemwide list of known host keys. This file should be prepared 573180744Sdes by the system administrator to contain the public host keys of 574180744Sdes all machines in the organization. The format of this file is de- 575180744Sdes scribed above. This file should be writable only by root/the 576180744Sdes owner and should be world-readable. 577180744Sdes 578180740Sdes /etc/ssh/sshd_config 579180740Sdes Contains configuration data for sshd. The file format and con- 580180740Sdes figuration options are described in sshd_config(5). 581180740Sdes 582180740Sdes /etc/ssh/sshrc 583180740Sdes Similar to ~/.ssh/rc, it can be used to specify machine-specific 584180740Sdes login-time initializations globally. This file should be 585180740Sdes writable only by root, and should be world-readable. 586180740Sdes 587180740Sdes /var/empty 588180740Sdes chroot(2) directory used by sshd during privilege separation in 589180740Sdes the pre-authentication phase. The directory should not contain 590180740Sdes any files and must be owned by root and not group or world- 591180740Sdes writable. 592180740Sdes 593180740Sdes /var/run/sshd.pid 594180740Sdes Contains the process ID of the sshd listening for connections (if 595180740Sdes there are several daemons running concurrently for different 596180740Sdes ports, this contains the process ID of the one started last). 597180740Sdes The content of this file is not sensitive; it can be world-read- 598180740Sdes able. 599180740Sdes 600180740SdesSEE ALSO 601180740Sdes scp(1), sftp(1), ssh(1), ssh-add(1), ssh-agent(1), ssh-keygen(1), 602180744Sdes ssh-keyscan(1), chroot(2), hosts_access(5), login.conf(5), moduli(5), 603180744Sdes sshd_config(5), inetd(8), sftp-server(8) 604180740Sdes 605180740SdesAUTHORS 606180740Sdes OpenSSH is a derivative of the original and free ssh 1.2.12 release by 607180740Sdes Tatu Ylonen. Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos, Theo 608180740Sdes de Raadt and Dug Song removed many bugs, re-added newer features and cre- 609180740Sdes ated OpenSSH. Markus Friedl contributed the support for SSH protocol 610180740Sdes versions 1.5 and 2.0. Niels Provos and Markus Friedl contributed support 611180740Sdes for privilege separation. 612180740Sdes 613180740SdesCAVEATS 614180740Sdes System security is not improved unless rshd, rlogind, and rexecd are dis- 615180740Sdes abled (thus completely disabling rlogin and rsh into the machine). 616180740Sdes 617204861SdesOpenBSD 4.6 March 5, 2010 10 618