1511b41d2SMark Murray.\" 2511b41d2SMark Murray.\" Author: Tatu Ylonen <ylo@cs.hut.fi> 3511b41d2SMark Murray.\" Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4511b41d2SMark Murray.\" All rights reserved 5511b41d2SMark Murray.\" 6c2d3a559SKris Kennaway.\" As far as I am concerned, the code I have written for this software 7c2d3a559SKris Kennaway.\" can be used freely for any purpose. Any derived versions of this 8c2d3a559SKris Kennaway.\" software must be clearly marked as such, and if the derived work is 9c2d3a559SKris Kennaway.\" incompatible with the protocol description in the RFC file, it must be 10c2d3a559SKris Kennaway.\" called by a name other than "ssh" or "Secure Shell". 11511b41d2SMark Murray.\" 12c2d3a559SKris Kennaway.\" Copyright (c) 1999,2000 Markus Friedl. All rights reserved. 13c2d3a559SKris Kennaway.\" Copyright (c) 1999 Aaron Campbell. All rights reserved. 14c2d3a559SKris Kennaway.\" Copyright (c) 1999 Theo de Raadt. All rights reserved. 15c2d3a559SKris Kennaway.\" 16c2d3a559SKris Kennaway.\" Redistribution and use in source and binary forms, with or without 17c2d3a559SKris Kennaway.\" modification, are permitted provided that the following conditions 18c2d3a559SKris Kennaway.\" are met: 19c2d3a559SKris Kennaway.\" 1. Redistributions of source code must retain the above copyright 20c2d3a559SKris Kennaway.\" notice, this list of conditions and the following disclaimer. 21c2d3a559SKris Kennaway.\" 2. Redistributions in binary form must reproduce the above copyright 22c2d3a559SKris Kennaway.\" notice, this list of conditions and the following disclaimer in the 23c2d3a559SKris Kennaway.\" documentation and/or other materials provided with the distribution. 24c2d3a559SKris Kennaway.\" 25c2d3a559SKris Kennaway.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 26c2d3a559SKris Kennaway.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 27c2d3a559SKris Kennaway.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 28c2d3a559SKris Kennaway.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 29c2d3a559SKris Kennaway.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 30c2d3a559SKris Kennaway.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 31c2d3a559SKris Kennaway.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 32c2d3a559SKris Kennaway.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33c2d3a559SKris Kennaway.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 34c2d3a559SKris Kennaway.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35c2d3a559SKris Kennaway.\" 36*bc5531deSDag-Erling Smørgrav.\" $OpenBSD: sshd.8,v 1.278 2014/11/15 14:41:03 bentley Exp $ 3735d4ccfbSDag-Erling Smørgrav.\" $FreeBSD$ 38*bc5531deSDag-Erling Smørgrav.Dd $Mdocdate: November 15 2014 $ 39511b41d2SMark Murray.Dt SSHD 8 40511b41d2SMark Murray.Os 41511b41d2SMark Murray.Sh NAME 42511b41d2SMark Murray.Nm sshd 43ca3176e7SBrian Feldman.Nd OpenSSH SSH daemon 44511b41d2SMark Murray.Sh SYNOPSIS 45511b41d2SMark Murray.Nm sshd 46e73e9afaSDag-Erling Smørgrav.Bk -words 47d4af9e69SDag-Erling Smørgrav.Op Fl 46DdeiqTt 48511b41d2SMark Murray.Op Fl b Ar bits 49d4af9e69SDag-Erling Smørgrav.Op Fl C Ar connection_spec 50b15c8340SDag-Erling Smørgrav.Op Fl c Ar host_certificate_file 51e4a9863fSDag-Erling Smørgrav.Op Fl E Ar log_file 52511b41d2SMark Murray.Op Fl f Ar config_file 53511b41d2SMark Murray.Op Fl g Ar login_grace_time 54511b41d2SMark Murray.Op Fl h Ar host_key_file 55511b41d2SMark Murray.Op Fl k Ar key_gen_time 56af12a3e7SDag-Erling Smørgrav.Op Fl o Ar option 57511b41d2SMark Murray.Op Fl p Ar port 58c2d3a559SKris Kennaway.Op Fl u Ar len 59e73e9afaSDag-Erling Smørgrav.Ek 60511b41d2SMark Murray.Sh DESCRIPTION 61511b41d2SMark Murray.Nm 62b74df5b2SDag-Erling Smørgrav(OpenSSH Daemon) is the daemon program for 63511b41d2SMark Murray.Xr ssh 1 . 64a0ee8cc6SDag-Erling SmørgravTogether these programs replace rlogin and rsh, 65d4af9e69SDag-Erling Smørgravand provide secure encrypted communications between two untrusted hosts 663c6ae118SKris Kennawayover an insecure network. 67511b41d2SMark Murray.Pp 68511b41d2SMark Murray.Nm 69b74df5b2SDag-Erling Smørgravlistens for connections from clients. 703c6ae118SKris KennawayIt is normally started at boot from 7135d4ccfbSDag-Erling Smørgrav.Pa /etc/rc.d/sshd . 72511b41d2SMark MurrayIt forks a new 733c6ae118SKris Kennawaydaemon for each incoming connection. 743c6ae118SKris KennawayThe forked daemons handle 75511b41d2SMark Murraykey exchange, encryption, authentication, command execution, 76511b41d2SMark Murrayand data exchange. 77511b41d2SMark Murray.Pp 78511b41d2SMark Murray.Nm 791ec0d754SDag-Erling Smørgravcan be configured using command-line options or a configuration file 801ec0d754SDag-Erling Smørgrav(by default 81b74df5b2SDag-Erling Smørgrav.Xr sshd_config 5 ) ; 82b74df5b2SDag-Erling Smørgravcommand-line options override values specified in the 83511b41d2SMark Murrayconfiguration file. 84511b41d2SMark Murray.Nm 85511b41d2SMark Murrayrereads its configuration file when it receives a hangup signal, 86ca3176e7SBrian Feldman.Dv SIGHUP , 87333ee039SDag-Erling Smørgravby executing itself with the name and options it was started with, e.g.\& 88ca3176e7SBrian Feldman.Pa /usr/sbin/sshd . 89511b41d2SMark Murray.Pp 90511b41d2SMark MurrayThe options are as follows: 91511b41d2SMark Murray.Bl -tag -width Ds 921ec0d754SDag-Erling Smørgrav.It Fl 4 931ec0d754SDag-Erling SmørgravForces 941ec0d754SDag-Erling Smørgrav.Nm 951ec0d754SDag-Erling Smørgravto use IPv4 addresses only. 961ec0d754SDag-Erling Smørgrav.It Fl 6 971ec0d754SDag-Erling SmørgravForces 981ec0d754SDag-Erling Smørgrav.Nm 991ec0d754SDag-Erling Smørgravto use IPv6 addresses only. 100511b41d2SMark Murray.It Fl b Ar bits 101ca3176e7SBrian FeldmanSpecifies the number of bits in the ephemeral protocol version 1 102d4af9e69SDag-Erling Smørgravserver key (default 1024). 103d4af9e69SDag-Erling Smørgrav.It Fl C Ar connection_spec 104d4af9e69SDag-Erling SmørgravSpecify the connection parameters to use for the 105d4af9e69SDag-Erling Smørgrav.Fl T 106d4af9e69SDag-Erling Smørgravextended test mode. 107d4af9e69SDag-Erling SmørgravIf provided, any 108d4af9e69SDag-Erling Smørgrav.Cm Match 109d4af9e69SDag-Erling Smørgravdirectives in the configuration file 110d4af9e69SDag-Erling Smørgravthat would apply to the specified user, host, and address will be set before 111d4af9e69SDag-Erling Smørgravthe configuration is written to standard output. 112d4af9e69SDag-Erling SmørgravThe connection parameters are supplied as keyword=value pairs. 113d4af9e69SDag-Erling SmørgravThe keywords are 114d4af9e69SDag-Erling Smørgrav.Dq user , 115d4af9e69SDag-Erling Smørgrav.Dq host , 116462c32cbSDag-Erling Smørgrav.Dq laddr , 117462c32cbSDag-Erling Smørgrav.Dq lport , 118d4af9e69SDag-Erling Smørgravand 119d4af9e69SDag-Erling Smørgrav.Dq addr . 120d4af9e69SDag-Erling SmørgravAll are required and may be supplied in any order, either with multiple 121d4af9e69SDag-Erling Smørgrav.Fl C 122d4af9e69SDag-Erling Smørgravoptions or as a comma-separated list. 123b15c8340SDag-Erling Smørgrav.It Fl c Ar host_certificate_file 124b15c8340SDag-Erling SmørgravSpecifies a path to a certificate file to identify 125b15c8340SDag-Erling Smørgrav.Nm 126b15c8340SDag-Erling Smørgravduring key exchange. 127b15c8340SDag-Erling SmørgravThe certificate file must match a host key file specified using the 128b15c8340SDag-Erling Smørgrav.Fl h 129b15c8340SDag-Erling Smørgravoption or the 130b15c8340SDag-Erling Smørgrav.Cm HostKey 131b15c8340SDag-Erling Smørgravconfiguration directive. 1321ec0d754SDag-Erling Smørgrav.It Fl D 1331ec0d754SDag-Erling SmørgravWhen this option is specified, 1341ec0d754SDag-Erling Smørgrav.Nm 1351ec0d754SDag-Erling Smørgravwill not detach and does not become a daemon. 1361ec0d754SDag-Erling SmørgravThis allows easy monitoring of 1371ec0d754SDag-Erling Smørgrav.Nm sshd . 138511b41d2SMark Murray.It Fl d 1393c6ae118SKris KennawayDebug mode. 140b15c8340SDag-Erling SmørgravThe server sends verbose debug output to standard error, 141b15c8340SDag-Erling Smørgravand does not put itself in the background. 1423c6ae118SKris KennawayThe server also will not fork and will only process one connection. 1433c6ae118SKris KennawayThis option is only intended for debugging for the server. 144e73e9afaSDag-Erling SmørgravMultiple 145e73e9afaSDag-Erling Smørgrav.Fl d 146e73e9afaSDag-Erling Smørgravoptions increase the debugging level. 14709958426SBrian FeldmanMaximum is 3. 148e4a9863fSDag-Erling Smørgrav.It Fl E Ar log_file 149e4a9863fSDag-Erling SmørgravAppend debug logs to 150e4a9863fSDag-Erling Smørgrav.Ar log_file 151e4a9863fSDag-Erling Smørgravinstead of the system log. 152ca3176e7SBrian Feldman.It Fl e 153e4a9863fSDag-Erling SmørgravWrite debug logs to standard error instead of the system log. 154d4af9e69SDag-Erling Smørgrav.It Fl f Ar config_file 1553c6ae118SKris KennawaySpecifies the name of the configuration file. 1563c6ae118SKris KennawayThe default is 1572134165cSKris Kennaway.Pa /etc/ssh/sshd_config . 158511b41d2SMark Murray.Nm 159511b41d2SMark Murrayrefuses to start if there is no configuration file. 160511b41d2SMark Murray.It Fl g Ar login_grace_time 161511b41d2SMark MurrayGives the grace time for clients to authenticate themselves (default 162f388f5efSDag-Erling Smørgrav120 seconds). 1633c6ae118SKris KennawayIf the client fails to authenticate the user within 1643c6ae118SKris Kennawaythis many seconds, the server disconnects and exits. 1653c6ae118SKris KennawayA value of zero indicates no limit. 166511b41d2SMark Murray.It Fl h Ar host_key_file 167af12a3e7SDag-Erling SmørgravSpecifies a file from which a host key is read. 168511b41d2SMark MurrayThis option must be given if 169511b41d2SMark Murray.Nm 170511b41d2SMark Murrayis not run as root (as the normal 171af12a3e7SDag-Erling Smørgravhost key files are normally not readable by anyone but root). 172af12a3e7SDag-Erling SmørgravThe default is 173af12a3e7SDag-Erling Smørgrav.Pa /etc/ssh/ssh_host_key 174af12a3e7SDag-Erling Smørgravfor protocol version 1, and 1754a421b63SDag-Erling Smørgrav.Pa /etc/ssh/ssh_host_dsa_key , 176f7167e0eSDag-Erling Smørgrav.Pa /etc/ssh/ssh_host_ecdsa_key . 177f7167e0eSDag-Erling Smørgrav.Pa /etc/ssh/ssh_host_ed25519_key 178d4af9e69SDag-Erling Smørgravand 1794a421b63SDag-Erling Smørgrav.Pa /etc/ssh/ssh_host_rsa_key 180af12a3e7SDag-Erling Smørgravfor protocol version 2. 181ca3176e7SBrian FeldmanIt is possible to have multiple host key files for 182ca3176e7SBrian Feldmanthe different protocol versions and host key algorithms. 183511b41d2SMark Murray.It Fl i 184511b41d2SMark MurraySpecifies that 185511b41d2SMark Murray.Nm 186e73e9afaSDag-Erling Smørgravis being run from 187e73e9afaSDag-Erling Smørgrav.Xr inetd 8 . 188511b41d2SMark Murray.Nm 189511b41d2SMark Murrayis normally not run 190511b41d2SMark Murrayfrom inetd because it needs to generate the server key before it can 1913c6ae118SKris Kennawayrespond to the client, and this may take tens of seconds. 1923c6ae118SKris KennawayClients would have to wait too long if the key was regenerated every time. 193333ee039SDag-Erling SmørgravHowever, with small key sizes (e.g. 512) using 194511b41d2SMark Murray.Nm 195511b41d2SMark Murrayfrom inetd may 196511b41d2SMark Murraybe feasible. 197511b41d2SMark Murray.It Fl k Ar key_gen_time 198ca3176e7SBrian FeldmanSpecifies how often the ephemeral protocol version 1 server key is 199ca3176e7SBrian Feldmanregenerated (default 3600 seconds, or one hour). 2003c6ae118SKris KennawayThe motivation for regenerating the key fairly 2011ec0d754SDag-Erling Smørgravoften is that the key is not stored anywhere, and after about an hour 202511b41d2SMark Murrayit becomes impossible to recover the key for decrypting intercepted 203511b41d2SMark Murraycommunications even if the machine is cracked into or physically 2043c6ae118SKris Kennawayseized. 2053c6ae118SKris KennawayA value of zero indicates that the key will never be regenerated. 206af12a3e7SDag-Erling Smørgrav.It Fl o Ar option 207af12a3e7SDag-Erling SmørgravCan be used to give options in the format used in the configuration file. 208af12a3e7SDag-Erling SmørgravThis is useful for specifying options for which there is no separate 209af12a3e7SDag-Erling Smørgravcommand-line flag. 2101ec0d754SDag-Erling SmørgravFor full details of the options, and their values, see 2111ec0d754SDag-Erling Smørgrav.Xr sshd_config 5 . 212511b41d2SMark Murray.It Fl p Ar port 213511b41d2SMark MurraySpecifies the port on which the server listens for connections 214511b41d2SMark Murray(default 22). 215af12a3e7SDag-Erling SmørgravMultiple port options are permitted. 216b74df5b2SDag-Erling SmørgravPorts specified in the configuration file with the 217b74df5b2SDag-Erling Smørgrav.Cm Port 218b74df5b2SDag-Erling Smørgravoption are ignored when a command-line port is specified. 219b74df5b2SDag-Erling SmørgravPorts specified using the 220b74df5b2SDag-Erling Smørgrav.Cm ListenAddress 221b74df5b2SDag-Erling Smørgravoption override command-line ports. 222511b41d2SMark Murray.It Fl q 2233c6ae118SKris KennawayQuiet mode. 2243c6ae118SKris KennawayNothing is sent to the system log. 2253c6ae118SKris KennawayNormally the beginning, 226511b41d2SMark Murrayauthentication, and termination of each connection is logged. 227d4af9e69SDag-Erling Smørgrav.It Fl T 228d4af9e69SDag-Erling SmørgravExtended test mode. 229d4af9e69SDag-Erling SmørgravCheck the validity of the configuration file, output the effective configuration 230d4af9e69SDag-Erling Smørgravto stdout and then exit. 231d4af9e69SDag-Erling SmørgravOptionally, 232d4af9e69SDag-Erling Smørgrav.Cm Match 233d4af9e69SDag-Erling Smørgravrules may be applied by specifying the connection parameters using one or more 234d4af9e69SDag-Erling Smørgrav.Fl C 235d4af9e69SDag-Erling Smørgravoptions. 236af12a3e7SDag-Erling Smørgrav.It Fl t 237af12a3e7SDag-Erling SmørgravTest mode. 238af12a3e7SDag-Erling SmørgravOnly check the validity of the configuration file and sanity of the keys. 239af12a3e7SDag-Erling SmørgravThis is useful for updating 240af12a3e7SDag-Erling Smørgrav.Nm 241af12a3e7SDag-Erling Smørgravreliably as configuration options may change. 242c2d3a559SKris Kennaway.It Fl u Ar len 243c2d3a559SKris KennawayThis option is used to specify the size of the field 244c2d3a559SKris Kennawayin the 245c2d3a559SKris Kennaway.Li utmp 246c2d3a559SKris Kennawaystructure that holds the remote host name. 247c2d3a559SKris KennawayIf the resolved host name is longer than 248c2d3a559SKris Kennaway.Ar len , 249c2d3a559SKris Kennawaythe dotted decimal value will be used instead. 250c2d3a559SKris KennawayThis allows hosts with very long host names that 251c2d3a559SKris Kennawayoverflow this field to still be uniquely identified. 252c2d3a559SKris KennawaySpecifying 253c2d3a559SKris Kennaway.Fl u0 254c2d3a559SKris Kennawayindicates that only dotted decimal addresses 255c2d3a559SKris Kennawayshould be put into the 256c2d3a559SKris Kennaway.Pa utmp 257c2d3a559SKris Kennawayfile. 258af12a3e7SDag-Erling Smørgrav.Fl u0 259e73e9afaSDag-Erling Smørgravmay also be used to prevent 260af12a3e7SDag-Erling Smørgrav.Nm 261af12a3e7SDag-Erling Smørgravfrom making DNS requests unless the authentication 262af12a3e7SDag-Erling Smørgravmechanism or configuration requires it. 263af12a3e7SDag-Erling SmørgravAuthentication mechanisms that may require DNS include 264af12a3e7SDag-Erling Smørgrav.Cm RhostsRSAAuthentication , 265b74df5b2SDag-Erling Smørgrav.Cm HostbasedAuthentication , 266af12a3e7SDag-Erling Smørgravand using a 267af12a3e7SDag-Erling Smørgrav.Cm from="pattern-list" 268af12a3e7SDag-Erling Smørgravoption in a key file. 269af12a3e7SDag-Erling SmørgravConfiguration options that require DNS include using a 270af12a3e7SDag-Erling SmørgravUSER@HOST pattern in 271af12a3e7SDag-Erling Smørgrav.Cm AllowUsers 272af12a3e7SDag-Erling Smørgravor 273af12a3e7SDag-Erling Smørgrav.Cm DenyUsers . 274511b41d2SMark Murray.El 275b74df5b2SDag-Erling Smørgrav.Sh AUTHENTICATION 276b74df5b2SDag-Erling SmørgravThe OpenSSH SSH daemon supports SSH protocols 1 and 2. 277b15c8340SDag-Erling SmørgravThe default is to use protocol 2 only, 278b74df5b2SDag-Erling Smørgravthough this can be changed via the 279b74df5b2SDag-Erling Smørgrav.Cm Protocol 280b74df5b2SDag-Erling Smørgravoption in 281614c49a9SDag-Erling Smørgrav.Xr sshd_config 5 . 282*bc5531deSDag-Erling SmørgravProtocol 2 supports DSA, ECDSA, Ed25519 and RSA keys; 283b74df5b2SDag-Erling Smørgravprotocol 1 only supports RSA keys. 284b74df5b2SDag-Erling SmørgravFor both protocols, 285b74df5b2SDag-Erling Smørgraveach host has a host-specific key, 286b74df5b2SDag-Erling Smørgravnormally 2048 bits, 287b74df5b2SDag-Erling Smørgravused to identify the host. 288b74df5b2SDag-Erling Smørgrav.Pp 289b74df5b2SDag-Erling SmørgravForward security for protocol 1 is provided through 290b74df5b2SDag-Erling Smørgravan additional server key, 291b74df5b2SDag-Erling Smørgravnormally 768 bits, 292b74df5b2SDag-Erling Smørgravgenerated when the server starts. 293b74df5b2SDag-Erling SmørgravThis key is normally regenerated every hour if it has been used, and 294b74df5b2SDag-Erling Smørgravis never stored on disk. 295b74df5b2SDag-Erling SmørgravWhenever a client connects, the daemon responds with its public 296b74df5b2SDag-Erling Smørgravhost and server keys. 297b74df5b2SDag-Erling SmørgravThe client compares the 298b74df5b2SDag-Erling SmørgravRSA host key against its own database to verify that it has not changed. 299b74df5b2SDag-Erling SmørgravThe client then generates a 256-bit random number. 300b74df5b2SDag-Erling SmørgravIt encrypts this 301b74df5b2SDag-Erling Smørgravrandom number using both the host key and the server key, and sends 302b74df5b2SDag-Erling Smørgravthe encrypted number to the server. 303b74df5b2SDag-Erling SmørgravBoth sides then use this 304b74df5b2SDag-Erling Smørgravrandom number as a session key which is used to encrypt all further 305b74df5b2SDag-Erling Smørgravcommunications in the session. 306b74df5b2SDag-Erling SmørgravThe rest of the session is encrypted 307b74df5b2SDag-Erling Smørgravusing a conventional cipher, currently Blowfish or 3DES, with 3DES 308b74df5b2SDag-Erling Smørgravbeing used by default. 309b74df5b2SDag-Erling SmørgravThe client selects the encryption algorithm 310b74df5b2SDag-Erling Smørgravto use from those offered by the server. 311b74df5b2SDag-Erling Smørgrav.Pp 312b74df5b2SDag-Erling SmørgravFor protocol 2, 313b74df5b2SDag-Erling Smørgravforward security is provided through a Diffie-Hellman key agreement. 314b74df5b2SDag-Erling SmørgravThis key agreement results in a shared session key. 315b74df5b2SDag-Erling SmørgravThe rest of the session is encrypted using a symmetric cipher, currently 316b74df5b2SDag-Erling Smørgrav128-bit AES, Blowfish, 3DES, CAST128, Arcfour, 192-bit AES, or 256-bit AES. 317b74df5b2SDag-Erling SmørgravThe client selects the encryption algorithm 318b74df5b2SDag-Erling Smørgravto use from those offered by the server. 319b74df5b2SDag-Erling SmørgravAdditionally, session integrity is provided 320b74df5b2SDag-Erling Smørgravthrough a cryptographic message authentication code 3216888a9beSDag-Erling Smørgrav(hmac-md5, hmac-sha1, umac-64, umac-128, hmac-ripemd160, 322e146993eSDag-Erling Smørgravhmac-sha2-256 or hmac-sha2-512). 323b74df5b2SDag-Erling Smørgrav.Pp 324b74df5b2SDag-Erling SmørgravFinally, the server and the client enter an authentication dialog. 325b74df5b2SDag-Erling SmørgravThe client tries to authenticate itself using 326b74df5b2SDag-Erling Smørgravhost-based authentication, 327b74df5b2SDag-Erling Smørgravpublic key authentication, 328b74df5b2SDag-Erling Smørgravchallenge-response authentication, 329b74df5b2SDag-Erling Smørgravor password authentication. 330b74df5b2SDag-Erling Smørgrav.Pp 331b74df5b2SDag-Erling SmørgravRegardless of the authentication type, the account is checked to 332b74df5b2SDag-Erling Smørgravensure that it is accessible. An account is not accessible if it is 333b74df5b2SDag-Erling Smørgravlocked, listed in 334b74df5b2SDag-Erling Smørgrav.Cm DenyUsers 335b74df5b2SDag-Erling Smørgravor its group is listed in 336b74df5b2SDag-Erling Smørgrav.Cm DenyGroups 337b74df5b2SDag-Erling Smørgrav\&. The definition of a locked account is system dependant. Some platforms 338b74df5b2SDag-Erling Smørgravhave their own account database (eg AIX) and some modify the passwd field ( 339b74df5b2SDag-Erling Smørgrav.Ql \&*LK\&* 340b74df5b2SDag-Erling Smørgravon Solaris and UnixWare, 341b74df5b2SDag-Erling Smørgrav.Ql \&* 342b74df5b2SDag-Erling Smørgravon HP-UX, containing 343b74df5b2SDag-Erling Smørgrav.Ql Nologin 344b74df5b2SDag-Erling Smørgravon Tru64, 345b74df5b2SDag-Erling Smørgrava leading 346b74df5b2SDag-Erling Smørgrav.Ql \&*LOCKED\&* 347b74df5b2SDag-Erling Smørgravon FreeBSD and a leading 348d4af9e69SDag-Erling Smørgrav.Ql \&! 349d4af9e69SDag-Erling Smørgravon most Linuxes). 350d4af9e69SDag-Erling SmørgravIf there is a requirement to disable password authentication 351b74df5b2SDag-Erling Smørgravfor the account while allowing still public-key, then the passwd field 352b74df5b2SDag-Erling Smørgravshould be set to something other than these values (eg 353b74df5b2SDag-Erling Smørgrav.Ql NP 354b74df5b2SDag-Erling Smørgravor 355b74df5b2SDag-Erling Smørgrav.Ql \&*NP\&* 356b74df5b2SDag-Erling Smørgrav). 357b74df5b2SDag-Erling Smørgrav.Pp 358b74df5b2SDag-Erling SmørgravIf the client successfully authenticates itself, a dialog for 359b74df5b2SDag-Erling Smørgravpreparing the session is entered. 360b74df5b2SDag-Erling SmørgravAt this time the client may request 361b74df5b2SDag-Erling Smørgravthings like allocating a pseudo-tty, forwarding X11 connections, 362b74df5b2SDag-Erling Smørgravforwarding TCP connections, or forwarding the authentication agent 363b74df5b2SDag-Erling Smørgravconnection over the secure channel. 364b74df5b2SDag-Erling Smørgrav.Pp 365333ee039SDag-Erling SmørgravAfter this, the client either requests a shell or execution of a command. 366b74df5b2SDag-Erling SmørgravThe sides then enter session mode. 367b74df5b2SDag-Erling SmørgravIn this mode, either side may send 368b74df5b2SDag-Erling Smørgravdata at any time, and such data is forwarded to/from the shell or 369b74df5b2SDag-Erling Smørgravcommand on the server side, and the user terminal in the client side. 370b74df5b2SDag-Erling Smørgrav.Pp 371b74df5b2SDag-Erling SmørgravWhen the user program terminates and all forwarded X11 and other 372b74df5b2SDag-Erling Smørgravconnections have been closed, the server sends command exit status to 373b74df5b2SDag-Erling Smørgravthe client, and both sides exit. 374511b41d2SMark Murray.Sh LOGIN PROCESS 375511b41d2SMark MurrayWhen a user successfully logs in, 376511b41d2SMark Murray.Nm 377511b41d2SMark Murraydoes the following: 378511b41d2SMark Murray.Bl -enum -offset indent 379511b41d2SMark Murray.It 380511b41d2SMark MurrayIf the login is on a tty, and no command has been specified, 381511b41d2SMark Murrayprints last login time and 382511b41d2SMark Murray.Pa /etc/motd 383511b41d2SMark Murray(unless prevented in the configuration file or by 384d4ecd108SDag-Erling Smørgrav.Pa ~/.hushlogin ; 385511b41d2SMark Murraysee the 386511b41d2SMark Murray.Sx FILES 387511b41d2SMark Murraysection). 388511b41d2SMark Murray.It 389511b41d2SMark MurrayIf the login is on a tty, records login time. 390511b41d2SMark Murray.It 391511b41d2SMark MurrayChecks 39235d4ccfbSDag-Erling Smørgrav.Pa /etc/nologin and 39335d4ccfbSDag-Erling Smørgrav.Pa /var/run/nologin ; 39435d4ccfbSDag-Erling Smørgravif one exists, it prints the contents and quits 395511b41d2SMark Murray(unless root). 396511b41d2SMark Murray.It 397511b41d2SMark MurrayChanges to run with normal user privileges. 398511b41d2SMark Murray.It 399511b41d2SMark MurraySets up basic environment. 400511b41d2SMark Murray.It 4011ec0d754SDag-Erling SmørgravReads the file 402d4ecd108SDag-Erling Smørgrav.Pa ~/.ssh/environment , 4031ec0d754SDag-Erling Smørgravif it exists, and users are allowed to change their environment. 404f388f5efSDag-Erling SmørgravSee the 405f388f5efSDag-Erling Smørgrav.Cm PermitUserEnvironment 406f388f5efSDag-Erling Smørgravoption in 407f388f5efSDag-Erling Smørgrav.Xr sshd_config 5 . 408511b41d2SMark Murray.It 409511b41d2SMark MurrayChanges to user's home directory. 410511b41d2SMark Murray.It 411511b41d2SMark MurrayIf 412d4ecd108SDag-Erling Smørgrav.Pa ~/.ssh/rc 413a0ee8cc6SDag-Erling Smørgravexists and the 414a0ee8cc6SDag-Erling Smørgrav.Xr sshd_config 5 415a0ee8cc6SDag-Erling Smørgrav.Cm PermitUserRC 416a0ee8cc6SDag-Erling Smørgravoption is set, runs it; else if 4172134165cSKris Kennaway.Pa /etc/ssh/sshrc 418511b41d2SMark Murrayexists, runs 41935d4ccfbSDag-Erling Smørgravit; otherwise runs 42035d4ccfbSDag-Erling Smørgrav.Xr xauth 1 . 4216a8633dbSKris KennawayThe 422511b41d2SMark Murray.Dq rc 423511b41d2SMark Murrayfiles are given the X11 424333ee039SDag-Erling Smørgravauthentication protocol and cookie in standard input. 425333ee039SDag-Erling SmørgravSee 426333ee039SDag-Erling Smørgrav.Sx SSHRC , 427333ee039SDag-Erling Smørgravbelow. 428511b41d2SMark Murray.It 429511b41d2SMark MurrayRuns user's shell or command. 430511b41d2SMark Murray.El 431333ee039SDag-Erling Smørgrav.Sh SSHRC 432333ee039SDag-Erling SmørgravIf the file 433333ee039SDag-Erling Smørgrav.Pa ~/.ssh/rc 434333ee039SDag-Erling Smørgravexists, 435333ee039SDag-Erling Smørgrav.Xr sh 1 436333ee039SDag-Erling Smørgravruns it after reading the 437333ee039SDag-Erling Smørgravenvironment files but before starting the user's shell or command. 438333ee039SDag-Erling SmørgravIt must not produce any output on stdout; stderr must be used 439333ee039SDag-Erling Smørgravinstead. 440333ee039SDag-Erling SmørgravIf X11 forwarding is in use, it will receive the "proto cookie" pair in 441333ee039SDag-Erling Smørgravits standard input (and 442333ee039SDag-Erling Smørgrav.Ev DISPLAY 443333ee039SDag-Erling Smørgravin its environment). 444333ee039SDag-Erling SmørgravThe script must call 445333ee039SDag-Erling Smørgrav.Xr xauth 1 446333ee039SDag-Erling Smørgravbecause 447333ee039SDag-Erling Smørgrav.Nm 448333ee039SDag-Erling Smørgravwill not run xauth automatically to add X11 cookies. 449ca3176e7SBrian Feldman.Pp 450333ee039SDag-Erling SmørgravThe primary purpose of this file is to run any initialization routines 451333ee039SDag-Erling Smørgravwhich may be needed before the user's home directory becomes 452333ee039SDag-Erling Smørgravaccessible; AFS is a particular example of such an environment. 453333ee039SDag-Erling Smørgrav.Pp 454333ee039SDag-Erling SmørgravThis file will probably contain some initialization code followed by 455333ee039SDag-Erling Smørgravsomething similar to: 456333ee039SDag-Erling Smørgrav.Bd -literal -offset 3n 457333ee039SDag-Erling Smørgravif read proto cookie && [ -n "$DISPLAY" ]; then 458333ee039SDag-Erling Smørgrav if [ `echo $DISPLAY | cut -c1-10` = 'localhost:' ]; then 459333ee039SDag-Erling Smørgrav # X11UseLocalhost=yes 460333ee039SDag-Erling Smørgrav echo add unix:`echo $DISPLAY | 461333ee039SDag-Erling Smørgrav cut -c11-` $proto $cookie 462333ee039SDag-Erling Smørgrav else 463333ee039SDag-Erling Smørgrav # X11UseLocalhost=no 464333ee039SDag-Erling Smørgrav echo add $DISPLAY $proto $cookie 465333ee039SDag-Erling Smørgrav fi | xauth -q - 466333ee039SDag-Erling Smørgravfi 467333ee039SDag-Erling Smørgrav.Ed 468333ee039SDag-Erling Smørgrav.Pp 469333ee039SDag-Erling SmørgravIf this file does not exist, 470333ee039SDag-Erling Smørgrav.Pa /etc/ssh/sshrc 471333ee039SDag-Erling Smørgravis run, and if that 472333ee039SDag-Erling Smørgravdoes not exist either, xauth is used to add the cookie. 473333ee039SDag-Erling Smørgrav.Sh AUTHORIZED_KEYS FILE FORMAT 474333ee039SDag-Erling Smørgrav.Cm AuthorizedKeysFile 475e146993eSDag-Erling Smørgravspecifies the files containing public keys for 476333ee039SDag-Erling Smørgravpublic key authentication; 477333ee039SDag-Erling Smørgravif none is specified, the default is 478e146993eSDag-Erling Smørgrav.Pa ~/.ssh/authorized_keys 479e146993eSDag-Erling Smørgravand 480e146993eSDag-Erling Smørgrav.Pa ~/.ssh/authorized_keys2 . 4813c6ae118SKris KennawayEach line of the file contains one 482511b41d2SMark Murraykey (empty lines and lines starting with a 483511b41d2SMark Murray.Ql # 484511b41d2SMark Murrayare ignored as 4853c6ae118SKris Kennawaycomments). 486333ee039SDag-Erling SmørgravProtocol 1 public keys consist of the following space-separated fields: 487333ee039SDag-Erling Smørgravoptions, bits, exponent, modulus, comment. 488333ee039SDag-Erling SmørgravProtocol 2 public key consist of: 489333ee039SDag-Erling Smørgravoptions, keytype, base64-encoded key, comment. 490333ee039SDag-Erling SmørgravThe options field is optional; 491333ee039SDag-Erling Smørgravits presence is determined by whether the line starts 492f388f5efSDag-Erling Smørgravwith a number or not (the options field never starts with a number). 493333ee039SDag-Erling SmørgravThe bits, exponent, modulus, and comment fields give the RSA key for 494ca3176e7SBrian Feldmanprotocol version 1; the 495511b41d2SMark Murraycomment field is not used for anything (but may be convenient for the 496511b41d2SMark Murrayuser to identify the key). 497ca3176e7SBrian FeldmanFor protocol version 2 the keytype is 4984a421b63SDag-Erling Smørgrav.Dq ecdsa-sha2-nistp256 , 4994a421b63SDag-Erling Smørgrav.Dq ecdsa-sha2-nistp384 , 5004a421b63SDag-Erling Smørgrav.Dq ecdsa-sha2-nistp521 , 501f7167e0eSDag-Erling Smørgrav.Dq ssh-ed25519 , 502ca3176e7SBrian Feldman.Dq ssh-dss 503ca3176e7SBrian Feldmanor 504ca3176e7SBrian Feldman.Dq ssh-rsa . 505511b41d2SMark Murray.Pp 506511b41d2SMark MurrayNote that lines in this file are usually several hundred bytes long 507aa49c926SDag-Erling Smørgrav(because of the size of the public key encoding) up to a limit of 508aa49c926SDag-Erling Smørgrav8 kilobytes, which permits DSA keys up to 8 kilobits and RSA 509aa49c926SDag-Erling Smørgravkeys up to 16 kilobits. 5103c6ae118SKris KennawayYou don't want to type them in; instead, copy the 511ca3176e7SBrian Feldman.Pa identity.pub , 512333ee039SDag-Erling Smørgrav.Pa id_dsa.pub , 5134a421b63SDag-Erling Smørgrav.Pa id_ecdsa.pub , 514f7167e0eSDag-Erling Smørgrav.Pa id_ed25519.pub , 515ca3176e7SBrian Feldmanor the 516ca3176e7SBrian Feldman.Pa id_rsa.pub 517511b41d2SMark Murrayfile and edit it. 518511b41d2SMark Murray.Pp 519614c49a9SDag-Erling Smørgrav.Nm 520614c49a9SDag-Erling Smørgravenforces a minimum RSA key modulus size for protocol 1 521614c49a9SDag-Erling Smørgravand protocol 2 keys of 768 bits. 522614c49a9SDag-Erling Smørgrav.Pp 523c2d3a559SKris KennawayThe options (if present) consist of comma-separated option 5243c6ae118SKris Kennawayspecifications. 5253c6ae118SKris KennawayNo spaces are permitted, except within double quotes. 526af12a3e7SDag-Erling SmørgravThe following option specifications are supported (note 527af12a3e7SDag-Erling Smørgravthat option keywords are case-insensitive): 528511b41d2SMark Murray.Bl -tag -width Ds 529b15c8340SDag-Erling Smørgrav.It Cm cert-authority 530b15c8340SDag-Erling SmørgravSpecifies that the listed key is a certification authority (CA) that is 531b15c8340SDag-Erling Smørgravtrusted to validate signed certificates for user authentication. 532b15c8340SDag-Erling Smørgrav.Pp 533b15c8340SDag-Erling SmørgravCertificates may encode access restrictions similar to these key options. 534b15c8340SDag-Erling SmørgravIf both certificate restrictions and key options are present, the most 535b15c8340SDag-Erling Smørgravrestrictive union of the two is applied. 536511b41d2SMark Murray.It Cm command="command" 537511b41d2SMark MurraySpecifies that the command is executed whenever this key is used for 5383c6ae118SKris Kennawayauthentication. 5393c6ae118SKris KennawayThe command supplied by the user (if any) is ignored. 540af12a3e7SDag-Erling SmørgravThe command is run on a pty if the client requests a pty; 5413c6ae118SKris Kennawayotherwise it is run without a tty. 542e73e9afaSDag-Erling SmørgravIf an 8-bit clean channel is required, 543af12a3e7SDag-Erling Smørgravone must not request a pty or should specify 544ca3176e7SBrian Feldman.Cm no-pty . 5453c6ae118SKris KennawayA quote may be included in the command by quoting it with a backslash. 5463c6ae118SKris KennawayThis option might be useful 547f388f5efSDag-Erling Smørgravto restrict certain public keys to perform just a specific operation. 5483c6ae118SKris KennawayAn example might be a key that permits remote backups but nothing else. 549b74df5b2SDag-Erling SmørgravNote that the client may specify TCP and/or X11 550e8aafc91SKris Kennawayforwarding unless they are explicitly prohibited. 551333ee039SDag-Erling SmørgravThe command originally supplied by the client is available in the 552333ee039SDag-Erling Smørgrav.Ev SSH_ORIGINAL_COMMAND 553333ee039SDag-Erling Smørgravenvironment variable. 554af12a3e7SDag-Erling SmørgravNote that this option applies to shell, command or subsystem execution. 555b15c8340SDag-Erling SmørgravAlso note that this command may be superseded by either a 556b15c8340SDag-Erling Smørgrav.Xr sshd_config 5 557b15c8340SDag-Erling Smørgrav.Cm ForceCommand 558b15c8340SDag-Erling Smørgravdirective or a command embedded in a certificate. 559511b41d2SMark Murray.It Cm environment="NAME=value" 560511b41d2SMark MurraySpecifies that the string is to be added to the environment when 5613c6ae118SKris Kennawaylogging in using this key. 5623c6ae118SKris KennawayEnvironment variables set this way 5633c6ae118SKris Kennawayoverride other default environment values. 5643c6ae118SKris KennawayMultiple options of this type are permitted. 565f388f5efSDag-Erling SmørgravEnvironment processing is disabled by default and is 566f388f5efSDag-Erling Smørgravcontrolled via the 567f388f5efSDag-Erling Smørgrav.Cm PermitUserEnvironment 568f388f5efSDag-Erling Smørgravoption. 569af12a3e7SDag-Erling SmørgravThis option is automatically disabled if 570af12a3e7SDag-Erling Smørgrav.Cm UseLogin 571af12a3e7SDag-Erling Smørgravis enabled. 572333ee039SDag-Erling Smørgrav.It Cm from="pattern-list" 573d4af9e69SDag-Erling SmørgravSpecifies that in addition to public key authentication, either the canonical 574d4af9e69SDag-Erling Smørgravname of the remote host or its IP address must be present in the 575d4af9e69SDag-Erling Smørgravcomma-separated list of patterns. 576e4a9863fSDag-Erling SmørgravSee PATTERNS in 577333ee039SDag-Erling Smørgrav.Xr ssh_config 5 578333ee039SDag-Erling Smørgravfor more information on patterns. 579d4af9e69SDag-Erling Smørgrav.Pp 580d4af9e69SDag-Erling SmørgravIn addition to the wildcard matching that may be applied to hostnames or 581d4af9e69SDag-Erling Smørgravaddresses, a 582d4af9e69SDag-Erling Smørgrav.Cm from 5837aee6ffeSDag-Erling Smørgravstanza may match IP addresses using CIDR address/masklen notation. 584d4af9e69SDag-Erling Smørgrav.Pp 585d4af9e69SDag-Erling SmørgravThe purpose of this option is to optionally increase security: public key 586d4af9e69SDag-Erling Smørgravauthentication by itself does not trust the network or name servers or 587d4af9e69SDag-Erling Smørgravanything (but the key); however, if somebody somehow steals the key, the key 588d4af9e69SDag-Erling Smørgravpermits an intruder to log in from anywhere in the world. 589d4af9e69SDag-Erling SmørgravThis additional option makes using a stolen key more difficult (name 590d4af9e69SDag-Erling Smørgravservers and/or routers would have to be compromised in addition to 591d4af9e69SDag-Erling Smørgravjust the key). 592511b41d2SMark Murray.It Cm no-agent-forwarding 593511b41d2SMark MurrayForbids authentication agent forwarding when this key is used for 594511b41d2SMark Murrayauthentication. 595333ee039SDag-Erling Smørgrav.It Cm no-port-forwarding 596333ee039SDag-Erling SmørgravForbids TCP forwarding when this key is used for authentication. 597333ee039SDag-Erling SmørgravAny port forward requests by the client will return an error. 598333ee039SDag-Erling SmørgravThis might be used, e.g. in connection with the 599333ee039SDag-Erling Smørgrav.Cm command 600333ee039SDag-Erling Smørgravoption. 601511b41d2SMark Murray.It Cm no-pty 602511b41d2SMark MurrayPrevents tty allocation (a request to allocate a pty will fail). 603d4af9e69SDag-Erling Smørgrav.It Cm no-user-rc 604d4af9e69SDag-Erling SmørgravDisables execution of 605d4af9e69SDag-Erling Smørgrav.Pa ~/.ssh/rc . 606333ee039SDag-Erling Smørgrav.It Cm no-X11-forwarding 607333ee039SDag-Erling SmørgravForbids X11 forwarding when this key is used for authentication. 608333ee039SDag-Erling SmørgravAny X11 forward requests by the client will return an error. 609ca3176e7SBrian Feldman.It Cm permitopen="host:port" 610*bc5531deSDag-Erling SmørgravLimit local port forwarding with 611*bc5531deSDag-Erling Smørgrav.Xr ssh 1 612*bc5531deSDag-Erling Smørgrav.Fl L 613*bc5531deSDag-Erling Smørgravsuch that it may only connect to the specified host and port. 614e2f6069cSDag-Erling SmørgravIPv6 addresses can be specified by enclosing the address in square brackets. 615af12a3e7SDag-Erling SmørgravMultiple 616ca3176e7SBrian Feldman.Cm permitopen 617cf2b5f3bSDag-Erling Smørgravoptions may be applied separated by commas. 618cf2b5f3bSDag-Erling SmørgravNo pattern matching is performed on the specified hostnames, 619cf2b5f3bSDag-Erling Smørgravthey must be literal domains or addresses. 620462c32cbSDag-Erling SmørgravA port specification of 621462c32cbSDag-Erling Smørgrav.Cm * 622462c32cbSDag-Erling Smørgravmatches any port. 623e2f6069cSDag-Erling Smørgrav.It Cm principals="principals" 624e2f6069cSDag-Erling SmørgravOn a 625e2f6069cSDag-Erling Smørgrav.Cm cert-authority 626e2f6069cSDag-Erling Smørgravline, specifies allowed principals for certificate authentication as a 627e2f6069cSDag-Erling Smørgravcomma-separated list. 628e2f6069cSDag-Erling SmørgravAt least one name from the list must appear in the certificate's 629e2f6069cSDag-Erling Smørgravlist of principals for the certificate to be accepted. 630e2f6069cSDag-Erling SmørgravThis option is ignored for keys that are not marked as trusted certificate 631e2f6069cSDag-Erling Smørgravsigners using the 632e2f6069cSDag-Erling Smørgrav.Cm cert-authority 633e2f6069cSDag-Erling Smørgravoption. 634b74df5b2SDag-Erling Smørgrav.It Cm tunnel="n" 635b74df5b2SDag-Erling SmørgravForce a 636b74df5b2SDag-Erling Smørgrav.Xr tun 4 637b74df5b2SDag-Erling Smørgravdevice on the server. 638b74df5b2SDag-Erling SmørgravWithout this option, the next available device will be used if 639b74df5b2SDag-Erling Smørgravthe client requests a tunnel. 640511b41d2SMark Murray.El 641ca3176e7SBrian Feldman.Pp 642333ee039SDag-Erling SmørgravAn example authorized_keys file: 643333ee039SDag-Erling Smørgrav.Bd -literal -offset 3n 644333ee039SDag-Erling Smørgrav# Comments allowed at start of line 645333ee039SDag-Erling Smørgravssh-rsa AAAAB3Nza...LiPk== user@example.net 646333ee039SDag-Erling Smørgravfrom="*.sales.example.net,!pc.sales.example.net" ssh-rsa 647333ee039SDag-Erling SmørgravAAAAB2...19Q== john@example.net 648333ee039SDag-Erling Smørgravcommand="dump /home",no-pty,no-port-forwarding ssh-dss 649333ee039SDag-Erling SmørgravAAAAC3...51R== example.net 650333ee039SDag-Erling Smørgravpermitopen="192.0.2.1:80",permitopen="192.0.2.2:25" ssh-dss 651333ee039SDag-Erling SmørgravAAAAB5...21S== 652333ee039SDag-Erling Smørgravtunnel="0",command="sh /etc/netstart tun0" ssh-rsa AAAA...== 653333ee039SDag-Erling Smørgravjane@example.net 654333ee039SDag-Erling Smørgrav.Ed 655511b41d2SMark Murray.Sh SSH_KNOWN_HOSTS FILE FORMAT 656511b41d2SMark MurrayThe 65735d4ccfbSDag-Erling Smørgrav.Pa /etc/ssh/ssh_known_hosts 658511b41d2SMark Murrayand 659d4ecd108SDag-Erling Smørgrav.Pa ~/.ssh/known_hosts 6603c6ae118SKris Kennawayfiles contain host public keys for all known hosts. 6613c6ae118SKris KennawayThe global file should 6625c51cd64SMike Pritchardbe prepared by the administrator (optional), and the per-user file is 663333ee039SDag-Erling Smørgravmaintained automatically: whenever the user connects from an unknown host, 664511b41d2SMark Murrayits key is added to the per-user file. 665511b41d2SMark Murray.Pp 666b15c8340SDag-Erling SmørgravEach line in these files contains the following fields: markers (optional), 667b15c8340SDag-Erling Smørgravhostnames, bits, exponent, modulus, comment. 6683c6ae118SKris KennawayThe fields are separated by spaces. 669511b41d2SMark Murray.Pp 670b15c8340SDag-Erling SmørgravThe marker is optional, but if it is present then it must be one of 671b15c8340SDag-Erling Smørgrav.Dq @cert-authority , 672b15c8340SDag-Erling Smørgravto indicate that the line contains a certification authority (CA) key, 673b15c8340SDag-Erling Smørgravor 674b15c8340SDag-Erling Smørgrav.Dq @revoked , 675b15c8340SDag-Erling Smørgravto indicate that the key contained on the line is revoked and must not ever 676b15c8340SDag-Erling Smørgravbe accepted. 677b15c8340SDag-Erling SmørgravOnly one marker should be used on a key line. 678b15c8340SDag-Erling Smørgrav.Pp 679cf2b5f3bSDag-Erling SmørgravHostnames is a comma-separated list of patterns 680333ee039SDag-Erling Smørgrav.Pf ( Ql * 681cf2b5f3bSDag-Erling Smørgravand 682cf2b5f3bSDag-Erling Smørgrav.Ql \&? 683cf2b5f3bSDag-Erling Smørgravact as 684511b41d2SMark Murraywildcards); each pattern in turn is matched against the canonical host 685511b41d2SMark Murrayname (when authenticating a client) or against the user-supplied 6863c6ae118SKris Kennawayname (when authenticating a server). 6873c6ae118SKris KennawayA pattern may also be preceded by 688cf2b5f3bSDag-Erling Smørgrav.Ql \&! 689511b41d2SMark Murrayto indicate negation: if the host name matches a negated 690511b41d2SMark Murraypattern, it is not accepted (by that line) even if it matched another 691511b41d2SMark Murraypattern on the line. 692333ee039SDag-Erling SmørgravA hostname or address may optionally be enclosed within 693333ee039SDag-Erling Smørgrav.Ql \&[ 694333ee039SDag-Erling Smørgravand 695333ee039SDag-Erling Smørgrav.Ql \&] 696333ee039SDag-Erling Smørgravbrackets then followed by 697333ee039SDag-Erling Smørgrav.Ql \&: 698333ee039SDag-Erling Smørgravand a non-standard port number. 699511b41d2SMark Murray.Pp 700aa49c926SDag-Erling SmørgravAlternately, hostnames may be stored in a hashed form which hides host names 701aa49c926SDag-Erling Smørgravand addresses should the file's contents be disclosed. 702aa49c926SDag-Erling SmørgravHashed hostnames start with a 703aa49c926SDag-Erling Smørgrav.Ql | 704aa49c926SDag-Erling Smørgravcharacter. 705aa49c926SDag-Erling SmørgravOnly one hashed hostname may appear on a single line and none of the above 706aa49c926SDag-Erling Smørgravnegation or wildcard operators may be applied. 707aa49c926SDag-Erling Smørgrav.Pp 708e8aafc91SKris KennawayBits, exponent, and modulus are taken directly from the RSA host key; they 709333ee039SDag-Erling Smørgravcan be obtained, for example, from 7102134165cSKris Kennaway.Pa /etc/ssh/ssh_host_key.pub . 711511b41d2SMark MurrayThe optional comment field continues to the end of the line, and is not used. 712511b41d2SMark Murray.Pp 713511b41d2SMark MurrayLines starting with 714511b41d2SMark Murray.Ql # 715511b41d2SMark Murrayand empty lines are ignored as comments. 716511b41d2SMark Murray.Pp 717511b41d2SMark MurrayWhen performing host authentication, authentication is accepted if any 718b15c8340SDag-Erling Smørgravmatching line has the proper key; either one that matches exactly or, 719b15c8340SDag-Erling Smørgravif the server has presented a certificate for authentication, the key 720b15c8340SDag-Erling Smørgravof the certification authority that signed the certificate. 721b15c8340SDag-Erling SmørgravFor a key to be trusted as a certification authority, it must use the 722b15c8340SDag-Erling Smørgrav.Dq @cert-authority 723b15c8340SDag-Erling Smørgravmarker described above. 724b15c8340SDag-Erling Smørgrav.Pp 725b15c8340SDag-Erling SmørgravThe known hosts file also provides a facility to mark keys as revoked, 726b15c8340SDag-Erling Smørgravfor example when it is known that the associated private key has been 727b15c8340SDag-Erling Smørgravstolen. 728b15c8340SDag-Erling SmørgravRevoked keys are specified by including the 729b15c8340SDag-Erling Smørgrav.Dq @revoked 730b15c8340SDag-Erling Smørgravmarker at the beginning of the key line, and are never accepted for 731b15c8340SDag-Erling Smørgravauthentication or as certification authorities, but instead will 732b15c8340SDag-Erling Smørgravproduce a warning from 733b15c8340SDag-Erling Smørgrav.Xr ssh 1 734b15c8340SDag-Erling Smørgravwhen they are encountered. 735b15c8340SDag-Erling Smørgrav.Pp 736b15c8340SDag-Erling SmørgravIt is permissible (but not 737511b41d2SMark Murrayrecommended) to have several lines or different host keys for the same 7383c6ae118SKris Kennawaynames. 7393c6ae118SKris KennawayThis will inevitably happen when short forms of host names 7403c6ae118SKris Kennawayfrom different domains are put in the file. 7413c6ae118SKris KennawayIt is possible 742511b41d2SMark Murraythat the files contain conflicting information; authentication is 743511b41d2SMark Murrayaccepted if valid information can be found from either file. 744511b41d2SMark Murray.Pp 745511b41d2SMark MurrayNote that the lines in these files are typically hundreds of characters 746511b41d2SMark Murraylong, and you definitely don't want to type in the host keys by hand. 747b15c8340SDag-Erling SmørgravRather, generate them by a script, 748b15c8340SDag-Erling Smørgrav.Xr ssh-keyscan 1 749511b41d2SMark Murrayor by taking 7502134165cSKris Kennaway.Pa /etc/ssh/ssh_host_key.pub 751511b41d2SMark Murrayand adding the host names at the front. 752b15c8340SDag-Erling Smørgrav.Xr ssh-keygen 1 753b15c8340SDag-Erling Smørgravalso offers some basic automated editing for 754b15c8340SDag-Erling Smørgrav.Pa ~/.ssh/known_hosts 755b15c8340SDag-Erling Smørgravincluding removing hosts matching a host name and converting all host 756b15c8340SDag-Erling Smørgravnames to their hashed representations. 757333ee039SDag-Erling Smørgrav.Pp 758333ee039SDag-Erling SmørgravAn example ssh_known_hosts file: 759333ee039SDag-Erling Smørgrav.Bd -literal -offset 3n 760333ee039SDag-Erling Smørgrav# Comments allowed at start of line 761333ee039SDag-Erling Smørgravclosenet,...,192.0.2.53 1024 37 159...93 closenet.example.net 762333ee039SDag-Erling Smørgravcvs.example.net,192.0.2.10 ssh-rsa AAAA1234.....= 763aa49c926SDag-Erling Smørgrav# A hashed hostname 764aa49c926SDag-Erling Smørgrav|1|JfKTdBh7rNbXkVAQCRp4OQoPfmI=|USECr3SWf1JUPsms5AqfD5QfxkM= ssh-rsa 765aa49c926SDag-Erling SmørgravAAAA1234.....= 766b15c8340SDag-Erling Smørgrav# A revoked key 767b15c8340SDag-Erling Smørgrav@revoked * ssh-rsa AAAAB5W... 768b15c8340SDag-Erling Smørgrav# A CA key, accepted for any host in *.mydomain.com or *.mydomain.org 769b15c8340SDag-Erling Smørgrav@cert-authority *.mydomain.org,*.mydomain.com ssh-rsa AAAAB5W... 770aa49c926SDag-Erling Smørgrav.Ed 771511b41d2SMark Murray.Sh FILES 772333ee039SDag-Erling Smørgrav.Bl -tag -width Ds -compact 7734a421b63SDag-Erling Smørgrav.It Pa ~/.hushlogin 774aa49c926SDag-Erling SmørgravThis file is used to suppress printing the last login time and 775aa49c926SDag-Erling Smørgrav.Pa /etc/motd , 776aa49c926SDag-Erling Smørgravif 777aa49c926SDag-Erling Smørgrav.Cm PrintLastLog 778aa49c926SDag-Erling Smørgravand 779aa49c926SDag-Erling Smørgrav.Cm PrintMotd , 780aa49c926SDag-Erling Smørgravrespectively, 781aa49c926SDag-Erling Smørgravare enabled. 782aa49c926SDag-Erling SmørgravIt does not suppress printing of the banner specified by 783aa49c926SDag-Erling Smørgrav.Cm Banner . 784333ee039SDag-Erling Smørgrav.Pp 7854a421b63SDag-Erling Smørgrav.It Pa ~/.rhosts 786333ee039SDag-Erling SmørgravThis file is used for host-based authentication (see 787333ee039SDag-Erling Smørgrav.Xr ssh 1 788333ee039SDag-Erling Smørgravfor more information). 789333ee039SDag-Erling SmørgravOn some machines this file may need to be 790333ee039SDag-Erling Smørgravworld-readable if the user's home directory is on an NFS partition, 791333ee039SDag-Erling Smørgravbecause 792511b41d2SMark Murray.Nm 793333ee039SDag-Erling Smørgravreads it as root. 794333ee039SDag-Erling SmørgravAdditionally, this file must be owned by the user, 795333ee039SDag-Erling Smørgravand must not have write permissions for anyone else. 796333ee039SDag-Erling SmørgravThe recommended 797333ee039SDag-Erling Smørgravpermission for most machines is read/write for the user, and not 798511b41d2SMark Murrayaccessible by others. 799511b41d2SMark Murray.Pp 8004a421b63SDag-Erling Smørgrav.It Pa ~/.shosts 801333ee039SDag-Erling SmørgravThis file is used in exactly the same way as 802333ee039SDag-Erling Smørgrav.Pa .rhosts , 803333ee039SDag-Erling Smørgravbut allows host-based authentication without permitting login with 804333ee039SDag-Erling Smørgravrlogin/rsh. 805511b41d2SMark Murray.Pp 8064a421b63SDag-Erling Smørgrav.It Pa ~/.ssh/ 807d4af9e69SDag-Erling SmørgravThis directory is the default location for all user-specific configuration 808d4af9e69SDag-Erling Smørgravand authentication information. 809d4af9e69SDag-Erling SmørgravThere is no general requirement to keep the entire contents of this directory 810d4af9e69SDag-Erling Smørgravsecret, but the recommended permissions are read/write/execute for the user, 811d4af9e69SDag-Erling Smørgravand not accessible by others. 812d4af9e69SDag-Erling Smørgrav.Pp 8134a421b63SDag-Erling Smørgrav.It Pa ~/.ssh/authorized_keys 814*bc5531deSDag-Erling SmørgravLists the public keys (DSA, ECDSA, Ed25519, RSA) 815f7167e0eSDag-Erling Smørgravthat can be used for logging in as this user. 816333ee039SDag-Erling SmørgravThe format of this file is described above. 817333ee039SDag-Erling SmørgravThe content of the file is not highly sensitive, but the recommended 818333ee039SDag-Erling Smørgravpermissions are read/write for the user, and not accessible by others. 819511b41d2SMark Murray.Pp 820333ee039SDag-Erling SmørgravIf this file, the 821333ee039SDag-Erling Smørgrav.Pa ~/.ssh 822333ee039SDag-Erling Smørgravdirectory, or the user's home directory are writable 823333ee039SDag-Erling Smørgravby other users, then the file could be modified or replaced by unauthorized 824333ee039SDag-Erling Smørgravusers. 825333ee039SDag-Erling SmørgravIn this case, 826333ee039SDag-Erling Smørgrav.Nm 827333ee039SDag-Erling Smørgravwill not allow it to be used unless the 828333ee039SDag-Erling Smørgrav.Cm StrictModes 829333ee039SDag-Erling Smørgravoption has been set to 830333ee039SDag-Erling Smørgrav.Dq no . 831511b41d2SMark Murray.Pp 8324a421b63SDag-Erling Smørgrav.It Pa ~/.ssh/environment 8333c6ae118SKris KennawayThis file is read into the environment at login (if it exists). 8343c6ae118SKris KennawayIt can only contain empty lines, comment lines (that start with 835511b41d2SMark Murray.Ql # ) , 8363c6ae118SKris Kennawayand assignment lines of the form name=value. 8373c6ae118SKris KennawayThe file should be writable 838511b41d2SMark Murrayonly by the user; it need not be readable by anyone else. 839f388f5efSDag-Erling SmørgravEnvironment processing is disabled by default and is 840f388f5efSDag-Erling Smørgravcontrolled via the 841f388f5efSDag-Erling Smørgrav.Cm PermitUserEnvironment 842f388f5efSDag-Erling Smørgravoption. 843511b41d2SMark Murray.Pp 8444a421b63SDag-Erling Smørgrav.It Pa ~/.ssh/known_hosts 845333ee039SDag-Erling SmørgravContains a list of host keys for all hosts the user has logged into 846333ee039SDag-Erling Smørgravthat are not already in the systemwide list of known host keys. 847333ee039SDag-Erling SmørgravThe format of this file is described above. 848333ee039SDag-Erling SmørgravThis file should be writable only by root/the owner and 849333ee039SDag-Erling Smørgravcan, but need not be, world-readable. 850511b41d2SMark Murray.Pp 8514a421b63SDag-Erling Smørgrav.It Pa ~/.ssh/rc 852333ee039SDag-Erling SmørgravContains initialization routines to be run before 853333ee039SDag-Erling Smørgravthe user's home directory becomes accessible. 854511b41d2SMark MurrayThis file should be writable only by the user, and need not be 855511b41d2SMark Murrayreadable by anyone else. 856333ee039SDag-Erling Smørgrav.Pp 8574a421b63SDag-Erling Smørgrav.It Pa /etc/hosts.allow 8584a421b63SDag-Erling Smørgrav.It Pa /etc/hosts.deny 859333ee039SDag-Erling SmørgravAccess controls that should be enforced by tcp-wrappers are defined here. 860333ee039SDag-Erling SmørgravFurther details are described in 861333ee039SDag-Erling Smørgrav.Xr hosts_access 5 . 862333ee039SDag-Erling Smørgrav.Pp 8634a421b63SDag-Erling Smørgrav.It Pa /etc/hosts.equiv 864333ee039SDag-Erling SmørgravThis file is for host-based authentication (see 865333ee039SDag-Erling Smørgrav.Xr ssh 1 ) . 866333ee039SDag-Erling SmørgravIt should only be writable by root. 867333ee039SDag-Erling Smørgrav.Pp 8684a421b63SDag-Erling Smørgrav.It Pa /etc/moduli 869333ee039SDag-Erling SmørgravContains Diffie-Hellman groups used for the "Diffie-Hellman Group Exchange". 870333ee039SDag-Erling SmørgravThe file format is described in 871333ee039SDag-Erling Smørgrav.Xr moduli 5 . 872333ee039SDag-Erling Smørgrav.Pp 8734a421b63SDag-Erling Smørgrav.It Pa /etc/motd 874333ee039SDag-Erling SmørgravSee 875333ee039SDag-Erling Smørgrav.Xr motd 5 . 876333ee039SDag-Erling Smørgrav.Pp 8774a421b63SDag-Erling Smørgrav.It Pa /etc/nologin 878333ee039SDag-Erling SmørgravIf this file exists, 879333ee039SDag-Erling Smørgrav.Nm 880333ee039SDag-Erling Smørgravrefuses to let anyone except root log in. 881333ee039SDag-Erling SmørgravThe contents of the file 882333ee039SDag-Erling Smørgravare displayed to anyone trying to log in, and non-root connections are 883333ee039SDag-Erling Smørgravrefused. 884333ee039SDag-Erling SmørgravThe file should be world-readable. 885333ee039SDag-Erling Smørgrav.Pp 8864a421b63SDag-Erling Smørgrav.It Pa /etc/shosts.equiv 887333ee039SDag-Erling SmørgravThis file is used in exactly the same way as 888333ee039SDag-Erling Smørgrav.Pa hosts.equiv , 889333ee039SDag-Erling Smørgravbut allows host-based authentication without permitting login with 890333ee039SDag-Erling Smørgravrlogin/rsh. 891333ee039SDag-Erling Smørgrav.Pp 8924a421b63SDag-Erling Smørgrav.It Pa /etc/ssh/ssh_host_key 8934a421b63SDag-Erling Smørgrav.It Pa /etc/ssh/ssh_host_dsa_key 8944a421b63SDag-Erling Smørgrav.It Pa /etc/ssh/ssh_host_ecdsa_key 895f7167e0eSDag-Erling Smørgrav.It Pa /etc/ssh/ssh_host_ed25519_key 8964a421b63SDag-Erling Smørgrav.It Pa /etc/ssh/ssh_host_rsa_key 897462c32cbSDag-Erling SmørgravThese files contain the private parts of the host keys. 898333ee039SDag-Erling SmørgravThese files should only be owned by root, readable only by root, and not 899333ee039SDag-Erling Smørgravaccessible to others. 900333ee039SDag-Erling SmørgravNote that 901333ee039SDag-Erling Smørgrav.Nm 902333ee039SDag-Erling Smørgravdoes not start if these files are group/world-accessible. 903333ee039SDag-Erling Smørgrav.Pp 9044a421b63SDag-Erling Smørgrav.It Pa /etc/ssh/ssh_host_key.pub 9054a421b63SDag-Erling Smørgrav.It Pa /etc/ssh/ssh_host_dsa_key.pub 9064a421b63SDag-Erling Smørgrav.It Pa /etc/ssh/ssh_host_ecdsa_key.pub 907f7167e0eSDag-Erling Smørgrav.It Pa /etc/ssh/ssh_host_ed25519_key.pub 9084a421b63SDag-Erling Smørgrav.It Pa /etc/ssh/ssh_host_rsa_key.pub 909462c32cbSDag-Erling SmørgravThese files contain the public parts of the host keys. 910333ee039SDag-Erling SmørgravThese files should be world-readable but writable only by 911333ee039SDag-Erling Smørgravroot. 912333ee039SDag-Erling SmørgravTheir contents should match the respective private parts. 913333ee039SDag-Erling SmørgravThese files are not 914333ee039SDag-Erling Smørgravreally used for anything; they are provided for the convenience of 915333ee039SDag-Erling Smørgravthe user so their contents can be copied to known hosts files. 916333ee039SDag-Erling SmørgravThese files are created using 917333ee039SDag-Erling Smørgrav.Xr ssh-keygen 1 . 918333ee039SDag-Erling Smørgrav.Pp 9194a421b63SDag-Erling Smørgrav.It Pa /etc/ssh/ssh_known_hosts 920d4af9e69SDag-Erling SmørgravSystemwide list of known host keys. 921d4af9e69SDag-Erling SmørgravThis file should be prepared by the 922d4af9e69SDag-Erling Smørgravsystem administrator to contain the public host keys of all machines in the 923d4af9e69SDag-Erling Smørgravorganization. 924d4af9e69SDag-Erling SmørgravThe format of this file is described above. 925d4af9e69SDag-Erling SmørgravThis file should be writable only by root/the owner and 926d4af9e69SDag-Erling Smørgravshould be world-readable. 927d4af9e69SDag-Erling Smørgrav.Pp 9284a421b63SDag-Erling Smørgrav.It Pa /etc/ssh/sshd_config 929333ee039SDag-Erling SmørgravContains configuration data for 930333ee039SDag-Erling Smørgrav.Nm sshd . 931333ee039SDag-Erling SmørgravThe file format and configuration options are described in 932333ee039SDag-Erling Smørgrav.Xr sshd_config 5 . 933333ee039SDag-Erling Smørgrav.Pp 9344a421b63SDag-Erling Smørgrav.It Pa /etc/ssh/sshrc 935333ee039SDag-Erling SmørgravSimilar to 936333ee039SDag-Erling Smørgrav.Pa ~/.ssh/rc , 937333ee039SDag-Erling Smørgravit can be used to specify 9383c6ae118SKris Kennawaymachine-specific login-time initializations globally. 9393c6ae118SKris KennawayThis file should be writable only by root, and should be world-readable. 940333ee039SDag-Erling Smørgrav.Pp 9414a421b63SDag-Erling Smørgrav.It Pa /var/empty 942333ee039SDag-Erling Smørgrav.Xr chroot 2 943333ee039SDag-Erling Smørgravdirectory used by 944333ee039SDag-Erling Smørgrav.Nm 945333ee039SDag-Erling Smørgravduring privilege separation in the pre-authentication phase. 946333ee039SDag-Erling SmørgravThe directory should not contain any files and must be owned by root 947333ee039SDag-Erling Smørgravand not group or world-writable. 948333ee039SDag-Erling Smørgrav.Pp 9494a421b63SDag-Erling Smørgrav.It Pa /var/run/sshd.pid 950333ee039SDag-Erling SmørgravContains the process ID of the 951333ee039SDag-Erling Smørgrav.Nm 952333ee039SDag-Erling Smørgravlistening for connections (if there are several daemons running 953333ee039SDag-Erling Smørgravconcurrently for different ports, this contains the process ID of the one 954333ee039SDag-Erling Smørgravstarted last). 955333ee039SDag-Erling SmørgravThe content of this file is not sensitive; it can be world-readable. 956c2d3a559SKris Kennaway.El 957511b41d2SMark Murray.Sh SEE ALSO 958511b41d2SMark Murray.Xr scp 1 , 959ca3176e7SBrian Feldman.Xr sftp 1 , 960511b41d2SMark Murray.Xr ssh 1 , 961511b41d2SMark Murray.Xr ssh-add 1 , 962511b41d2SMark Murray.Xr ssh-agent 1 , 963511b41d2SMark Murray.Xr ssh-keygen 1 , 964d4af9e69SDag-Erling Smørgrav.Xr ssh-keyscan 1 , 9651ec0d754SDag-Erling Smørgrav.Xr chroot 2 , 9661ec0d754SDag-Erling Smørgrav.Xr hosts_access 5 , 967af12a3e7SDag-Erling Smørgrav.Xr login.conf 5 , 968af12a3e7SDag-Erling Smørgrav.Xr moduli 5 , 969614c49a9SDag-Erling Smørgrav.Xr sshd_config 5 , 9701ec0d754SDag-Erling Smørgrav.Xr inetd 8 , 971af12a3e7SDag-Erling Smørgrav.Xr sftp-server 8 972cf2b5f3bSDag-Erling Smørgrav.Sh AUTHORS 973cf2b5f3bSDag-Erling SmørgravOpenSSH is a derivative of the original and free 974cf2b5f3bSDag-Erling Smørgravssh 1.2.12 release by Tatu Ylonen. 975cf2b5f3bSDag-Erling SmørgravAaron Campbell, Bob Beck, Markus Friedl, Niels Provos, 976cf2b5f3bSDag-Erling SmørgravTheo de Raadt and Dug Song 977cf2b5f3bSDag-Erling Smørgravremoved many bugs, re-added newer features and 978cf2b5f3bSDag-Erling Smørgravcreated OpenSSH. 979cf2b5f3bSDag-Erling SmørgravMarkus Friedl contributed the support for SSH 980cf2b5f3bSDag-Erling Smørgravprotocol versions 1.5 and 2.0. 981cf2b5f3bSDag-Erling SmørgravNiels Provos and Markus Friedl contributed support 982cf2b5f3bSDag-Erling Smørgravfor privilege separation. 983