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

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.321   ! jmc        36: .\" $OpenBSD: sshd.8,v 1.320 2022/08/11 01:56:51 djm Exp $
        !            37: .Dd $Mdocdate: August 11 2022 $
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
1.321   ! jmc       220: .Vt utmp
1.61      markus    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.317     dtucker   279: After this, the client either requests an interactive shell or execution
                    280: or a non-interactive command, which
                    281: .Nm
                    282: will execute via the user's shell using its
                    283: .Fl c
                    284: option.
1.212     jmc       285: The sides then enter session mode.
                    286: In this mode, either side may send
                    287: data at any time, and such data is forwarded to/from the shell or
                    288: command on the server side, and the user terminal in the client side.
                    289: .Pp
                    290: When the user program terminates and all forwarded X11 and other
                    291: connections have been closed, the server sends command exit status to
                    292: the client, and both sides exit.
1.2       deraadt   293: .Sh LOGIN PROCESS
1.1       deraadt   294: When a user successfully logs in,
1.2       deraadt   295: .Nm
1.1       deraadt   296: does the following:
1.2       deraadt   297: .Bl -enum -offset indent
                    298: .It
1.1       deraadt   299: If the login is on a tty, and no command has been specified,
1.40      aaron     300: prints last login time and
1.2       deraadt   301: .Pa /etc/motd
1.1       deraadt   302: (unless prevented in the configuration file or by
1.207     djm       303: .Pa ~/.hushlogin ;
1.2       deraadt   304: see the
1.40      aaron     305: .Sx FILES
1.2       deraadt   306: section).
                    307: .It
1.1       deraadt   308: If the login is on a tty, records login time.
1.2       deraadt   309: .It
                    310: Checks
                    311: .Pa /etc/nologin ;
                    312: if it exists, prints contents and quits
1.1       deraadt   313: (unless root).
1.2       deraadt   314: .It
1.1       deraadt   315: Changes to run with normal user privileges.
1.2       deraadt   316: .It
1.1       deraadt   317: Sets up basic environment.
1.2       deraadt   318: .It
1.200     jmc       319: Reads the file
1.207     djm       320: .Pa ~/.ssh/environment ,
1.200     jmc       321: if it exists, and users are allowed to change their environment.
1.188     stevesk   322: See the
1.187     marc      323: .Cm PermitUserEnvironment
1.188     stevesk   324: option in
1.187     marc      325: .Xr sshd_config 5 .
1.2       deraadt   326: .It
1.1       deraadt   327: Changes to user's home directory.
1.2       deraadt   328: .It
                    329: If
1.207     djm       330: .Pa ~/.ssh/rc
1.276     djm       331: exists and the
                    332: .Xr sshd_config 5
                    333: .Cm PermitUserRC
                    334: option is set, runs it; else if
1.168     deraadt   335: .Pa /etc/ssh/sshrc
1.2       deraadt   336: exists, runs
1.316     jmc       337: it; otherwise runs
                    338: .Xr xauth 1 .
1.36      aaron     339: The
1.2       deraadt   340: .Dq rc
                    341: files are given the X11
1.1       deraadt   342: authentication protocol and cookie in standard input.
1.226     jmc       343: See
                    344: .Sx SSHRC ,
                    345: below.
1.2       deraadt   346: .It
1.1       deraadt   347: Runs user's shell or command.
1.279     djm       348: All commands are run under the user's login shell as specified in the
                    349: system password database.
1.2       deraadt   350: .El
1.226     jmc       351: .Sh SSHRC
                    352: If the file
                    353: .Pa ~/.ssh/rc
                    354: exists,
                    355: .Xr sh 1
                    356: runs it after reading the
                    357: environment files but before starting the user's shell or command.
                    358: It must not produce any output on stdout; stderr must be used
                    359: instead.
                    360: If X11 forwarding is in use, it will receive the "proto cookie" pair in
                    361: its standard input (and
                    362: .Ev DISPLAY
                    363: in its environment).
                    364: The script must call
                    365: .Xr xauth 1
                    366: because
                    367: .Nm
                    368: will not run xauth automatically to add X11 cookies.
                    369: .Pp
                    370: The primary purpose of this file is to run any initialization routines
                    371: which may be needed before the user's home directory becomes
                    372: accessible; AFS is a particular example of such an environment.
                    373: .Pp
                    374: This file will probably contain some initialization code followed by
                    375: something similar to:
                    376: .Bd -literal -offset 3n
                    377: if read proto cookie && [ -n "$DISPLAY" ]; then
                    378:        if [ `echo $DISPLAY | cut -c1-10` = 'localhost:' ]; then
                    379:                # X11UseLocalhost=yes
                    380:                echo add unix:`echo $DISPLAY |
                    381:                    cut -c11-` $proto $cookie
                    382:        else
                    383:                # X11UseLocalhost=no
                    384:                echo add $DISPLAY $proto $cookie
                    385:        fi | xauth -q -
                    386: fi
                    387: .Ed
                    388: .Pp
                    389: If this file does not exist,
                    390: .Pa /etc/ssh/sshrc
                    391: is run, and if that
                    392: does not exist either, xauth is used to add the cookie.
