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