[BACK]Return to sshd.8 CVS log [TXT][DIR] Up to [local] / src / usr.bin / ssh

Annotation of src/usr.bin/ssh/sshd.8, Revision 1.246

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.246   ! djm        37: .\" $OpenBSD: sshd.8,v 1.245 2008/06/11 07:30:37 jmc Exp $
        !            38: .Dd $Mdocdate: June 11 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
1.246   ! djm       103: server key (default 1024).
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"
1.244     djm       507: Specifies that in addition to public key authentication, either the canonical
1.245     jmc       508: name of the remote host or its IP address must be present in the
1.244     djm       509: comma-separated list of patterns.
1.229     jmc       510: See
                    511: .Sx PATTERNS
                    512: in
                    513: .Xr ssh_config 5
                    514: for more information on patterns.
1.244     djm       515: .Pp
                    516: In addition to the wildcard matching that may be applied to hostnames or
                    517: addresses, a
                    518: .Cm from
                    519: stanza may match IP addressess using CIDR address/masklen notation.
                    520: .Pp
                    521: The purpose of this option is to optionally increase security: public key
                    522: authentication by itself does not trust the network or name servers or
                    523: anything (but the key); however, if somebody somehow steals the key, the key
                    524: permits an intruder to log in from anywhere in the world.
                    525: This additional option makes using a stolen key more difficult (name
                    526: servers and/or routers would have to be compromised in addition to
                    527: just the key).
1.218     jmc       528: .It Cm no-agent-forwarding
                    529: Forbids authentication agent forwarding when this key is used for
                    530: authentication.
1.2       deraadt   531: .It Cm no-port-forwarding
1.211     jmc       532: Forbids TCP forwarding when this key is used for authentication.
1.36      aaron     533: Any port forward requests by the client will return an error.
1.230     jmc       534: This might be used, e.g. in connection with the
1.2       deraadt   535: .Cm command
1.1       deraadt   536: option.
1.218     jmc       537: .It Cm no-pty
                    538: Prevents tty allocation (a request to allocate a pty will fail).
1.240     djm       539: .It Cm no-user-rc
1.241     jmc       540: Disables execution of
1.240     djm       541: .Pa ~/.ssh/rc .
1.2       deraadt   542: .It Cm no-X11-forwarding
1.1       deraadt   543: Forbids X11 forwarding when this key is used for authentication.
                    544: Any X11 forward requests by the client will return an error.
1.107     djm       545: .It Cm permitopen="host:port"
1.133     itojun    546: Limit local
1.107     djm       547: .Li ``ssh -L''
1.111     stevesk   548: port forwarding such that it may only connect to the specified host and
1.146     stevesk   549: port.
                    550: IPv6 addresses can be specified with an alternative syntax:
1.200     jmc       551: .Ar host Ns / Ns Ar port .
1.146     stevesk   552: Multiple
1.107     djm       553: .Cm permitopen
1.197     jmc       554: options may be applied separated by commas.
                    555: No pattern matching is performed on the specified hostnames,
                    556: they must be literal domains or addresses.
1.209     reyk      557: .It Cm tunnel="n"
                    558: Force a
                    559: .Xr tun 4
                    560: device on the server.
                    561: Without this option, the next available device will be used if
                    562: the client requests a tunnel.
1.2       deraadt   563: .El
                    564: .Pp
1.219     jmc       565: An example authorized_keys file:
1.222     jmc       566: .Bd -literal -offset 3n
1.219     jmc       567: # Comments allowed at start of line
                    568: ssh-rsa AAAAB3Nza...LiPk== user@example.net
1.222     jmc       569: from="*.sales.example.net,!pc.sales.example.net" ssh-rsa
                    570: AAAAB2...19Q== john@example.net
                    571: command="dump /home",no-pty,no-port-forwarding ssh-dss
                    572: AAAAC3...51R== example.net
                    573: permitopen="192.0.2.1:80",permitopen="192.0.2.2:25" ssh-dss
                    574: AAAAB5...21S==
                    575: tunnel="0",command="sh /etc/netstart tun0" ssh-rsa AAAA...==
                    576: jane@example.net
1.219     jmc       577: .Ed
1.2       deraadt   578: .Sh SSH_KNOWN_HOSTS FILE FORMAT
1.40      aaron     579: The
1.194     jmc       580: .Pa /etc/ssh/ssh_known_hosts
1.40      aaron     581: and
1.207     djm       582: .Pa ~/.ssh/known_hosts
1.36      aaron     583: files contain host public keys for all known hosts.
                    584: The global file should