1.2       deraadt   393: .Sh AUTHORIZED_KEYS FILE FORMAT
1.125     markus    394: .Cm AuthorizedKeysFile
1.262     jmc       395: specifies the files containing public keys for
1.217     jmc       396: public key authentication;
1.281     djm       397: if this option is not specified, the default is
1.261     djm       398: .Pa ~/.ssh/authorized_keys
                    399: and
                    400: .Pa ~/.ssh/authorized_keys2 .
1.36      aaron     401: Each line of the file contains one
1.2       deraadt   402: key (empty lines and lines starting with a
                    403: .Ql #
                    404: are ignored as
1.36      aaron     405: comments).
1.285     naddy     406: Public keys consist of the following space-separated fields:
1.217     jmc       407: options, keytype, base64-encoded key, comment.
1.285     naddy     408: The options field is optional.
1.305     naddy     409: The supported key types are:
                    410: .Pp
                    411: .Bl -item -compact -offset indent
                    412: .It
                    413: sk-ecdsa-sha2-nistp256@openssh.com
                    414: .It
                    415: ecdsa-sha2-nistp256
                    416: .It
                    417: ecdsa-sha2-nistp384
                    418: .It
                    419: ecdsa-sha2-nistp521
                    420: .It
1.306     djm       421: sk-ssh-ed25519@openssh.com
                    422: .It
1.305     naddy     423: ssh-ed25519
                    424: .It
                    425: ssh-dss
                    426: .It
                    427: ssh-rsa
                    428: .El
                    429: .Pp
                    430: The comment field is not used for anything (but may be convenient for the
1.285     naddy     431: user to identify the key).
1.2       deraadt   432: .Pp
1.285     naddy     433: Note that lines in this file can be several hundred bytes long
1.203     dtucker   434: (because of the size of the public key encoding) up to a limit of
1.305     naddy     435: 8 kilobytes, which permits RSA keys up to 16 kilobits.
1.36      aaron     436: You don't want to type them in; instead, copy the
1.217     jmc       437: .Pa id_dsa.pub ,
1.259     djm       438: .Pa id_ecdsa.pub ,
1.305     naddy     439: .Pa id_ecdsa_sk.pub ,
1.273     naddy     440: .Pa id_ed25519.pub ,
1.306     djm       441: .Pa id_ed25519_sk.pub ,
1.75      markus    442: or the
1.113     itojun    443: .Pa id_rsa.pub
1.1       deraadt   444: file and edit it.
1.175     stevesk   445: .Pp
                    446: .Nm
1.296     dtucker   447: enforces a minimum RSA key modulus size of 1024 bits.
1.2       deraadt   448: .Pp
1.58      deraadt   449: The options (if present) consist of comma-separated option
1.36      aaron     450: specifications.
                    451: No spaces are permitted, except within double quotes.
1.141     stevesk   452: The following option specifications are supported (note
                    453: that option keywords are case-insensitive):
1.2       deraadt   454: .Bl -tag -width Ds
1.282     djm       455: .It Cm agent-forwarding
                    456: Enable authentication agent forwarding previously disabled by the
                    457: .Cm restrict
                    458: option.
1.253     djm       459: .It Cm cert-authority
1.251     djm       460: Specifies that the listed key is a certification authority (CA) that is
                    461: trusted to validate signed certificates for user authentication.
                    462: .Pp
                    463: Certificates may encode access restrictions similar to these key options.
                    464: If both certificate restrictions and key options are present, the most
                    465: restrictive union of the two is applied.
