sshd.0 revision 239849
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 13214979Sdes programs replace rlogin(1) and rsh(1), and provide secure encrypted 14214979Sdes communications 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. 18214979Sdes The forked daemons handle key exchange, encryption, authentication, 19214979Sdes command execution, and data exchange. 20180740Sdes 21180740Sdes sshd can be configured using command-line options or a configuration file 22214979Sdes (by default sshd_config(5)); command-line options override values 23214979Sdes specified in the configuration file. sshd rereads its configuration file 24214979Sdes when it receives a hangup signal, SIGHUP, by executing itself with the 25214979Sdes name 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 41214979Sdes will be set before the configuration is written to standard 42214979Sdes output. The connection parameters are supplied as keyword=value 43239849Sdes pairs. The keywords are ``user'', ``host'', ``laddr'', 44239849Sdes ``lport'', and ``addr''. All are required and may be supplied in 45239849Sdes any order, either with multiple -C options or as a comma- 46239849Sdes separated list. 47180750Sdes 48204861Sdes -c host_certificate_file 49204861Sdes Specifies a path to a certificate file to identify sshd during 50204861Sdes key exchange. The certificate file must match a host key file 51214979Sdes specified using the -h option or the HostKey configuration 52214979Sdes directive. 53204861Sdes 54180740Sdes -D When this option is specified, sshd will not detach and does not 55180740Sdes become a daemon. This allows easy monitoring of sshd. 56180740Sdes 57204861Sdes -d Debug mode. The server sends verbose debug output to standard 58214979Sdes error, and does not put itself in the background. The server 59214979Sdes also will not fork and will only process one connection. This 60214979Sdes option is only intended for debugging for the server. Multiple 61214979Sdes -d options increase the debugging level. Maximum is 3. 62180740Sdes 63180740Sdes -e When this option is specified, sshd will send the output to the 64180740Sdes standard error instead of the system log. 65180740Sdes 66180744Sdes -f config_file 67180740Sdes Specifies the name of the configuration file. The default is 68214979Sdes /etc/ssh/sshd_config. sshd refuses to start if there is no 69214979Sdes configuration file. 70180740Sdes 71180740Sdes -g login_grace_time 72214979Sdes Gives the grace time for clients to authenticate themselves 73214979Sdes (default 120 seconds). If the client fails to authenticate the 74214979Sdes user within this many seconds, the server disconnects and exits. 75214979Sdes A value of zero indicates no limit. 76180740Sdes 77180740Sdes -h host_key_file 78180740Sdes Specifies a file from which a host key is read. This option must 79180740Sdes be given if sshd is not run as root (as the normal host key files 80180740Sdes are normally not readable by anyone but root). The default is 81180740Sdes /etc/ssh/ssh_host_key for protocol version 1, and 82218767Sdes /etc/ssh/ssh_host_dsa_key, /etc/ssh/ssh_host_ecdsa_key and 83218767Sdes /etc/ssh/ssh_host_rsa_key for protocol version 2. It is possible 84218767Sdes to have multiple host key files for the different protocol 85218767Sdes versions and host key algorithms. 86180740Sdes 87180740Sdes -i Specifies that sshd is being run from inetd(8). sshd is normally 88180740Sdes not run from inetd because it needs to generate the server key 89180740Sdes before it can respond to the client, and this may take tens of 90214979Sdes seconds. Clients would have to wait too long if the key was 91214979Sdes regenerated every time. However, with small key sizes (e.g. 512) 92180740Sdes using sshd from inetd may be feasible. 93180740Sdes 94180740Sdes -k key_gen_time 95180740Sdes Specifies how often the ephemeral protocol version 1 server key 96214979Sdes is regenerated (default 3600 seconds, or one hour). The 97214979Sdes motivation for regenerating the key fairly often is that the key 98214979Sdes is not stored anywhere, and after about an hour it becomes 99214979Sdes impossible to recover the key for decrypting intercepted 100214979Sdes communications even if the machine is cracked into or physically 101214979Sdes seized. A value of zero indicates that the key will never be 102214979Sdes regenerated. 103180740Sdes 104180740Sdes -o option 105214979Sdes Can be used to give options in the format used in the 106214979Sdes configuration file. This is useful for specifying options for 107214979Sdes which there is no separate command-line flag. For full details 108214979Sdes of the options, and their values, see sshd_config(5). 109180740Sdes 110180740Sdes -p port 111180740Sdes Specifies the port on which the server listens for connections 112214979Sdes (default 22). Multiple port options are permitted. Ports 113214979Sdes specified in the configuration file with the Port option are 114214979Sdes ignored when a command-line port is specified. Ports specified 115214979Sdes using the ListenAddress option override command-line ports. 116180740Sdes 117214979Sdes -q Quiet mode. Nothing is sent to the system log. Normally the 118214979Sdes beginning, authentication, and termination of each connection is 119180740Sdes logged. 120180740Sdes 121180750Sdes -T Extended test mode. Check the validity of the configuration 122180750Sdes file, output the effective configuration to stdout and then exit. 123214979Sdes Optionally, Match rules may be applied by specifying the 124214979Sdes connection parameters using one or more -C options. 125180750Sdes 126180740Sdes -t Test mode. Only check the validity of the configuration file and 127180740Sdes sanity of the keys. This is useful for updating sshd reliably as 128180740Sdes configuration options may change. 129180740Sdes 130180740Sdes -u len This option is used to specify the size of the field in the utmp 131180740Sdes structure that holds the remote host name. If the resolved host 132180740Sdes name is longer than len, the dotted decimal value will be used 133214979Sdes instead. This allows hosts with very long host names that 134214979Sdes overflow this field to still be uniquely identified. Specifying 135214979Sdes -u0 indicates that only dotted decimal addresses should be put 136214979Sdes into the utmp file. -u0 may also be used to prevent sshd from 137214979Sdes making DNS requests unless the authentication mechanism or 138214979Sdes configuration requires it. Authentication mechanisms that may 139214979Sdes require DNS include RhostsRSAAuthentication, 140214979Sdes HostbasedAuthentication, and using a from="pattern-list" option 141214979Sdes in a key file. Configuration options that require DNS include 142214979Sdes using a USER@HOST pattern in AllowUsers or DenyUsers. 143180740Sdes 144180740SdesAUTHENTICATION 145204861Sdes The OpenSSH SSH daemon supports SSH protocols 1 and 2. The default is to 146204861Sdes use protocol 2 only, though this can be changed via the Protocol option 147218767Sdes in sshd_config(5). Protocol 2 supports DSA, ECDSA and RSA keys; protocol 148218767Sdes 1 only supports RSA keys. For both protocols, each host has a host- 149214979Sdes specific key, normally 2048 bits, used to identify the host. 150180740Sdes 151180740Sdes Forward security for protocol 1 is provided through an additional server 152180740Sdes key, normally 768 bits, generated when the server starts. This key is 153180740Sdes normally regenerated every hour if it has been used, and is never stored 154180740Sdes on disk. Whenever a client connects, the daemon responds with its public 155180740Sdes host and server keys. The client compares the RSA host key against its 156214979Sdes own database to verify that it has not changed. The client then 157214979Sdes generates a 256-bit random number. It encrypts this random number using 158214979Sdes both the host key and the server key, and sends the encrypted number to 159214979Sdes the server. Both sides then use this random number as a session key 160214979Sdes which is used to encrypt all further communications in the session. The 161214979Sdes rest of the session is encrypted using a conventional cipher, currently 162214979Sdes Blowfish or 3DES, with 3DES being used by default. The client selects 163214979Sdes the encryption algorithm to use from those offered by the server. 164180740Sdes 165180740Sdes For protocol 2, forward security is provided through a Diffie-Hellman key 166180740Sdes agreement. This key agreement results in a shared session key. The rest 167180740Sdes of the session is encrypted using a symmetric cipher, currently 128-bit 168180740Sdes AES, Blowfish, 3DES, CAST128, Arcfour, 192-bit AES, or 256-bit AES. The 169180740Sdes client selects the encryption algorithm to use from those offered by the 170214979Sdes server. Additionally, session integrity is provided through a 171225825Sdes cryptographic message authentication code (hmac-md5, hmac-sha1, umac-64, 172225825Sdes hmac-ripemd160, hmac-sha2-256 or hmac-sha2-512). 173180740Sdes 174180740Sdes Finally, the server and the client enter an authentication dialog. The 175214979Sdes client tries to authenticate itself using host-based authentication, 176214979Sdes public key authentication, challenge-response authentication, or password 177180740Sdes authentication. 178180740Sdes 179180740Sdes Regardless of the authentication type, the account is checked to ensure 180180740Sdes that it is accessible. An account is not accessible if it is locked, 181214979Sdes listed in DenyUsers or its group is listed in DenyGroups . The 182214979Sdes definition of a locked account is system dependant. Some platforms have 183214979Sdes their own account database (eg AIX) and some modify the passwd field ( 184214979Sdes `*LK*' on Solaris and UnixWare, `*' on HP-UX, containing `Nologin' on 185214979Sdes Tru64, a leading `*LOCKED*' on FreeBSD and a leading `!' on most 186214979Sdes Linuxes). If there is a requirement to disable password authentication 187214979Sdes for the account while allowing still public-key, then the passwd field 188214979Sdes should be set to something other than these values (eg `NP' or `*NP*' ). 189180740Sdes 190180740Sdes If the client successfully authenticates itself, a dialog for preparing 191180740Sdes the session is entered. At this time the client may request things like 192214979Sdes allocating a pseudo-tty, forwarding X11 connections, forwarding TCP 193214979Sdes connections, or forwarding the authentication agent connection over the 194214979Sdes secure channel. 195180740Sdes 196180740Sdes After this, the client either requests a shell or execution of a command. 197180740Sdes The sides then enter session mode. In this mode, either side may send 198180740Sdes data at any time, and such data is forwarded to/from the shell or command 199180740Sdes on the server side, and the user terminal in the client side. 200180740Sdes 201214979Sdes When the user program terminates and all forwarded X11 and other 202214979Sdes connections have been closed, the server sends command exit status to the 203180740Sdes client, and both sides exit. 204180740Sdes 205180740SdesLOGIN PROCESS 206180740Sdes When a user successfully logs in, sshd does the following: 207180740Sdes 208180740Sdes 1. If the login is on a tty, and no command has been specified, 209180740Sdes prints last login time and /etc/motd (unless prevented in the 210180740Sdes configuration file or by ~/.hushlogin; see the FILES section). 211180740Sdes 212180740Sdes 2. If the login is on a tty, records login time. 213180740Sdes 214180740Sdes 3. Checks /etc/nologin; if it exists, prints contents and quits 215180740Sdes (unless root). 216180740Sdes 217180740Sdes 4. Changes to run with normal user privileges. 218180740Sdes 219180740Sdes 5. Sets up basic environment. 220180740Sdes 221180740Sdes 6. Reads the file ~/.ssh/environment, if it exists, and users are 222180740Sdes allowed to change their environment. See the 223180740Sdes PermitUserEnvironment option in sshd_config(5). 224180740Sdes 225180740Sdes 7. Changes to user's home directory. 226180740Sdes 227180740Sdes 8. If ~/.ssh/rc exists, runs it; else if /etc/ssh/sshrc exists, 228180740Sdes runs it; otherwise runs xauth. The ``rc'' files are given the 229180740Sdes X11 authentication protocol and cookie in standard input. See 230180740Sdes SSHRC, below. 231180740Sdes 232180740Sdes 9. Runs user's shell or command. 233180740Sdes 234180740SdesSSHRC 235180740Sdes If the file ~/.ssh/rc exists, sh(1) runs it after reading the environment 236214979Sdes files but before starting the user's shell or command. It must not 237214979Sdes produce any output on stdout; stderr must be used instead. If X11 238214979Sdes forwarding is in use, it will receive the "proto cookie" pair in its 239214979Sdes standard input (and DISPLAY in its environment). The script must call 240214979Sdes xauth(1) because sshd will not run xauth automatically to add X11 241214979Sdes cookies. 242180740Sdes 243180740Sdes The primary purpose of this file is to run any initialization routines 244180740Sdes which may be needed before the user's home directory becomes accessible; 245180740Sdes AFS is a particular example of such an environment. 246180740Sdes 247180740Sdes This file will probably contain some initialization code followed by 248180740Sdes something similar to: 249180740Sdes 250180740Sdes if read proto cookie && [ -n "$DISPLAY" ]; then 251180740Sdes if [ `echo $DISPLAY | cut -c1-10` = 'localhost:' ]; then 252180740Sdes # X11UseLocalhost=yes 253180740Sdes echo add unix:`echo $DISPLAY | 254180740Sdes cut -c11-` $proto $cookie 255180740Sdes else 256180740Sdes # X11UseLocalhost=no 257180740Sdes echo add $DISPLAY $proto $cookie 258180740Sdes fi | xauth -q - 259180740Sdes fi 260180740Sdes 261180740Sdes If this file does not exist, /etc/ssh/sshrc is run, and if that does not 262180740Sdes exist either, xauth is used to add the cookie. 263180740Sdes 264180740SdesAUTHORIZED_KEYS FILE FORMAT 265225825Sdes AuthorizedKeysFile specifies the files containing public keys for public 266180740Sdes key authentication; if none is specified, the default is 267225825Sdes ~/.ssh/authorized_keys and ~/.ssh/authorized_keys2. Each line of the 268225825Sdes file contains one key (empty lines and lines starting with a `#' are 269225825Sdes ignored as comments). Protocol 1 public keys consist of the following 270225825Sdes space-separated fields: options, bits, exponent, modulus, comment. 271225825Sdes Protocol 2 public key consist of: options, keytype, base64-encoded key, 272225825Sdes comment. The options field is optional; its presence is determined by 273225825Sdes whether the line starts with a number or not (the options field never 274225825Sdes starts with a number). The bits, exponent, modulus, and comment fields 275225825Sdes give the RSA key for protocol version 1; the comment field is not used 276225825Sdes for anything (but may be convenient for the user to identify the key). 277225825Sdes For protocol version 2 the keytype is ``ecdsa-sha2-nistp256'', 278225825Sdes ``ecdsa-sha2-nistp384'', ``ecdsa-sha2-nistp521'', ``ssh-dss'' or 279225825Sdes ``ssh-rsa''. 280180740Sdes 281214979Sdes Note that lines in this file are usually several hundred bytes long 282214979Sdes (because of the size of the public key encoding) up to a limit of 8 283214979Sdes kilobytes, which permits DSA keys up to 8 kilobits and RSA keys up to 16 284180740Sdes kilobits. You don't want to type them in; instead, copy the 285218767Sdes identity.pub, id_dsa.pub, id_ecdsa.pub, or the id_rsa.pub file and edit 286218767Sdes it. 287180740Sdes 288180740Sdes sshd enforces a minimum RSA key modulus size for protocol 1 and protocol 289180740Sdes 2 keys of 768 bits. 290180740Sdes 291214979Sdes The options (if present) consist of comma-separated option 292214979Sdes specifications. No spaces are permitted, except within double quotes. 293214979Sdes The following option specifications are supported (note that option 294214979Sdes keywords are case-insensitive): 295180740Sdes 296204861Sdes cert-authority 297204861Sdes Specifies that the listed key is a certification authority (CA) 298214979Sdes that is trusted to validate signed certificates for user 299214979Sdes authentication. 300204861Sdes 301204861Sdes Certificates may encode access restrictions similar to these key 302204861Sdes options. If both certificate restrictions and key options are 303204861Sdes present, the most restrictive union of the two is applied. 304204861Sdes 305180740Sdes command="command" 306180740Sdes Specifies that the command is executed whenever this key is used 307180740Sdes for authentication. The command supplied by the user (if any) is 308180740Sdes ignored. The command is run on a pty if the client requests a 309214979Sdes pty; otherwise it is run without a tty. If an 8-bit clean 310214979Sdes channel is required, one must not request a pty or should specify 311214979Sdes no-pty. A quote may be included in the command by quoting it 312214979Sdes with a backslash. This option might be useful to restrict 313214979Sdes certain public keys to perform just a specific operation. An 314214979Sdes example might be a key that permits remote backups but nothing 315214979Sdes else. Note that the client may specify TCP and/or X11 forwarding 316214979Sdes unless they are explicitly prohibited. The command originally 317214979Sdes supplied by the client is available in the SSH_ORIGINAL_COMMAND 318214979Sdes environment variable. Note that this option applies to shell, 319214979Sdes command or subsystem execution. Also note that this command may 320214979Sdes be superseded by either a sshd_config(5) ForceCommand directive 321214979Sdes or a command embedded in a certificate. 322180740Sdes 323180740Sdes environment="NAME=value" 324180740Sdes Specifies that the string is to be added to the environment when 325180740Sdes logging in using this key. Environment variables set this way 326180740Sdes override other default environment values. Multiple options of 327180740Sdes this type are permitted. Environment processing is disabled by 328180740Sdes default and is controlled via the PermitUserEnvironment option. 329180740Sdes This option is automatically disabled if UseLogin is enabled. 330180740Sdes 331180740Sdes from="pattern-list" 332180750Sdes Specifies that in addition to public key authentication, either 333180750Sdes the canonical name of the remote host or its IP address must be 334180750Sdes present in the comma-separated list of patterns. See PATTERNS in 335180750Sdes ssh_config(5) for more information on patterns. 336180740Sdes 337214979Sdes In addition to the wildcard matching that may be applied to 338214979Sdes hostnames or addresses, a from stanza may match IP addresses 339214979Sdes using CIDR address/masklen notation. 340180740Sdes 341180750Sdes The purpose of this option is to optionally increase security: 342180750Sdes public key authentication by itself does not trust the network or 343180750Sdes name servers or anything (but the key); however, if somebody 344180750Sdes somehow steals the key, the key permits an intruder to log in 345180750Sdes from anywhere in the world. This additional option makes using a 346180750Sdes stolen key more difficult (name servers and/or routers would have 347180750Sdes to be compromised in addition to just the key). 348180750Sdes 349180740Sdes no-agent-forwarding 350180740Sdes Forbids authentication agent forwarding when this key is used for 351180740Sdes authentication. 352180740Sdes 353180740Sdes no-port-forwarding 354180740Sdes Forbids TCP forwarding when this key is used for authentication. 355180740Sdes Any port forward requests by the client will return an error. 356180740Sdes This might be used, e.g. in connection with the command option. 357180740Sdes 358180740Sdes no-pty Prevents tty allocation (a request to allocate a pty will fail). 359180740Sdes 360180746Sdes no-user-rc 361180746Sdes Disables execution of ~/.ssh/rc. 362180746Sdes 363180740Sdes no-X11-forwarding 364180740Sdes Forbids X11 forwarding when this key is used for authentication. 365180740Sdes Any X11 forward requests by the client will return an error. 366180740Sdes 367180740Sdes permitopen="host:port" 368214979Sdes Limit local ``ssh -L'' port forwarding such that it may only 369214979Sdes connect to the specified host and port. IPv6 addresses can be 370214979Sdes specified by enclosing the address in square brackets. Multiple 371214979Sdes permitopen options may be applied separated by commas. No 372214979Sdes pattern matching is performed on the specified hostnames, they 373239844Sdes must be literal domains or addresses. A port specification of * 374239844Sdes matches any port. 375180740Sdes 376214979Sdes principals="principals" 377214979Sdes On a cert-authority line, specifies allowed principals for 378214979Sdes certificate authentication as a comma-separated list. At least 379214979Sdes one name from the list must appear in the certificate's list of 380214979Sdes principals for the certificate to be accepted. This option is 381214979Sdes ignored for keys that are not marked as trusted certificate 382214979Sdes signers using the cert-authority option. 383214979Sdes 384180740Sdes tunnel="n" 385180740Sdes Force a tun(4) device on the server. Without this option, the 386214979Sdes next available device will be used if the client requests a 387214979Sdes tunnel. 388180740Sdes 389180740Sdes An example authorized_keys file: 390180740Sdes 391180740Sdes # Comments allowed at start of line 392180740Sdes ssh-rsa AAAAB3Nza...LiPk== user@example.net 393180740Sdes from="*.sales.example.net,!pc.sales.example.net" ssh-rsa 394180740Sdes AAAAB2...19Q== john@example.net 395180740Sdes command="dump /home",no-pty,no-port-forwarding ssh-dss 396180740Sdes AAAAC3...51R== example.net 397180740Sdes permitopen="192.0.2.1:80",permitopen="192.0.2.2:25" ssh-dss 398180740Sdes AAAAB5...21S== 399180740Sdes tunnel="0",command="sh /etc/netstart tun0" ssh-rsa AAAA...== 400180740Sdes jane@example.net 401180740Sdes 402180740SdesSSH_KNOWN_HOSTS FILE FORMAT 403180740Sdes The /etc/ssh/ssh_known_hosts and ~/.ssh/known_hosts files contain host 404180740Sdes public keys for all known hosts. The global file should be prepared by 405214979Sdes the administrator (optional), and the per-user file is maintained 406214979Sdes automatically: whenever the user connects from an unknown host, its key 407214979Sdes is added to the per-user file. 408180740Sdes 409214979Sdes Each line in these files contains the following fields: markers 410214979Sdes (optional), hostnames, bits, exponent, modulus, comment. The fields are 411214979Sdes separated by spaces. 412180740Sdes 413204861Sdes The marker is optional, but if it is present then it must be one of 414204861Sdes ``@cert-authority'', to indicate that the line contains a certification 415204861Sdes authority (CA) key, or ``@revoked'', to indicate that the key contained 416204861Sdes on the line is revoked and must not ever be accepted. Only one marker 417204861Sdes should be used on a key line. 418204861Sdes 419214979Sdes Hostnames is a comma-separated list of patterns (`*' and `?' act as 420214979Sdes wildcards); each pattern in turn is matched against the canonical host 421214979Sdes name (when authenticating a client) or against the user-supplied name 422214979Sdes (when authenticating a server). A pattern may also be preceded by `!' to 423214979Sdes indicate negation: if the host name matches a negated pattern, it is not 424214979Sdes accepted (by that line) even if it matched another pattern on the line. 425214979Sdes A hostname or address may optionally be enclosed within `[' and `]' 426214979Sdes brackets then followed by `:' and a non-standard port number. 427180740Sdes 428180740Sdes Alternately, hostnames may be stored in a hashed form which hides host 429180740Sdes names and addresses should the file's contents be disclosed. Hashed 430214979Sdes hostnames start with a `|' character. Only one hashed hostname may 431214979Sdes appear on a single line and none of the above negation or wildcard 432214979Sdes operators may be applied. 433180740Sdes 434180740Sdes Bits, exponent, and modulus are taken directly from the RSA host key; 435180740Sdes they can be obtained, for example, from /etc/ssh/ssh_host_key.pub. The 436180740Sdes optional comment field continues to the end of the line, and is not used. 437180740Sdes 438180740Sdes Lines starting with `#' and empty lines are ignored as comments. 439180740Sdes 440180740Sdes When performing host authentication, authentication is accepted if any 441204861Sdes matching line has the proper key; either one that matches exactly or, if 442204861Sdes the server has presented a certificate for authentication, the key of the 443204861Sdes certification authority that signed the certificate. For a key to be 444204861Sdes trusted as a certification authority, it must use the ``@cert-authority'' 445204861Sdes marker described above. 446180740Sdes 447204861Sdes The known hosts file also provides a facility to mark keys as revoked, 448204861Sdes for example when it is known that the associated private key has been 449204861Sdes stolen. Revoked keys are specified by including the ``@revoked'' marker 450214979Sdes at the beginning of the key line, and are never accepted for 451214979Sdes authentication or as certification authorities, but instead will produce 452214979Sdes a warning from ssh(1) when they are encountered. 453204861Sdes 454214979Sdes It is permissible (but not recommended) to have several lines or 455214979Sdes different host keys for the same names. This will inevitably happen when 456214979Sdes short forms of host names from different domains are put in the file. It 457214979Sdes is possible that the files contain conflicting information; 458214979Sdes authentication is accepted if valid information can be found from either 459214979Sdes file. 460204861Sdes 461180740Sdes Note that the lines in these files are typically hundreds of characters 462180740Sdes long, and you definitely don't want to type in the host keys by hand. 463204861Sdes Rather, generate them by a script, ssh-keyscan(1) or by taking 464204861Sdes /etc/ssh/ssh_host_key.pub and adding the host names at the front. 465204861Sdes ssh-keygen(1) also offers some basic automated editing for 466214979Sdes ~/.ssh/known_hosts including removing hosts matching a host name and 467214979Sdes converting all host names to their hashed representations. 468180740Sdes 469180740Sdes An example ssh_known_hosts file: 470180740Sdes 471180740Sdes # Comments allowed at start of line 472180740Sdes closenet,...,192.0.2.53 1024 37 159...93 closenet.example.net 473180740Sdes cvs.example.net,192.0.2.10 ssh-rsa AAAA1234.....= 474180740Sdes # A hashed hostname 475180740Sdes |1|JfKTdBh7rNbXkVAQCRp4OQoPfmI=|USECr3SWf1JUPsms5AqfD5QfxkM= ssh-rsa 476180740Sdes AAAA1234.....= 477204861Sdes # A revoked key 478204861Sdes @revoked * ssh-rsa AAAAB5W... 479204861Sdes # A CA key, accepted for any host in *.mydomain.com or *.mydomain.org 480204861Sdes @cert-authority *.mydomain.org,*.mydomain.com ssh-rsa AAAAB5W... 481180740Sdes 482180740SdesFILES 483180740Sdes ~/.hushlogin 484180740Sdes This file is used to suppress printing the last login time and 485214979Sdes /etc/motd, if PrintLastLog and PrintMotd, respectively, are 486214979Sdes enabled. It does not suppress printing of the banner specified 487214979Sdes by Banner. 488180740Sdes 489180740Sdes ~/.rhosts 490180740Sdes This file is used for host-based authentication (see ssh(1) for 491180740Sdes more information). On some machines this file may need to be 492214979Sdes world-readable if the user's home directory is on an NFS 493214979Sdes partition, because sshd reads it as root. Additionally, this 494214979Sdes file must be owned by the user, and must not have write 495214979Sdes permissions for anyone else. The recommended permission for most 496214979Sdes machines is read/write for the user, and not accessible by 497214979Sdes others. 498180740Sdes 499180740Sdes ~/.shosts 500180740Sdes This file is used in exactly the same way as .rhosts, but allows 501180740Sdes host-based authentication without permitting login with 502180740Sdes rlogin/rsh. 503180740Sdes 504180746Sdes ~/.ssh/ 505214979Sdes This directory is the default location for all user-specific 506214979Sdes configuration and authentication information. There is no 507214979Sdes general requirement to keep the entire contents of this directory 508214979Sdes secret, but the recommended permissions are read/write/execute 509214979Sdes for the user, and not accessible by others. 510180746Sdes 511180740Sdes ~/.ssh/authorized_keys 512218767Sdes Lists the public keys (DSA/ECDSA/RSA) that can be used for 513218767Sdes logging in as this user. The format of this file is described 514218767Sdes above. The content of the file is not highly sensitive, but the 515218767Sdes recommended permissions are read/write for the user, and not 516218767Sdes accessible by others. 517180740Sdes 518180740Sdes If this file, the ~/.ssh directory, or the user's home directory 519180740Sdes are writable by other users, then the file could be modified or 520214979Sdes replaced by unauthorized users. In this case, sshd will not 521214979Sdes allow it to be used unless the StrictModes option has been set to 522189006Sdes ``no''. 523180740Sdes 524180740Sdes ~/.ssh/environment 525180740Sdes This file is read into the environment at login (if it exists). 526180740Sdes It can only contain empty lines, comment lines (that start with 527180740Sdes `#'), and assignment lines of the form name=value. The file 528180740Sdes should be writable only by the user; it need not be readable by 529180740Sdes anyone else. Environment processing is disabled by default and 530180740Sdes is controlled via the PermitUserEnvironment option. 531180740Sdes 532180740Sdes ~/.ssh/known_hosts 533180740Sdes Contains a list of host keys for all hosts the user has logged 534180740Sdes into that are not already in the systemwide list of known host 535180740Sdes keys. The format of this file is described above. This file 536180740Sdes should be writable only by root/the owner and can, but need not 537180740Sdes be, world-readable. 538180740Sdes 539180740Sdes ~/.ssh/rc 540180740Sdes Contains initialization routines to be run before the user's home 541180740Sdes directory becomes accessible. This file should be writable only 542180740Sdes by the user, and need not be readable by anyone else. 543180740Sdes 544180740Sdes /etc/hosts.allow 545180740Sdes /etc/hosts.deny 546214979Sdes Access controls that should be enforced by tcp-wrappers are 547214979Sdes defined here. Further details are described in hosts_access(5). 548180740Sdes 549180740Sdes /etc/hosts.equiv 550180740Sdes This file is for host-based authentication (see ssh(1)). It 551180740Sdes should only be writable by root. 552180740Sdes 553180740Sdes /etc/moduli 554180740Sdes Contains Diffie-Hellman groups used for the "Diffie-Hellman Group 555180740Sdes Exchange". The file format is described in moduli(5). 556180740Sdes 557180740Sdes /etc/motd 558180740Sdes See motd(5). 559180740Sdes 560180740Sdes /etc/nologin 561180740Sdes If this file exists, sshd refuses to let anyone except root log 562180740Sdes in. The contents of the file are displayed to anyone trying to 563180740Sdes log in, and non-root connections are refused. The file should be 564180740Sdes world-readable. 565180740Sdes 566180740Sdes /etc/shosts.equiv 567214979Sdes This file is used in exactly the same way as hosts.equiv, but 568214979Sdes allows host-based authentication without permitting login with 569180740Sdes rlogin/rsh. 570180740Sdes 571180740Sdes /etc/ssh/ssh_host_key 572180740Sdes /etc/ssh/ssh_host_dsa_key 573218767Sdes /etc/ssh/ssh_host_ecdsa_key 574180740Sdes /etc/ssh/ssh_host_rsa_key 575239849Sdes These files contain the private parts of the host keys. These 576239849Sdes files should only be owned by root, readable only by root, and 577239849Sdes not accessible to others. Note that sshd does not start if these 578239849Sdes files are group/world-accessible. 579180740Sdes 580180740Sdes /etc/ssh/ssh_host_key.pub 581180740Sdes /etc/ssh/ssh_host_dsa_key.pub 582218767Sdes /etc/ssh/ssh_host_ecdsa_key.pub 583180740Sdes /etc/ssh/ssh_host_rsa_key.pub 584239849Sdes These files contain the public parts of the host keys. These 585239849Sdes files should be world-readable but writable only by root. Their 586239849Sdes contents should match the respective private parts. These files 587239849Sdes are not really used for anything; they are provided for the 588180740Sdes convenience of the user so their contents can be copied to known 589180740Sdes hosts files. These files are created using ssh-keygen(1). 590180740Sdes 591180744Sdes /etc/ssh/ssh_known_hosts 592180744Sdes Systemwide list of known host keys. This file should be prepared 593180744Sdes by the system administrator to contain the public host keys of 594214979Sdes all machines in the organization. The format of this file is 595214979Sdes described above. This file should be writable only by root/the 596180744Sdes owner and should be world-readable. 597180744Sdes 598180740Sdes /etc/ssh/sshd_config 599214979Sdes Contains configuration data for sshd. The file format and 600214979Sdes configuration options are described in sshd_config(5). 601180740Sdes 602180740Sdes /etc/ssh/sshrc 603180740Sdes Similar to ~/.ssh/rc, it can be used to specify machine-specific 604180740Sdes login-time initializations globally. This file should be 605180740Sdes writable only by root, and should be world-readable. 606180740Sdes 607180740Sdes /var/empty 608180740Sdes chroot(2) directory used by sshd during privilege separation in 609180740Sdes the pre-authentication phase. The directory should not contain 610180740Sdes any files and must be owned by root and not group or world- 611180740Sdes writable. 612180740Sdes 613180740Sdes /var/run/sshd.pid 614180740Sdes Contains the process ID of the sshd listening for connections (if 615180740Sdes there are several daemons running concurrently for different 616180740Sdes ports, this contains the process ID of the one started last). 617214979Sdes The content of this file is not sensitive; it can be world- 618214979Sdes readable. 619180740Sdes 620180740SdesSEE ALSO 621180740Sdes scp(1), sftp(1), ssh(1), ssh-add(1), ssh-agent(1), ssh-keygen(1), 622180744Sdes ssh-keyscan(1), chroot(2), hosts_access(5), login.conf(5), moduli(5), 623180744Sdes sshd_config(5), inetd(8), sftp-server(8) 624180740Sdes 625180740SdesAUTHORS 626180740Sdes OpenSSH is a derivative of the original and free ssh 1.2.12 release by 627180740Sdes Tatu Ylonen. Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos, Theo 628214979Sdes de Raadt and Dug Song removed many bugs, re-added newer features and 629214979Sdes created OpenSSH. Markus Friedl contributed the support for SSH protocol 630180740Sdes versions 1.5 and 2.0. Niels Provos and Markus Friedl contributed support 631180740Sdes for privilege separation. 632180740Sdes 633180740SdesCAVEATS 634214979Sdes System security is not improved unless rshd, rlogind, and rexecd are 635214979Sdes disabled (thus completely disabling rlogin and rsh into the machine). 636180740Sdes 637239849SdesOpenBSD 5.2 June 18, 2012 OpenBSD 5.2 638