1.37      brad      585: be prepared by the administrator (optional), and the per-user file is
1.220     jmc       586: maintained automatically: whenever the user connects from an unknown host,
1.36      aaron     587: its key is added to the per-user file.
1.2       deraadt   588: .Pp
1.1       deraadt   589: Each line in these files contains the following fields: hostnames,
1.36      aaron     590: bits, exponent, modulus, comment.
                    591: The fields are separated by spaces.
1.2       deraadt   592: .Pp
1.196     david     593: Hostnames is a comma-separated list of patterns
1.220     jmc       594: .Pf ( Ql *
1.197     jmc       595: and
                    596: .Ql \&?
1.195     mouring   597: act as
1.1       deraadt   598: wildcards); each pattern in turn is matched against the canonical host
                    599: name (when authenticating a client) or against the user-supplied
1.36      aaron     600: name (when authenticating a server).
                    601: A pattern may also be preceded by
1.195     mouring   602: .Ql \&!
1.2       deraadt   603: to indicate negation: if the host name matches a negated
1.1       deraadt   604: pattern, it is not accepted (by that line) even if it matched another
                    605: pattern on the line.
1.231     dtucker   606: A hostname or address may optionally be enclosed within
                    607: .Ql \&[
                    608: and
                    609: .Ql \&]
                    610: brackets then followed by
                    611: .Ql \&:
1.232     jmc       612: and a non-standard port number.
1.2       deraadt   613: .Pp
1.205     djm       614: Alternately, hostnames may be stored in a hashed form which hides host names
1.206     jmc       615: and addresses should the file's contents be disclosed.
                    616: Hashed hostnames start with a
                    617: .Ql |
1.205     djm       618: character.
                    619: Only one hashed hostname may appear on a single line and none of the above
                    620: negation or wildcard operators may be applied.
                    621: .Pp
1.49      markus    622: Bits, exponent, and modulus are taken directly from the RSA host key; they
1.220     jmc       623: can be obtained, for example, from
1.167     deraadt   624: .Pa /etc/ssh/ssh_host_key.pub .
1.1       deraadt   625: The optional comment field continues to the end of the line, and is not used.
1.2       deraadt   626: .Pp
                    627: Lines starting with
                    628: .Ql #
                    629: and empty lines are ignored as comments.
                    630: .Pp
1.1       deraadt   631: When performing host authentication, authentication is accepted if any
1.36      aaron     632: matching line has the proper key.
                    633: It is thus permissible (but not
1.1       deraadt   634: recommended) to have several lines or different host keys for the same
1.36      aaron     635: names.
                    636: This will inevitably happen when short forms of host names
                    637: from different domains are put in the file.
                    638: It is possible
1.1       deraadt   639: that the files contain conflicting information; authentication is
                    640: accepted if valid information can be found from either file.
1.2       deraadt   641: .Pp
1.1       deraadt   642: Note that the lines in these files are typically hundreds of characters
                    643: long, and you definitely don't want to type in the host keys by hand.
1.6       aaron     644: Rather, generate them by a script
1.40      aaron     645: or by taking
1.167     deraadt   646: .Pa /etc/ssh/ssh_host_key.pub
1.1       deraadt   647: and adding the host names at the front.
1.221     jmc       648: .Pp
                    649: An example ssh_known_hosts file:
                    650: .Bd -literal -offset 3n
                    651: # Comments allowed at start of line
                    652: closenet,...,192.0.2.53 1024 37 159...93 closenet.example.net
                    653: cvs.example.net,192.0.2.10 ssh-rsa AAAA1234.....=
1.205     djm       654: # A hashed hostname
                    655: |1|JfKTdBh7rNbXkVAQCRp4OQoPfmI=|USECr3SWf1JUPsms5AqfD5QfxkM= ssh-rsa
                    656: AAAA1234.....=
1.120     markus    657: .Ed
1.2       deraadt   658: .Sh FILES
1.223     jmc       659: .Bl -tag -width Ds -compact
                    660: .It ~/.hushlogin
1.204     jmc       661: This file is used to suppress printing the last login time and
                    662: .Pa /etc/motd ,
                    663: if
                    664: .Cm PrintLastLog
                    665: and
                    666: .Cm PrintMotd ,
                    667: respectively,
                    668: are enabled.
                    669: It does not suppress printing of the banner specified by
                    670: .Cm Banner .
1.223     jmc       671: .Pp
                    672: .It ~/.rhosts