1.2       deraadt   466: .It Cm command="command"
1.1       deraadt   467: Specifies that the command is executed whenever this key is used for
1.36      aaron     468: authentication.
                    469: The command supplied by the user (if any) is ignored.
1.148     markus    470: The command is run on a pty if the client requests a pty;
1.36      aaron     471: otherwise it is run without a tty.
1.194     jmc       472: If an 8-bit clean channel is required,
1.147     deraadt   473: one must not request a pty or should specify
1.89      markus    474: .Cm no-pty .
1.36      aaron     475: A quote may be included in the command by quoting it with a backslash.
1.287     djm       476: .Pp
1.36      aaron     477: This option might be useful
1.189     espie     478: to restrict certain public keys to perform just a specific operation.
1.36      aaron     479: An example might be a key that permits remote backups but nothing else.
1.211     jmc       480: Note that the client may specify TCP and/or X11
1.287     djm       481: forwarding unless they are explicitly prohibited, e.g. using the
                    482: .Cm restrict
                    483: key option.
                    484: .Pp
1.233     dtucker   485: The command originally supplied by the client is available in the
                    486: .Ev SSH_ORIGINAL_COMMAND
                    487: environment variable.
1.149     markus    488: Note that this option applies to shell, command or subsystem execution.
1.287     djm       489: Also note that this command may be superseded by a
1.251     djm       490: .Xr sshd_config 5
                    491: .Cm ForceCommand
1.287     djm       492: directive.
                    493: .Pp
                    494: If a command is specified and a forced-command is embedded in a certificate
                    495: used for authentication, then the certificate will be accepted only if the
                    496: two commands are identical.
1.2       deraadt   497: .It Cm environment="NAME=value"
1.1       deraadt   498: Specifies that the string is to be added to the environment when
1.36      aaron     499: logging in using this key.
                    500: Environment variables set this way
                    501: override other default environment values.
                    502: Multiple options of this type are permitted.
1.188     stevesk   503: Environment processing is disabled by default and is
                    504: controlled via the
                    505: .Cm PermitUserEnvironment
                    506: option.
1.299     jmc       507: .It Cm expiry-time="timespec"
                    508: Specifies a time after which the key will not be accepted.
1.320     djm       509: The time may be specified as a YYYYMMDD[Z] date or a YYYYMMDDHHMM[SS][Z] time.
                    510: Dates and times will be interpreted in the system time zone unless suffixed
                    511: by a Z character, in which case they will be interpreted in the UTC time zone.
1.218     jmc       512: .It Cm from="pattern-list"
1.244     djm       513: Specifies that in addition to public key authentication, either the canonical
1.245     jmc       514: name of the remote host or its IP address must be present in the
1.244     djm       515: comma-separated list of patterns.
1.270     jmc       516: See PATTERNS in
1.229     jmc       517: .Xr ssh_config 5
                    518: for more information on patterns.
1.244     djm       519: .Pp
                    520: In addition to the wildcard matching that may be applied to hostnames or
                    521: addresses, a
                    522: .Cm from
1.248     sobrado   523: stanza may match IP addresses using CIDR address/masklen notation.
1.244     djm       524: .Pp
                    525: The purpose of this option is to optionally increase security: public key
                    526: authentication by itself does not trust the network or name servers or
                    527: anything (but the key); however, if somebody somehow steals the key, the key
                    528: permits an intruder to log in from anywhere in the world.
                    529: This additional option makes using a stolen key more difficult (name
                    530: servers and/or routers would have to be compromised in addition to
                    531: just the key).
1.218     jmc       532: .It Cm no-agent-forwarding
                    533: Forbids authentication agent forwarding when this key is used for
                    534: authentication.
1.2       deraadt   535: .It Cm no-port-forwarding
1.211     jmc       536: Forbids TCP forwarding when this key is used for authentication.
1.36      aaron     537: Any port forward requests by the client will return an error.
1.230     jmc       538: This might be used, e.g. in connection with the
1.2       deraadt   539: .Cm command
1.1       deraadt   540: option.
1.218     jmc       541: .It Cm no-pty
                    542: Prevents tty allocation (a request to allocate a pty will fail).
1.240     djm       543: .It Cm no-user-rc
1.241     jmc       544: Disables execution of
1.240     djm       545: .Pa ~/.ssh/rc .
1.2       deraadt   546: .It Cm no-X11-forwarding
1.1       deraadt   547: Forbids X11 forwarding when this key is used for authentication.
                    548: Any X11 forward requests by the client will return an error.
