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