1.225     jmc       673: This file is used for host-based authentication (see
                    674: .Xr ssh 1
                    675: for more information).
                    676: On some machines this file may need to be
                    677: world-readable if the user's home directory is on an NFS partition,
                    678: because
                    679: .Nm
                    680: reads it as root.
                    681: Additionally, this file must be owned by the user,
                    682: and must not have write permissions for anyone else.
                    683: The recommended
                    684: permission for most machines is read/write for the user, and not
1.1       deraadt   685: accessible by others.
1.2       deraadt   686: .Pp
1.223     jmc       687: .It ~/.shosts
1.225     jmc       688: This file is used in exactly the same way as
                    689: .Pa .rhosts ,
                    690: but allows host-based authentication without permitting login with
                    691: rlogin/rsh.
1.238     mcbride   692: .Pp
                    693: .It ~/.ssh/
                    694: This directory is the default location for all user-specific configuration
                    695: and authentication information.
                    696: There is no general requirement to keep the entire contents of this directory
                    697: secret, but the recommended permissions are read/write/execute for the user,
                    698: and not accessible by others.
1.2       deraadt   699: .Pp
1.223     jmc       700: .It ~/.ssh/authorized_keys
1.225     jmc       701: Lists the public keys (RSA/DSA) that can be used for logging in as this user.
1.223     jmc       702: The format of this file is described above.
1.234     dtucker   703: The content of the file is not highly sensitive, but the recommended
1.225     jmc       704: permissions are read/write for the user, and not accessible by others.
1.234     dtucker   705: .Pp
                    706: If this file, the
                    707: .Pa ~/.ssh
                    708: directory, or the user's home directory are writable
                    709: by other users, then the file could be modified or replaced by unauthorized
                    710: users.
                    711: In this case,
                    712: .Nm
                    713: will not allow it to be used unless the
                    714: .Cm StrictModes
                    715: option has been set to
                    716: .Dq no .
                    717: The recommended permissions can be set by executing
                    718: .Dq chmod go-w ~/ ~/.ssh ~/.ssh/authorized_keys .