1.302     djm       549: .It Cm permitlisten="[host:]port"
1.301     jmc       550: Limit remote port forwarding with the
1.300     djm       551: .Xr ssh 1
                    552: .Fl R
1.302     djm       553: option such that it may only listen on the specified host (optional) and port.
1.300     djm       554: IPv6 addresses can be specified by enclosing the address in square brackets.
                    555: Multiple
                    556: .Cm permitlisten
                    557: options may be applied separated by commas.
                    558: Hostnames may include wildcards as described in the PATTERNS section in
                    559: .Xr ssh_config 5 .
                    560: A port specification of
                    561: .Cm *
                    562: matches any port.
                    563: Note that the setting of
                    564: .Cm GatewayPorts
                    565: may further restrict listen addresses.
1.302     djm       566: Note that
                    567: .Xr ssh 1
                    568: will send a hostname of
                    569: .Dq localhost
                    570: if a listen host was not specified when the forwarding was requested, and
1.303     jmc       571: that this name is treated differently to the explicit localhost addresses
1.302     djm       572: .Dq 127.0.0.1
                    573: and
                    574: .Dq ::1 .
1.107     djm       575: .It Cm permitopen="host:port"
1.301     jmc       576: Limit local port forwarding with the
1.278     bentley   577: .Xr ssh 1
                    578: .Fl L
1.300     djm       579: option such that it may only connect to the specified host and port.
1.257     djm       580: IPv6 addresses can be specified by enclosing the address in square brackets.
1.146     stevesk   581: Multiple
1.107     djm       582: .Cm permitopen
1.197     jmc       583: options may be applied separated by commas.
1.312     djm       584: No pattern matching or name lookup is performed on the
                    585: specified hostnames, they must be literal host names and/or addresses.
1.264     dtucker   586: A port specification of
                    587: .Cm *
                    588: matches any port.
1.282     djm       589: .It Cm port-forwarding
                    590: Enable port forwarding previously disabled by the
                    591: .Cm restrict
1.294     djm       592: option.
1.256     djm       593: .It Cm principals="principals"
                    594: On a
                    595: .Cm cert-authority
                    596: line, specifies allowed principals for certificate authentication as a
                    597: comma-separated list.
                    598: At least one name from the list must appear in the certificate's
                    599: list of principals for the certificate to be accepted.
                    600: This option is ignored for keys that are not marked as trusted certificate
                    601: signers using the
                    602: .Cm cert-authority
                    603: option.
1.282     djm       604: .It Cm pty
                    605: Permits tty allocation previously disabled by the
                    606: .Cm restrict
                    607: option.
1.307     djm       608: .It Cm no-touch-required
                    609: Do not require demonstration of user presence
                    610: for signatures made using this key.
1.313     djm       611: This option only makes sense for the FIDO authenticator algorithms
                    612: .Cm ecdsa-sk
                    613: and
                    614: .Cm ed25519-sk .
                    615: .It Cm verify-required
                    616: Require that signatures made using this key attest that they verified
                    617: the user, e.g. via a PIN.
1.311     naddy     618: This option only makes sense for the FIDO authenticator algorithms
1.307     djm       619: .Cm ecdsa-sk
                    620: and
                    621: .Cm ed25519-sk .
1.282     djm       622: .It Cm restrict
                    623: Enable all restrictions, i.e. disable port, agent and X11 forwarding,
                    624: as well as disabling PTY allocation
                    625: and execution of
                    626: .Pa ~/.ssh/rc .
1.318     naddy     627: If any future restriction capabilities are added to authorized_keys files,
1.282     djm       628: they will be included in this set.
1.209     reyk      629: .It Cm tunnel="n"
                    630: Force a
                    631: .Xr tun 4
                    632: device on the server.
                    633: Without this option, the next available device will be used if
                    634: the client requests a tunnel.
1.282     djm       635: .It Cm user-rc
                    636: Enables execution of
                    637: .Pa ~/.ssh/rc
                    638: previously disabled by the
                    639: .Cm restrict
                    640: option.
                    641: .It Cm X11-forwarding
                    642: Permits X11 forwarding previously disabled by the
                    643: .Cm restrict
                    644: option.
1.2       deraadt   645: .El
                    646: .Pp
