[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.269

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.269   ! dtucker    36: .\" $OpenBSD: sshd.8,v 1.268 2013/04/07 02:10:33 dtucker Exp $
        !            37: .Dd $Mdocdate: April 7 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.75      markus    470: .Dq ssh-dss
                    471: or
                    472: .Dq ssh-rsa .
1.2       deraadt   473: .Pp
1.1       deraadt   474: Note that lines in this file are usually several hundred bytes long
1.203     dtucker   475: (because of the size of the public key encoding) up to a limit of
                    476: 8 kilobytes, which permits DSA keys up to 8 kilobits and RSA
                    477: keys up to 16 kilobits.
1.36      aaron     478: You don't want to type them in; instead, copy the
1.113     itojun    479: .Pa identity.pub ,
1.217     jmc       480: .Pa id_dsa.pub ,
1.259     djm       481: .Pa id_ecdsa.pub ,
1.75      markus    482: or the
1.113     itojun    483: .Pa id_rsa.pub
1.1       deraadt   484: file and edit it.
1.175     stevesk   485: .Pp
                    486: .Nm
                    487: enforces a minimum RSA key modulus size for protocol 1
                    488: and protocol 2 keys of 768 bits.
1.2       deraadt   489: .Pp
1.58      deraadt   490: The options (if present) consist of comma-separated option
1.36      aaron     491: specifications.
                    492: No spaces are permitted, except within double quotes.
1.141     stevesk   493: The following option specifications are supported (note
                    494: that option keywords are case-insensitive):
1.2       deraadt   495: .Bl -tag -width Ds
1.253     djm       496: .It Cm cert-authority
1.251     djm       497: Specifies that the listed key is a certification authority (CA) that is
                    498: trusted to validate signed certificates for user authentication.
                    499: .Pp
                    500: Certificates may encode access restrictions similar to these key options.
                    501: If both certificate restrictions and key options are present, the most
                    502: restrictive union of the two is applied.
1.2       deraadt   503: .It Cm command="command"
1.1       deraadt   504: Specifies that the command is executed whenever this key is used for
1.36      aaron     505: authentication.
                    506: The command supplied by the user (if any) is ignored.
1.148     markus    507: The command is run on a pty if the client requests a pty;
1.36      aaron     508: otherwise it is run without a tty.
1.194     jmc       509: If an 8-bit clean channel is required,
1.147     deraadt   510: one must not request a pty or should specify
1.89      markus    511: .Cm no-pty .
1.36      aaron     512: A quote may be included in the command by quoting it with a backslash.
                    513: This option might be useful
1.189     espie     514: to restrict certain public keys to perform just a specific operation.
1.36      aaron     515: An example might be a key that permits remote backups but nothing else.
1.211     jmc       516: Note that the client may specify TCP and/or X11
1.51      hugh      517: forwarding unless they are explicitly prohibited.
1.233     dtucker   518: The command originally supplied by the client is available in the
                    519: .Ev SSH_ORIGINAL_COMMAND
                    520: environment variable.
1.149     markus    521: Note that this option applies to shell, command or subsystem execution.
1.251     djm       522: Also note that this command may be superseded by either a
                    523: .Xr sshd_config 5
                    524: .Cm ForceCommand
                    525: directive or a command embedded in a certificate.
1.2       deraadt   526: .It Cm environment="NAME=value"
1.1       deraadt   527: Specifies that the string is to be added to the environment when
1.36      aaron     528: logging in using this key.
                    529: Environment variables set this way
                    530: override other default environment values.
                    531: Multiple options of this type are permitted.
1.188     stevesk   532: Environment processing is disabled by default and is
                    533: controlled via the
                    534: .Cm PermitUserEnvironment
                    535: option.
1.155     markus    536: This option is automatically disabled if
                    537: .Cm UseLogin
                    538: is enabled.
1.218     jmc       539: .It Cm from="pattern-list"
1.244     djm       540: Specifies that in addition to public key authentication, either the canonical
1.245     jmc       541: name of the remote host or its IP address must be present in the
1.244     djm       542: comma-separated list of patterns.
1.229     jmc       543: See
                    544: .Sx PATTERNS
                    545: in
                    546: .Xr ssh_config 5
                    547: for more information on patterns.
1.244     djm       548: .Pp
                    549: In addition to the wildcard matching that may be applied to hostnames or
                    550: addresses, a
                    551: .Cm from
1.248     sobrado   552: stanza may match IP addresses using CIDR address/masklen notation.
1.244     djm       553: .Pp
                    554: The purpose of this option is to optionally increase security: public key
                    555: authentication by itself does not trust the network or name servers or
                    556: anything (but the key); however, if somebody somehow steals the key, the key
                    557: permits an intruder to log in from anywhere in the world.
                    558: This additional option makes using a stolen key more difficult (name
                    559: servers and/or routers would have to be compromised in addition to
                    560: just the key).
1.218     jmc       561: .It Cm no-agent-forwarding
                    562: Forbids authentication agent forwarding when this key is used for
                    563: authentication.
1.2       deraadt   564: .It Cm no-port-forwarding
1.211     jmc       565: Forbids TCP forwarding when this key is used for authentication.
1.36      aaron     566: Any port forward requests by the client will return an error.
1.230     jmc       567: This might be used, e.g. in connection with the
1.2       deraadt   568: .Cm command
1.1       deraadt   569: option.
1.218     jmc       570: .It Cm no-pty
                    571: Prevents tty allocation (a request to allocate a pty will fail).
1.240     djm       572: .It Cm no-user-rc
1.241     jmc       573: Disables execution of
1.240     djm       574: .Pa ~/.ssh/rc .
1.2       deraadt   575: .It Cm no-X11-forwarding
1.1       deraadt   576: Forbids X11 forwarding when this key is used for authentication.
                    577: Any X11 forward requests by the client will return an error.
1.107     djm       578: .It Cm permitopen="host:port"
1.133     itojun    579: Limit local
1.107     djm       580: .Li ``ssh -L''
1.111     stevesk   581: port forwarding such that it may only connect to the specified host and
1.146     stevesk   582: port.
1.257     djm       583: IPv6 addresses can be specified by enclosing the address in square brackets.
1.146     stevesk   584: Multiple
1.107     djm       585: .Cm permitopen
1.197     jmc       586: options may be applied separated by commas.
                    587: No pattern matching is performed on the specified hostnames,
                    588: they must be literal domains or addresses.
1.264     dtucker   589: A port specification of
                    590: .Cm *
                    591: matches any port.
1.256     djm       592: .It Cm principals="principals"
                    593: On a
                    594: .Cm cert-authority
                    595: line, specifies allowed principals for certificate authentication as a
                    596: comma-separated list.
                    597: At least one name from the list must appear in the certificate's
                    598: list of principals for the certificate to be accepted.
                    599: This option is ignored for keys that are not marked as trusted certificate
                    600: signers using the
                    601: .Cm cert-authority
                    602: option.
1.209     reyk      603: .It Cm tunnel="n"
                    604: Force a
                    605: .Xr tun 4
                    606: device on the server.
                    607: Without this option, the next available device will be used if
                    608: the client requests a tunnel.
1.2       deraadt   609: .El
                    610: .Pp
1.219     jmc       611: An example authorized_keys file:
1.222     jmc       612: .Bd -literal -offset 3n
1.219     jmc       613: # Comments allowed at start of line
                    614: ssh-rsa AAAAB3Nza...LiPk== user@example.net
1.222     jmc       615: from="*.sales.example.net,!pc.sales.example.net" ssh-rsa
                    616: AAAAB2...19Q== john@example.net
                    617: command="dump /home",no-pty,no-port-forwarding ssh-dss
                    618: AAAAC3...51R== example.net
                    619: permitopen="192.0.2.1:80",permitopen="192.0.2.2:25" ssh-dss
                    620: AAAAB5...21S==
                    621: tunnel="0",command="sh /etc/netstart tun0" ssh-rsa AAAA...==
                    622: jane@example.net
1.219     jmc       623: .Ed
1.2       deraadt   624: .Sh SSH_KNOWN_HOSTS FILE FORMAT
1.40      aaron     625: The
1.194     jmc       626: .Pa /etc/ssh/ssh_known_hosts
1.40      aaron     627: and
1.207     djm       628: .Pa ~/.ssh/known_hosts
1.36      aaron     629: files contain host public keys for all known hosts.
                    630: The global file should
1.37      brad      631: be prepared by the administrator (optional), and the per-user file is
1.220     jmc       632: maintained automatically: whenever the user connects from an unknown host,
1.36      aaron     633: its key is added to the per-user file.
1.2       deraadt   634: .Pp
1.254     djm       635: Each line in these files contains the following fields: markers (optional),
                    636: hostnames, bits, exponent, modulus, comment.
1.36      aaron     637: The fields are separated by spaces.
1.2       deraadt   638: .Pp
1.254     djm       639: The marker is optional, but if it is present then it must be one of
                    640: .Dq @cert-authority ,
                    641: to indicate that the line contains a certification authority (CA) key,
                    642: or
                    643: .Dq @revoked ,
                    644: to indicate that the key contained on the line is revoked and must not ever
                    645: be accepted.
                    646: Only one marker should be used on a key line.
                    647: .Pp
1.196     david     648: Hostnames is a comma-separated list of patterns
1.220     jmc       649: .Pf ( Ql *
1.197     jmc       650: and
                    651: .Ql \&?
1.195     mouring   652: act as
1.1       deraadt   653: wildcards); each pattern in turn is matched against the canonical host
                    654: name (when authenticating a client) or against the user-supplied
1.36      aaron     655: name (when authenticating a server).
                    656: A pattern may also be preceded by
1.195     mouring   657: .Ql \&!
1.2       deraadt   658: to indicate negation: if the host name matches a negated
1.1       deraadt   659: pattern, it is not accepted (by that line) even if it matched another
                    660: pattern on the line.
1.231     dtucker   661: A hostname or address may optionally be enclosed within
                    662: .Ql \&[
                    663: and
                    664: .Ql \&]
                    665: brackets then followed by
                    666: .Ql \&:
1.232     jmc       667: and a non-standard port number.
1.2       deraadt   668: .Pp
1.205     djm       669: Alternately, hostnames may be stored in a hashed form which hides host names
1.206     jmc       670: and addresses should the file's contents be disclosed.
                    671: Hashed hostnames start with a
                    672: .Ql |
1.205     djm       673: character.
                    674: Only one hashed hostname may appear on a single line and none of the above
                    675: negation or wildcard operators may be applied.
                    676: .Pp
1.49      markus    677: Bits, exponent, and modulus are taken directly from the RSA host key; they
1.220     jmc       678: can be obtained, for example, from
1.167     deraadt   679: .Pa /etc/ssh/ssh_host_key.pub .
1.1       deraadt   680: The optional comment field continues to the end of the line, and is not used.
1.2       deraadt   681: .Pp
                    682: Lines starting with
                    683: .Ql #
                    684: and empty lines are ignored as comments.
                    685: .Pp
1.1       deraadt   686: When performing host authentication, authentication is accepted if any
1.254     djm       687: matching line has the proper key; either one that matches exactly or,
                    688: if the server has presented a certificate for authentication, the key
                    689: of the certification authority that signed the certificate.
                    690: For a key to be trusted as a certification authority, it must use the
                    691: .Dq @cert-authority
                    692: marker described above.
                    693: .Pp
                    694: The known hosts file also provides a facility to mark keys as revoked,
                    695: for example when it is known that the associated private key has been
                    696: stolen.
                    697: Revoked keys are specified by including the
                    698: .Dq @revoked
                    699: marker at the beginning of the key line, and are never accepted for
                    700: authentication or as certification authorities, but instead will
                    701: produce a warning from
                    702: .Xr ssh 1
                    703: when they are encountered.
                    704: .Pp
                    705: It is permissible (but not
1.1       deraadt   706: recommended) to have several lines or different host keys for the same
1.36      aaron     707: names.
                    708: This will inevitably happen when short forms of host names
                    709: from different domains are put in the file.
                    710: It is possible
1.1       deraadt   711: that the files contain conflicting information; authentication is
                    712: accepted if valid information can be found from either file.
1.2       deraadt   713: .Pp
1.1       deraadt   714: Note that the lines in these files are typically hundreds of characters
                    715: long, and you definitely don't want to type in the host keys by hand.
1.254     djm       716: Rather, generate them by a script,
                    717: .Xr ssh-keyscan 1
1.40      aaron     718: or by taking
1.167     deraadt   719: .Pa /etc/ssh/ssh_host_key.pub
1.1       deraadt   720: and adding the host names at the front.
1.254     djm       721: .Xr ssh-keygen 1
1.255     jmc       722: also offers some basic automated editing for
1.254     djm       723: .Pa ~/.ssh/known_hosts
                    724: including removing hosts matching a host name and converting all host
                    725: names to their hashed representations.
1.221     jmc       726: .Pp
                    727: An example ssh_known_hosts file:
                    728: .Bd -literal -offset 3n
                    729: # Comments allowed at start of line
                    730: closenet,...,192.0.2.53 1024 37 159...93 closenet.example.net
                    731: cvs.example.net,192.0.2.10 ssh-rsa AAAA1234.....=
1.205     djm       732: # A hashed hostname
                    733: |1|JfKTdBh7rNbXkVAQCRp4OQoPfmI=|USECr3SWf1JUPsms5AqfD5QfxkM= ssh-rsa
                    734: AAAA1234.....=
1.254     djm       735: # A revoked key
                    736: @revoked * ssh-rsa AAAAB5W...
                    737: # A CA key, accepted for any host in *.mydomain.com or *.mydomain.org
                    738: @cert-authority *.mydomain.org,*.mydomain.com ssh-rsa AAAAB5W...
1.120     markus    739: .Ed
1.2       deraadt   740: .Sh FILES
1.223     jmc       741: .Bl -tag -width Ds -compact
1.258     jmc       742: .It Pa ~/.hushlogin
1.204     jmc       743: This file is used to suppress printing the last login time and
                    744: .Pa /etc/motd ,
                    745: if
                    746: .Cm PrintLastLog
                    747: and
                    748: .Cm PrintMotd ,
                    749: respectively,
                    750: are enabled.
                    751: It does not suppress printing of the banner specified by
                    752: .Cm Banner .
1.223     jmc       753: .Pp
1.258     jmc       754: .It Pa ~/.rhosts
1.225     jmc       755: This file is used for host-based authentication (see
                    756: .Xr ssh 1
                    757: for more information).
                    758: On some machines this file may need to be
                    759: world-readable if the user's home directory is on an NFS partition,
                    760: because
                    761: .Nm
                    762: reads it as root.
                    763: Additionally, this file must be owned by the user,
                    764: and must not have write permissions for anyone else.
                    765: The recommended
                    766: permission for most machines is read/write for the user, and not
1.1       deraadt   767: accessible by others.
1.2       deraadt   768: .Pp
1.258     jmc       769: .It Pa ~/.shosts
1.225     jmc       770: This file is used in exactly the same way as
                    771: .Pa .rhosts ,
                    772: but allows host-based authentication without permitting login with
                    773: rlogin/rsh.
1.238     mcbride   774: .Pp
1.258     jmc       775: .It Pa ~/.ssh/
1.238     mcbride   776: This directory is the default location for all user-specific configuration
                    777: and authentication information.
                    778: There is no general requirement to keep the entire contents of this directory
                    779: secret, but the recommended permissions are read/write/execute for the user,
                    780: and not accessible by others.
1.2       deraadt   781: .Pp
1.258     jmc       782: .It Pa ~/.ssh/authorized_keys
1.259     djm       783: Lists the public keys (DSA/ECDSA/RSA) that can be used for logging in
                    784: as this user.
1.223     jmc       785: The format of this file is described above.
1.234     dtucker   786: The content of the file is not highly sensitive, but the recommended
1.225     jmc       787: permissions are read/write for the user, and not accessible by others.
1.234     dtucker   788: .Pp
                    789: If this file, the
                    790: .Pa ~/.ssh
                    791: directory, or the user's home directory are writable
                    792: by other users, then the file could be modified or replaced by unauthorized
                    793: users.
                    794: In this case,
                    795: .Nm
                    796: will not allow it to be used unless the
                    797: .Cm StrictModes
                    798: option has been set to
                    799: .Dq no .
1.2       deraadt   800: .Pp
1.258     jmc       801: .It Pa ~/.ssh/environment
1.36      aaron     802: This file is read into the environment at login (if it exists).
                    803: It can only contain empty lines, comment lines (that start with
1.2       deraadt   804: .Ql # ) ,
1.36      aaron     805: and assignment lines of the form name=value.
                    806: The file should be writable
1.6       aaron     807: only by the user; it need not be readable by anyone else.
1.188     stevesk   808: Environment processing is disabled by default and is
                    809: controlled via the
                    810: .Cm PermitUserEnvironment
                    811: option.
1.223     jmc       812: .Pp
1.258     jmc       813: .It Pa ~/.ssh/known_hosts
1.225     jmc       814: Contains a list of host keys for all hosts the user has logged into
                    815: that are not already in the systemwide list of known host keys.
                    816: The format of this file is described above.
                    817: This file should be writable only by root/the owner and
1.223     jmc       818: can, but need not be, world-readable.
                    819: .Pp
1.258     jmc       820: .It Pa ~/.ssh/rc
1.226     jmc       821: Contains initialization routines to be run before
                    822: the user's home directory becomes accessible.
1.1       deraadt   823: This file should be writable only by the user, and need not be
                    824: readable by anyone else.
1.223     jmc       825: .Pp
1.258     jmc       826: .It Pa /etc/hosts.allow
                    827: .It Pa /etc/hosts.deny
1.223     jmc       828: Access controls that should be enforced by tcp-wrappers are defined here.
                    829: Further details are described in
                    830: .Xr hosts_access 5 .
                    831: .Pp
1.258     jmc       832: .It Pa /etc/hosts.equiv
1.227     jmc       833: This file is for host-based authentication (see
                    834: .Xr ssh 1 ) .
                    835: It should only be writable by root.
1.223     jmc       836: .Pp
1.258     jmc       837: .It Pa /etc/moduli
1.223     jmc       838: Contains Diffie-Hellman groups used for the "Diffie-Hellman Group Exchange".
                    839: The file format is described in
                    840: .Xr moduli 5 .
                    841: .Pp
1.258     jmc       842: .It Pa /etc/motd
1.223     jmc       843: See
                    844: .Xr motd 5 .
                    845: .Pp
1.258     jmc       846: .It Pa /etc/nologin
1.223     jmc       847: If this file exists,
                    848: .Nm
                    849: refuses to let anyone except root log in.
                    850: The contents of the file
                    851: are displayed to anyone trying to log in, and non-root connections are
                    852: refused.
                    853: The file should be world-readable.
                    854: .Pp
1.258     jmc       855: .It Pa /etc/shosts.equiv
1.227     jmc       856: This file is used in exactly the same way as
                    857: .Pa hosts.equiv ,
                    858: but allows host-based authentication without permitting login with
                    859: rlogin/rsh.
1.225     jmc       860: .Pp
1.258     jmc       861: .It Pa /etc/ssh/ssh_host_key
                    862: .It Pa /etc/ssh/ssh_host_dsa_key
1.259     djm       863: .It Pa /etc/ssh/ssh_host_ecdsa_key
1.258     jmc       864: .It Pa /etc/ssh/ssh_host_rsa_key
1.266     dtucker   865: These files contain the private parts of the host keys.
1.223     jmc       866: These files should only be owned by root, readable only by root, and not
                    867: accessible to others.
                    868: Note that
                    869: .Nm
1.228     jmc       870: does not start if these files are group/world-accessible.
1.223     jmc       871: .Pp
1.258     jmc       872: .It Pa /etc/ssh/ssh_host_key.pub
                    873: .It Pa /etc/ssh/ssh_host_dsa_key.pub
1.259     djm       874: .It Pa /etc/ssh/ssh_host_ecdsa_key.pub
1.258     jmc       875: .It Pa /etc/ssh/ssh_host_rsa_key.pub
1.266     dtucker   876: These files contain the public parts of the host keys.
1.223     jmc       877: These files should be world-readable but writable only by
                    878: root.
                    879: Their contents should match the respective private parts.
                    880: These files are not
                    881: really used for anything; they are provided for the convenience of
                    882: the user so their contents can be copied to known hosts files.
                    883: These files are created using
                    884: .Xr ssh-keygen 1 .
                    885: .Pp
1.258     jmc       886: .It Pa /etc/ssh/ssh_known_hosts
1.235     jmc       887: Systemwide list of known host keys.
                    888: This file should be prepared by the
                    889: system administrator to contain the public host keys of all machines in the
                    890: organization.
                    891: The format of this file is described above.
                    892: This file should be writable only by root/the owner and
                    893: should be world-readable.
                    894: .Pp
1.258     jmc       895: .It Pa /etc/ssh/sshd_config
1.223     jmc       896: Contains configuration data for
                    897: .Nm sshd .
                    898: The file format and configuration options are described in
                    899: .Xr sshd_config 5 .
                    900: .Pp
1.258     jmc       901: .It Pa /etc/ssh/sshrc
1.226     jmc       902: Similar to
                    903: .Pa ~/.ssh/rc ,
                    904: it can be used to specify
1.36      aaron     905: machine-specific login-time initializations globally.
                    906: This file should be writable only by root, and should be world-readable.
1.223     jmc       907: .Pp
1.258     jmc       908: .It Pa /var/empty
1.223     jmc       909: .Xr chroot 2
                    910: directory used by
                    911: .Nm
                    912: during privilege separation in the pre-authentication phase.
                    913: The directory should not contain any files and must be owned by root
                    914: and not group or world-writable.
                    915: .Pp
1.258     jmc       916: .It Pa /var/run/sshd.pid
1.223     jmc       917: Contains the process ID of the
                    918: .Nm
                    919: listening for connections (if there are several daemons running
                    920: concurrently for different ports, this contains the process ID of the one
                    921: started last).
                    922: The content of this file is not sensitive; it can be world-readable.
1.56      aaron     923: .El
1.2       deraadt   924: .Sh SEE ALSO
                    925: .Xr scp 1 ,
1.90      djm       926: .Xr sftp 1 ,
1.2       deraadt   927: .Xr ssh 1 ,
1.5       deraadt   928: .Xr ssh-add 1 ,
1.2       deraadt   929: .Xr ssh-agent 1 ,
1.5       deraadt   930: .Xr ssh-keygen 1 ,
1.235     jmc       931: .Xr ssh-keyscan 1 ,
1.200     jmc       932: .Xr chroot 2 ,
                    933: .Xr hosts_access 5 ,
1.136     markus    934: .Xr login.conf 5 ,
                    935: .Xr moduli 5 ,
1.184     stevesk   936: .Xr sshd_config 5 ,
1.200     jmc       937: .Xr inetd 8 ,
1.128     mpech     938: .Xr sftp-server 8
1.198     jmc       939: .Sh AUTHORS
                    940: OpenSSH is a derivative of the original and free
                    941: ssh 1.2.12 release by Tatu Ylonen.
                    942: Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos,
                    943: Theo de Raadt and Dug Song
                    944: removed many bugs, re-added newer features and
                    945: created OpenSSH.
                    946: Markus Friedl contributed the support for SSH
                    947: protocol versions 1.5 and 2.0.
                    948: Niels Provos and Markus Friedl contributed support
                    949: for privilege separation.
1.216     jmc       950: .Sh CAVEATS
                    951: System security is not improved unless
                    952: .Nm rshd ,
                    953: .Nm rlogind ,
                    954: and
                    955: .Nm rexecd
                    956: are disabled (thus completely disabling
                    957: .Xr rlogin
                    958: and
                    959: .Xr rsh
                    960: into the machine).