1.2       deraadt   719: .Pp
1.223     jmc       720: .It ~/.ssh/environment
1.36      aaron     721: This file is read into the environment at login (if it exists).
                    722: It can only contain empty lines, comment lines (that start with
1.2       deraadt   723: .Ql # ) ,
1.36      aaron     724: and assignment lines of the form name=value.
                    725: The file should be writable
1.6       aaron     726: only by the user; it need not be readable by anyone else.
1.188     stevesk   727: Environment processing is disabled by default and is
                    728: controlled via the
                    729: .Cm PermitUserEnvironment
                    730: option.
1.223     jmc       731: .Pp
                    732: .It ~/.ssh/known_hosts
1.225     jmc       733: Contains a list of host keys for all hosts the user has logged into
                    734: that are not already in the systemwide list of known host keys.
                    735: The format of this file is described above.
                    736: This file should be writable only by root/the owner and
1.223     jmc       737: can, but need not be, world-readable.
                    738: .Pp
                    739: .It ~/.ssh/rc
1.226     jmc       740: Contains initialization routines to be run before
                    741: the user's home directory becomes accessible.
1.1       deraadt   742: This file should be writable only by the user, and need not be
                    743: readable by anyone else.
1.223     jmc       744: .Pp
                    745: .It /etc/hosts.allow
                    746: .It /etc/hosts.deny
                    747: Access controls that should be enforced by tcp-wrappers are defined here.
                    748: Further details are described in
                    749: .Xr hosts_access 5 .
                    750: .Pp
                    751: .It /etc/hosts.equiv
1.227     jmc       752: This file is for host-based authentication (see
                    753: .Xr ssh 1 ) .
                    754: It should only be writable by root.
1.223     jmc       755: .Pp
                    756: .It /etc/moduli
                    757: Contains Diffie-Hellman groups used for the "Diffie-Hellman Group Exchange".
                    758: The file format is described in
                    759: .Xr moduli 5 .
                    760: .Pp
                    761: .It /etc/motd
                    762: See
                    763: .Xr motd 5 .
                    764: .Pp
                    765: .It /etc/nologin
                    766: If this file exists,
                    767: .Nm
                    768: refuses to let anyone except root log in.
                    769: The contents of the file
                    770: are displayed to anyone trying to log in, and non-root connections are
                    771: refused.
                    772: The file should be world-readable.
                    773: .Pp
                    774: .It /etc/shosts.equiv
1.227     jmc       775: This file is used in exactly the same way as
                    776: .Pa hosts.equiv ,
                    777: but allows host-based authentication without permitting login with
                    778: rlogin/rsh.
1.225     jmc       779: .Pp
1.223     jmc       780: .It /etc/ssh/ssh_host_key
                    781: .It /etc/ssh/ssh_host_dsa_key
                    782: .It /etc/ssh/ssh_host_rsa_key
                    783: These three files contain the private parts of the host keys.
                    784: These files should only be owned by root, readable only by root, and not
                    785: accessible to others.
                    786: Note that
                    787: .Nm
1.228     jmc       788: does not start if these files are group/world-accessible.
1.223     jmc       789: .Pp
                    790: .It /etc/ssh/ssh_host_key.pub
                    791: .It /etc/ssh/ssh_host_dsa_key.pub
                    792: .It /etc/ssh/ssh_host_rsa_key.pub
                    793: These three files contain the public parts of the host keys.
                    794: These files should be world-readable but writable only by
                    795: root.
                    796: Their contents should match the respective private parts.
                    797: These files are not
                    798: really used for anything; they are provided for the convenience of
                    799: the user so their contents can be copied to known hosts files.
                    800: These files are created using
                    801: .Xr ssh-keygen 1 .
                    802: .Pp
1.235     jmc       803: .It /etc/ssh/ssh_known_hosts
                    804: Systemwide list of known host keys.
                    805: This file should be prepared by the
                    806: system administrator to contain the public host keys of all machines in the
                    807: organization.
                    808: The format of this file is described above.
                    809: This file should be writable only by root/the owner and
                    810: should be world-readable.
                    811: .Pp
1.223     jmc       812: .It /etc/ssh/sshd_config
                    813: Contains configuration data for
                    814: .Nm sshd .
                    815: The file format and configuration options are described in
                    816: .Xr sshd_config 5 .
                    817: .Pp
                    818: .It /etc/ssh/sshrc
1.226     jmc       819: Similar to
                    820: .Pa ~/.ssh/rc ,
                    821: it can be used to specify
1.36      aaron     822: machine-specific login-time initializations globally.
                    823: This file should be writable only by root, and should be world-readable.
1.223     jmc       824: .Pp
                    825: .It /var/empty
                    826: .Xr chroot 2
                    827: directory used by
                    828: .Nm
                    829: during privilege separation in the pre-authentication phase.
                    830: The directory should not contain any files and must be owned by root
                    831: and not group or world-writable.
                    832: .Pp
                    833: .It /var/run/sshd.pid
                    834: Contains the process ID of the
                    835: .Nm
                    836: listening for connections (if there are several daemons running
                    837: concurrently for different ports, this contains the process ID of the one
                    838: started last).
                    839: The content of this file is not sensitive; it can be world-readable.
1.56      aaron     840: .El
1.2       deraadt   841: .Sh SEE ALSO
                    842: .Xr scp 1 ,
1.90      djm       843: .Xr sftp 1 ,
1.2       deraadt   844: .Xr ssh 1 ,
1.5       deraadt   845: .Xr ssh-add 1 ,
1.2       deraadt   846: .Xr ssh-agent 1 ,
1.5       deraadt   847: .Xr ssh-keygen 1 ,
1.235     jmc       848: .Xr ssh-keyscan 1 ,
1.200     jmc       849: .Xr chroot 2 ,
                    850: .Xr hosts_access 5 ,
1.136     markus    851: .Xr login.conf 5 ,
                    852: .Xr moduli 5 ,
1.184     stevesk   853: .Xr sshd_config 5 ,
1.200     jmc       854: .Xr inetd 8 ,
1.128     mpech     855: .Xr sftp-server 8
1.198     jmc       856: .Sh AUTHORS
                    857: OpenSSH is a derivative of the original and free
                    858: ssh 1.2.12 release by Tatu Ylonen.
                    859: Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos,
                    860: Theo de Raadt and Dug Song
                    861: removed many bugs, re-added newer features and
                    862: created OpenSSH.
                    863: Markus Friedl contributed the support for SSH
                    864: protocol versions 1.5 and 2.0.
                    865: Niels Provos and Markus Friedl contributed support
                    866: for privilege separation.
1.216     jmc       867: .Sh CAVEATS
                    868: System security is not improved unless
                    869: .Nm rshd ,
                    870: .Nm rlogind ,
                    871: and
                    872: .Nm rexecd
                    873: are disabled (thus completely disabling
                    874: .Xr rlogin
                    875: and
                    876: .Xr rsh
                    877: into the machine).