1.219     jmc       647: An example authorized_keys file:
1.222     jmc       648: .Bd -literal -offset 3n
1.315     djm       649: # Comments are allowed at start of line. Blank lines are allowed.
                    650: # Plain key, no restrictions
                    651: ssh-rsa ...
                    652: # Forced command, disable PTY and all forwarding
                    653: restrict,command="dump /home" ssh-rsa ...
                    654: # Restriction of ssh -L forwarding destinations
                    655: permitopen="192.0.2.1:80",permitopen="192.0.2.2:25" ssh-rsa ...
                    656: # Restriction of ssh -R forwarding listeners
                    657: permitlisten="localhost:8080",permitlisten="[::1]:22000" ssh-rsa ...
                    658: # Configuration for tunnel forwarding
                    659: tunnel="0",command="sh /etc/netstart tun0" ssh-rsa ...
                    660: # Override of restriction to allow PTY allocation
                    661: restrict,pty,command="nethack" ssh-rsa ...
                    662: # Allow FIDO key without requiring touch
                    663: no-touch-required sk-ecdsa-sha2-nistp256@openssh.com ...
                    664: # Require user-verification (e.g. PIN or biometric) for FIDO key
                    665: verify-required sk-ecdsa-sha2-nistp256@openssh.com ...
                    666: # Trust CA key, allow touch-less FIDO if requested in certificate
                    667: cert-authority,no-touch-required,principals="user_a" ssh-rsa ...
1.219     jmc       668: .Ed
1.2       deraadt   669: .Sh SSH_KNOWN_HOSTS FILE FORMAT
1.40      aaron     670: The
1.194     jmc       671: .Pa /etc/ssh/ssh_known_hosts
1.40      aaron     672: and
1.207     djm       673: .Pa ~/.ssh/known_hosts
1.36      aaron     674: files contain host public keys for all known hosts.
                    675: The global file should
1.37      brad      676: be prepared by the administrator (optional), and the per-user file is
1.288     dtucker   677: maintained automatically: whenever the user connects to an unknown host,
1.36      aaron     678: its key is added to the per-user file.
1.2       deraadt   679: .Pp
1.314     djm       680: Each line in these files contains the following fields: marker (optional),
1.285     naddy     681: hostnames, keytype, base64-encoded key, comment.
1.36      aaron     682: The fields are separated by spaces.
1.2       deraadt   683: .Pp
1.254     djm       684: The marker is optional, but if it is present then it must be one of
                    685: .Dq @cert-authority ,
                    686: to indicate that the line contains a certification authority (CA) key,
                    687: or
                    688: .Dq @revoked ,
                    689: to indicate that the key contained on the line is revoked and must not ever
                    690: be accepted.
                    691: Only one marker should be used on a key line.
                    692: .Pp
1.196     david     693: Hostnames is a comma-separated list of patterns
1.220     jmc       694: .Pf ( Ql *
1.197     jmc       695: and
                    696: .Ql \&?
1.195     mouring   697: act as
1.290     djm       698: wildcards); each pattern in turn is matched against the host name.
                    699: When
                    700: .Nm sshd
                    701: is authenticating a client, such as when using
                    702: .Cm HostbasedAuthentication ,
                    703: this will be the canonical client host name.
                    704: When
                    705: .Xr ssh 1
1.291     jmc       706: is authenticating a server, this will be the host name
1.290     djm       707: given by the user, the value of the
                    708: .Xr ssh 1
                    709: .Cm HostkeyAlias
                    710: if it was specified, or the canonical server hostname if the
                    711: .Xr ssh 1
                    712: .Cm CanonicalizeHostname
                    713: option was used.
                    714: .Pp
1.36      aaron     715: A pattern may also be preceded by
1.195     mouring   716: .Ql \&!
1.2       deraadt   717: to indicate negation: if the host name matches a negated
1.1       deraadt   718: pattern, it is not accepted (by that line) even if it matched another
                    719: pattern on the line.
1.231     dtucker   720: A hostname or address may optionally be enclosed within
                    721: .Ql \&[
                    722: and
                    723: .Ql \&]
                    724: brackets then followed by
                    725: .Ql \&:
1.232     jmc       726: and a non-standard port number.
1.2       deraadt   727: .Pp
1.205     djm       728: Alternately, hostnames may be stored in a hashed form which hides host names
1.206     jmc       729: and addresses should the file's contents be disclosed.
                    730: Hashed hostnames start with a
                    731: .Ql |
