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