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

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