1.205     djm       732: character.
                    733: Only one hashed hostname may appear on a single line and none of the above
                    734: negation or wildcard operators may be applied.
                    735: .Pp
1.285     naddy     736: The keytype and base64-encoded key are taken directly from the host key; they
1.220     jmc       737: can be obtained, for example, from
1.285     naddy     738: .Pa /etc/ssh/ssh_host_rsa_key.pub .
1.1       deraadt   739: The optional comment field continues to the end of the line, and is not used.
1.2       deraadt   740: .Pp
                    741: Lines starting with
                    742: .Ql #
                    743: and empty lines are ignored as comments.
                    744: .Pp
1.1       deraadt   745: When performing host authentication, authentication is accepted if any
1.254     djm       746: matching line has the proper key; either one that matches exactly or,
                    747: if the server has presented a certificate for authentication, the key
                    748: of the certification authority that signed the certificate.
                    749: For a key to be trusted as a certification authority, it must use the
                    750: .Dq @cert-authority
                    751: marker described above.
                    752: .Pp
                    753: The known hosts file also provides a facility to mark keys as revoked,
                    754: for example when it is known that the associated private key has been
                    755: stolen.
                    756: Revoked keys are specified by including the
                    757: .Dq @revoked
                    758: marker at the beginning of the key line, and are never accepted for
                    759: authentication or as certification authorities, but instead will
                    760: produce a warning from
                    761: .Xr ssh 1
                    762: when they are encountered.
                    763: .Pp
                    764: It is permissible (but not
1.1       deraadt   765: recommended) to have several lines or different host keys for the same
1.36      aaron     766: names.
                    767: This will inevitably happen when short forms of host names
                    768: from different domains are put in the file.
                    769: It is possible
1.1       deraadt   770: that the files contain conflicting information; authentication is
                    771: accepted if valid information can be found from either file.
1.2       deraadt   772: .Pp
1.1       deraadt   773: Note that the lines in these files are typically hundreds of characters
                    774: long, and you definitely don't want to type in the host keys by hand.
1.254     djm       775: Rather, generate them by a script,
                    776: .Xr ssh-keyscan 1
1.285     naddy     777: or by taking, for example,
                    778: .Pa /etc/ssh/ssh_host_rsa_key.pub
1.1       deraadt   779: and adding the host names at the front.
1.254     djm       780: .Xr ssh-keygen 1
1.255     jmc       781: also offers some basic automated editing for
1.254     djm       782: .Pa ~/.ssh/known_hosts
                    783: including removing hosts matching a host name and converting all host
                    784: names to their hashed representations.
1.221     jmc       785: .Pp
                    786: An example ssh_known_hosts file:
                    787: .Bd -literal -offset 3n
                    788: # Comments allowed at start of line
                    789: cvs.example.net,192.0.2.10 ssh-rsa AAAA1234.....=
1.205     djm       790: # A hashed hostname
                    791: |1|JfKTdBh7rNbXkVAQCRp4OQoPfmI=|USECr3SWf1JUPsms5AqfD5QfxkM= ssh-rsa
                    792: AAAA1234.....=
1.254     djm       793: # A revoked key
                    794: @revoked * ssh-rsa AAAAB5W...
                    795: # A CA key, accepted for any host in *.mydomain.com or *.mydomain.org
                    796: @cert-authority *.mydomain.org,*.mydomain.com ssh-rsa AAAAB5W...
1.120     markus    797: .Ed
1.2       deraadt   798: .Sh FILES
1.223     jmc       799: .Bl -tag -width Ds -compact
1.258     jmc       800: .It Pa ~/.hushlogin
1.204     jmc       801: This file is used to suppress printing the last login time and
                    802: .Pa /etc/motd ,
                    803: if
                    804: .Cm PrintLastLog
                    805: and
                    806: .Cm PrintMotd ,
                    807: respectively,
                    808: are enabled.
                    809: It does not suppress printing of the banner specified by
                    810: .Cm Banner .
1.223     jmc       811: .Pp
1.258     jmc       812: .It Pa ~/.rhosts
1.225     jmc       813: This file is used for host-based authentication (see
                    814: .Xr ssh 1
                    815: for more information).
                    816: On some machines this file may need to be
                    817: world-readable if the user's home directory is on an NFS partition,
                    818: because
                    819: .Nm
                    820: reads it as root.
                    821: Additionally, this file must be owned by the user,
                    822: and must not have write permissions for anyone else.
                    823: The recommended
                    824: permission for most machines is read/write for the user, and not
1.1       deraadt   825: accessible by others.
1.2       deraadt   826: .Pp
1.258     jmc       827: .It Pa ~/.shosts
1.225     jmc       828: This file is used in exactly the same way as
                    829: .Pa .rhosts ,
                    830: but allows host-based authentication without permitting login with
                    831: rlogin/rsh.
1.238     mcbride   832: .Pp
1.258     jmc       833: .It Pa ~/.ssh/
1.238     mcbride   834: This directory is the default location for all user-specific configuration
                    835: and authentication information.
                    836: There is no general requirement to keep the entire contents of this directory
                    837: secret, but the recommended permissions are read/write/execute for the user,
                    838: and not accessible by others.
1.2       deraadt   839: .Pp
1.258     jmc       840: .It Pa ~/.ssh/authorized_keys
1.277     sobrado   841: Lists the public keys (DSA, ECDSA, Ed25519, RSA)
1.273     naddy     842: that can be used for logging in as this user.
1.223     jmc       843: The format of this file is described above.
1.234     dtucker   844: The content of the file is not highly sensitive, but the recommended
1.225     jmc       845: permissions are read/write for the user, and not accessible by others.
1.234     dtucker   846: .Pp
                    847: If this file, the
                    848: .Pa ~/.ssh
                    849: directory, or the user's home directory are writable
                    850: by other users, then the file could be modified or replaced by unauthorized
                    851: users.
                    852: In this case,
                    853: .Nm
                    854: will not allow it to be used unless the
                    855: .Cm StrictModes
                    856: option has been set to
                    857: .Dq no .
1.2       deraadt   858: .Pp
1.258     jmc       859: .It Pa ~/.ssh/environment
1.36      aaron     860: This file is read into the environment at login (if it exists).
                    861: It can only contain empty lines, comment lines (that start with
1.2       deraadt   862: .Ql # ) ,
1.36      aaron     863: and assignment lines of the form name=value.
                    864: The file should be writable
1.6       aaron     865: only by the user; it need not be readable by anyone else.
1.188     stevesk   866: Environment processing is disabled by default and is
                    867: controlled via the
                    868: .Cm PermitUserEnvironment
                    869: option.
1.223     jmc       870: .Pp
1.258     jmc       871: .It Pa ~/.ssh/known_hosts
1.225     jmc       872: Contains a list of host keys for all hosts the user has logged into
                    873: that are not already in the systemwide list of known host keys.
                    874: The format of this file is described above.
                    875: This file should be writable only by root/the owner and
1.223     jmc       876: can, but need not be, world-readable.
                    877: .Pp
1.258     jmc       878: .It Pa ~/.ssh/rc
1.226     jmc       879: Contains initialization routines to be run before
                    880: the user's home directory becomes accessible.
1.1       deraadt   881: This file should be writable only by the user, and need not be
                    882: readable by anyone else.
1.223     jmc       883: .Pp
1.258     jmc       884: .It Pa /etc/hosts.equiv
1.227     jmc       885: This file is for host-based authentication (see
                    886: .Xr ssh 1 ) .
                    887: It should only be writable by root.
1.223     jmc       888: .Pp
1.258     jmc       889: .It Pa /etc/moduli
1.283     djm       890: Contains Diffie-Hellman groups used for the "Diffie-Hellman Group Exchange"
                    891: key exchange method.
1.223     jmc       892: The file format is described in
                    893: .Xr moduli 5 .
1.283     djm       894: If no usable groups are found in this file then fixed internal groups will
                    895: be used.
1.223     jmc       896: .Pp
1.258     jmc       897: .It Pa /etc/motd
1.223     jmc       898: See
                    899: .Xr motd 5 .
                    900: .Pp
1.258     jmc       901: .It Pa /etc/nologin
1.223     jmc       902: If this file exists,
                    903: .Nm
                    904: refuses to let anyone except root log in.
                    905: The contents of the file
                    906: are displayed to anyone trying to log in, and non-root connections are
                    907: refused.
                    908: The file should be world-readable.
                    909: .Pp
1.258     jmc       910: .It Pa /etc/shosts.equiv
1.227     jmc       911: This file is used in exactly the same way as
                    912: .Pa hosts.equiv ,
                    913: but allows host-based authentication without permitting login with
                    914: rlogin/rsh.
1.225     jmc       915: .Pp
1.259     djm       916: .It Pa /etc/ssh/ssh_host_ecdsa_key
1.273     naddy     917: .It Pa /etc/ssh/ssh_host_ed25519_key
1.258     jmc       918: .It Pa /etc/ssh/ssh_host_rsa_key
1.266     dtucker   919: These files contain the private parts of the host keys.
1.223     jmc       920: These files should only be owned by root, readable only by root, and not
                    921: accessible to others.
                    922: Note that
                    923: .Nm
1.228     jmc       924: does not start if these files are group/world-accessible.
1.223     jmc       925: .Pp
1.259     djm       926: .It Pa /etc/ssh/ssh_host_ecdsa_key.pub
1.273     naddy     927: .It Pa /etc/ssh/ssh_host_ed25519_key.pub
1.258     jmc       928: .It Pa /etc/ssh/ssh_host_rsa_key.pub
1.266     dtucker   929: These files contain the public parts of the host keys.
1.223     jmc       930: These files should be world-readable but writable only by
                    931: root.
                    932: Their contents should match the respective private parts.
                    933: These files are not
                    934: really used for anything; they are provided for the convenience of
                    935: the user so their contents can be copied to known hosts files.
                    936: These files are created using
                    937: .Xr ssh-keygen 1 .
                    938: .Pp
1.258     jmc       939: .It Pa /etc/ssh/ssh_known_hosts
1.235     jmc       940: Systemwide list of known host keys.
                    941: This file should be prepared by the
                    942: system administrator to contain the public host keys of all machines in the
                    943: organization.
                    944: The format of this file is described above.
                    945: This file should be writable only by root/the owner and
                    946: should be world-readable.
                    947: .Pp
1.258     jmc       948: .It Pa /etc/ssh/sshd_config
1.223     jmc       949: Contains configuration data for
                    950: .Nm sshd .
                    951: The file format and configuration options are described in
                    952: .Xr sshd_config 5 .
                    953: .Pp
1.258     jmc       954: .It Pa /etc/ssh/sshrc
1.226     jmc       955: Similar to
                    956: .Pa ~/.ssh/rc ,
                    957: it can be used to specify
1.36      aaron     958: machine-specific login-time initializations globally.
                    959: This file should be writable only by root, and should be world-readable.
1.223     jmc       960: .Pp
1.258     jmc       961: .It Pa /var/empty
1.223     jmc       962: .Xr chroot 2
                    963: directory used by
                    964: .Nm
                    965: during privilege separation in the pre-authentication phase.
                    966: The directory should not contain any files and must be owned by root
                    967: and not group or world-writable.
                    968: .Pp
1.258     jmc       969: .It Pa /var/run/sshd.pid
1.223     jmc       970: Contains the process ID of the
                    971: .Nm
                    972: listening for connections (if there are several daemons running
                    973: concurrently for different ports, this contains the process ID of the one
                    974: started last).
                    975: The content of this file is not sensitive; it can be world-readable.
1.56      aaron     976: .El
1.2       deraadt   977: .Sh SEE ALSO
                    978: .Xr scp 1 ,
1.90      djm       979: .Xr sftp 1 ,
1.2       deraadt   980: .Xr ssh 1 ,
1.5       deraadt   981: .Xr ssh-add 1 ,
1.2       deraadt   982: .Xr ssh-agent 1 ,
1.5       deraadt   983: .Xr ssh-keygen 1 ,
1.235     jmc       984: .Xr ssh-keyscan 1 ,
1.200     jmc       985: .Xr chroot 2 ,
1.136     markus    986: .Xr login.conf 5 ,
                    987: .Xr moduli 5 ,
1.184     stevesk   988: .Xr sshd_config 5 ,
1.200     jmc       989: .Xr inetd 8 ,
1.128     mpech     990: .Xr sftp-server 8
1.198     jmc       991: .Sh AUTHORS
                    992: OpenSSH is a derivative of the original and free
                    993: ssh 1.2.12 release by Tatu Ylonen.
                    994: Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos,
                    995: Theo de Raadt and Dug Song
                    996: removed many bugs, re-added newer features and
                    997: created OpenSSH.
                    998: Markus Friedl contributed the support for SSH
                    999: protocol versions 1.5 and 2.0.
                   1000: Niels Provos and Markus Friedl contributed support
                   1001: for privilege separation.