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

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.319   ! jmc        36: .\" $OpenBSD: sshd.8,v 1.318 2022/03/31 17:27:27 naddy Exp $
        !            37: .Dd $Mdocdate: March 31 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
                    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.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.
                    509: The time may be specified as a YYYYMMDD date or a YYYYMMDDHHMM[SS] time
                    510: in the system time-zone.
1.218     jmc       511: .It Cm from="pattern-list"
1.244     djm       512: Specifies that in addition to public key authentication, either the canonical
1.245     jmc       513: name of the remote host or its IP address must be present in the
1.244     djm       514: comma-separated list of patterns.
1.270     jmc       515: See PATTERNS in
1.229     jmc       516: .Xr ssh_config 5
                    517: for more information on patterns.
1.244     djm       518: .Pp
                    519: In addition to the wildcard matching that may be applied to hostnames or
                    520: addresses, a
                    521: .Cm from
1.248     sobrado   522: stanza may match IP addresses using CIDR address/masklen notation.
1.244     djm       523: .Pp
                    524: The purpose of this option is to optionally increase security: public key
                    525: authentication by itself does not trust the network or name servers or
                    526: anything (but the key); however, if somebody somehow steals the key, the key
                    527: permits an intruder to log in from anywhere in the world.
                    528: This additional option makes using a stolen key more difficult (name
                    529: servers and/or routers would have to be compromised in addition to
                    530: just the key).
1.218     jmc       531: .It Cm no-agent-forwarding
                    532: Forbids authentication agent forwarding when this key is used for
                    533: authentication.
1.2       deraadt   534: .It Cm no-port-forwarding
1.211     jmc       535: Forbids TCP forwarding when this key is used for authentication.
1.36      aaron     536: Any port forward requests by the client will return an error.
1.230     jmc       537: This might be used, e.g. in connection with the
1.2       deraadt   538: .Cm command
1.1       deraadt   539: option.
1.218     jmc       540: .It Cm no-pty
                    541: Prevents tty allocation (a request to allocate a pty will fail).
1.240     djm       542: .It Cm no-user-rc
1.241     jmc       543: Disables execution of
1.240     djm       544: .Pa ~/.ssh/rc .
1.2       deraadt   545: .It Cm no-X11-forwarding
1.1       deraadt   546: Forbids X11 forwarding when this key is used for authentication.
                    547: Any X11 forward requests by the client will return an error.
1.302     djm       548: .It Cm permitlisten="[host:]port"
1.301     jmc       549: Limit remote port forwarding with the
1.300     djm       550: .Xr ssh 1
                    551: .Fl R
1.302     djm       552: option such that it may only listen on the specified host (optional) and port.
1.300     djm       553: IPv6 addresses can be specified by enclosing the address in square brackets.
                    554: Multiple
                    555: .Cm permitlisten
                    556: options may be applied separated by commas.
                    557: Hostnames may include wildcards as described in the PATTERNS section in
                    558: .Xr ssh_config 5 .
                    559: A port specification of
                    560: .Cm *
                    561: matches any port.
                    562: Note that the setting of
                    563: .Cm GatewayPorts
                    564: may further restrict listen addresses.
1.302     djm       565: Note that
                    566: .Xr ssh 1
                    567: will send a hostname of
                    568: .Dq localhost
                    569: if a listen host was not specified when the forwarding was requested, and
1.303     jmc       570: that this name is treated differently to the explicit localhost addresses
1.302     djm       571: .Dq 127.0.0.1
                    572: and
                    573: .Dq ::1 .
1.107     djm       574: .It Cm permitopen="host:port"
1.301     jmc       575: Limit local port forwarding with the
1.278     bentley   576: .Xr ssh 1
                    577: .Fl L
1.300     djm       578: option such that it may only connect to the specified host and port.
1.257     djm       579: IPv6 addresses can be specified by enclosing the address in square brackets.
1.146     stevesk   580: Multiple
1.107     djm       581: .Cm permitopen
1.197     jmc       582: options may be applied separated by commas.
1.312     djm       583: No pattern matching or name lookup is performed on the
                    584: specified hostnames, they must be literal host names and/or addresses.
1.264     dtucker   585: A port specification of
                    586: .Cm *
                    587: matches any port.
1.282     djm       588: .It Cm port-forwarding
                    589: Enable port forwarding previously disabled by the
                    590: .Cm restrict
1.294     djm       591: option.
1.256     djm       592: .It Cm principals="principals"
                    593: On a
                    594: .Cm cert-authority
                    595: line, specifies allowed principals for certificate authentication as a
                    596: comma-separated list.
                    597: At least one name from the list must appear in the certificate's
                    598: list of principals for the certificate to be accepted.
                    599: This option is ignored for keys that are not marked as trusted certificate
                    600: signers using the
                    601: .Cm cert-authority
                    602: option.
1.282     djm       603: .It Cm pty
                    604: Permits tty allocation previously disabled by the
                    605: .Cm restrict
                    606: option.
1.307     djm       607: .It Cm no-touch-required
                    608: Do not require demonstration of user presence
                    609: for signatures made using this key.
1.313     djm       610: This option only makes sense for the FIDO authenticator algorithms
                    611: .Cm ecdsa-sk
                    612: and
                    613: .Cm ed25519-sk .
                    614: .It Cm verify-required
                    615: Require that signatures made using this key attest that they verified
                    616: the user, e.g. via a PIN.
1.311     naddy     617: This option only makes sense for the FIDO authenticator algorithms
1.307     djm       618: .Cm ecdsa-sk
                    619: and
                    620: .Cm ed25519-sk .
1.282     djm       621: .It Cm restrict
                    622: Enable all restrictions, i.e. disable port, agent and X11 forwarding,
                    623: as well as disabling PTY allocation
                    624: and execution of
                    625: .Pa ~/.ssh/rc .
1.318     naddy     626: If any future restriction capabilities are added to authorized_keys files,
1.282     djm       627: they will be included in this set.
1.209     reyk      628: .It Cm tunnel="n"
                    629: Force a
                    630: .Xr tun 4
                    631: device on the server.
                    632: Without this option, the next available device will be used if
                    633: the client requests a tunnel.
1.282     djm       634: .It Cm user-rc
                    635: Enables execution of
                    636: .Pa ~/.ssh/rc
                    637: previously disabled by the
                    638: .Cm restrict
                    639: option.
                    640: .It Cm X11-forwarding
                    641: Permits X11 forwarding previously disabled by the
                    642: .Cm restrict
                    643: option.
1.2       deraadt   644: .El
                    645: .Pp
1.219     jmc       646: An example authorized_keys file:
1.222     jmc       647: .Bd -literal -offset 3n
1.315     djm       648: # Comments are allowed at start of line. Blank lines are allowed.
                    649: # Plain key, no restrictions
                    650: ssh-rsa ...
                    651: # Forced command, disable PTY and all forwarding
                    652: restrict,command="dump /home" ssh-rsa ...
                    653: # Restriction of ssh -L forwarding destinations
                    654: permitopen="192.0.2.1:80",permitopen="192.0.2.2:25" ssh-rsa ...
                    655: # Restriction of ssh -R forwarding listeners
                    656: permitlisten="localhost:8080",permitlisten="[::1]:22000" ssh-rsa ...
                    657: # Configuration for tunnel forwarding
                    658: tunnel="0",command="sh /etc/netstart tun0" ssh-rsa ...
                    659: # Override of restriction to allow PTY allocation
                    660: restrict,pty,command="nethack" ssh-rsa ...
                    661: # Allow FIDO key without requiring touch
                    662: no-touch-required sk-ecdsa-sha2-nistp256@openssh.com ...
                    663: # Require user-verification (e.g. PIN or biometric) for FIDO key
                    664: verify-required sk-ecdsa-sha2-nistp256@openssh.com ...
                    665: # Trust CA key, allow touch-less FIDO if requested in certificate
                    666: cert-authority,no-touch-required,principals="user_a" ssh-rsa ...
1.219     jmc       667: .Ed
1.2       deraadt   668: .Sh SSH_KNOWN_HOSTS FILE FORMAT
1.40      aaron     669: The
1.194     jmc       670: .Pa /etc/ssh/ssh_known_hosts
1.40      aaron     671: and
1.207     djm       672: .Pa ~/.ssh/known_hosts
1.36      aaron     673: files contain host public keys for all known hosts.
                    674: The global file should
1.37      brad      675: be prepared by the administrator (optional), and the per-user file is
1.288     dtucker   676: maintained automatically: whenever the user connects to an unknown host,
1.36      aaron     677: its key is added to the per-user file.
1.2       deraadt   678: .Pp
1.314     djm       679: Each line in these files contains the following fields: marker (optional),
1.285     naddy     680: hostnames, keytype, base64-encoded key, comment.
1.36      aaron     681: The fields are separated by spaces.
1.2       deraadt   682: .Pp
1.254     djm       683: The marker is optional, but if it is present then it must be one of
                    684: .Dq @cert-authority ,
                    685: to indicate that the line contains a certification authority (CA) key,
                    686: or
                    687: .Dq @revoked ,
                    688: to indicate that the key contained on the line is revoked and must not ever
                    689: be accepted.
                    690: Only one marker should be used on a key line.
                    691: .Pp
1.196     david     692: Hostnames is a comma-separated list of patterns
1.220     jmc       693: .Pf ( Ql *
1.197     jmc       694: and
                    695: .Ql \&?
1.195     mouring   696: act as
1.290     djm       697: wildcards); each pattern in turn is matched against the host name.
                    698: When
                    699: .Nm sshd
                    700: is authenticating a client, such as when using
                    701: .Cm HostbasedAuthentication ,
                    702: this will be the canonical client host name.
                    703: When
                    704: .Xr ssh 1
1.291     jmc       705: is authenticating a server, this will be the host name
1.290     djm       706: given by the user, the value of the
                    707: .Xr ssh 1
                    708: .Cm HostkeyAlias
                    709: if it was specified, or the canonical server hostname if the
                    710: .Xr ssh 1
                    711: .Cm CanonicalizeHostname
                    712: option was used.
                    713: .Pp
1.36      aaron     714: A pattern may also be preceded by
1.195     mouring   715: .Ql \&!
1.2       deraadt   716: to indicate negation: if the host name matches a negated
1.1       deraadt   717: pattern, it is not accepted (by that line) even if it matched another
                    718: pattern on the line.
1.231     dtucker   719: A hostname or address may optionally be enclosed within
                    720: .Ql \&[
                    721: and
                    722: .Ql \&]
                    723: brackets then followed by
                    724: .Ql \&:
1.232     jmc       725: and a non-standard port number.
1.2       deraadt   726: .Pp
1.205     djm       727: Alternately, hostnames may be stored in a hashed form which hides host names
1.206     jmc       728: and addresses should the file's contents be disclosed.
                    729: Hashed hostnames start with a
                    730: .Ql |
1.205     djm       731: character.
                    732: Only one hashed hostname may appear on a single line and none of the above
                    733: negation or wildcard operators may be applied.
                    734: .Pp
1.285     naddy     735: The keytype and base64-encoded key are taken directly from the host key; they
1.220     jmc       736: can be obtained, for example, from
1.285     naddy     737: .Pa /etc/ssh/ssh_host_rsa_key.pub .
1.1       deraadt   738: The optional comment field continues to the end of the line, and is not used.
1.2       deraadt   739: .Pp
                    740: Lines starting with
                    741: .Ql #
                    742: and empty lines are ignored as comments.
                    743: .Pp
1.1       deraadt   744: When performing host authentication, authentication is accepted if any
1.254     djm       745: matching line has the proper key; either one that matches exactly or,
                    746: if the server has presented a certificate for authentication, the key
                    747: of the certification authority that signed the certificate.
                    748: For a key to be trusted as a certification authority, it must use the
                    749: .Dq @cert-authority
                    750: marker described above.
                    751: .Pp
                    752: The known hosts file also provides a facility to mark keys as revoked,
                    753: for example when it is known that the associated private key has been
                    754: stolen.
                    755: Revoked keys are specified by including the
                    756: .Dq @revoked
                    757: marker at the beginning of the key line, and are never accepted for
                    758: authentication or as certification authorities, but instead will
                    759: produce a warning from
                    760: .Xr ssh 1
                    761: when they are encountered.
                    762: .Pp
                    763: It is permissible (but not
1.1       deraadt   764: recommended) to have several lines or different host keys for the same
1.36      aaron     765: names.
                    766: This will inevitably happen when short forms of host names
                    767: from different domains are put in the file.
                    768: It is possible
1.1       deraadt   769: that the files contain conflicting information; authentication is
                    770: accepted if valid information can be found from either file.
1.2       deraadt   771: .Pp
1.1       deraadt   772: Note that the lines in these files are typically hundreds of characters
                    773: long, and you definitely don't want to type in the host keys by hand.
1.254     djm       774: Rather, generate them by a script,
                    775: .Xr ssh-keyscan 1
1.285     naddy     776: or by taking, for example,
                    777: .Pa /etc/ssh/ssh_host_rsa_key.pub
1.1       deraadt   778: and adding the host names at the front.
1.254     djm       779: .Xr ssh-keygen 1
1.255     jmc       780: also offers some basic automated editing for
1.254     djm       781: .Pa ~/.ssh/known_hosts
                    782: including removing hosts matching a host name and converting all host
                    783: names to their hashed representations.
1.221     jmc       784: .Pp
                    785: An example ssh_known_hosts file:
                    786: .Bd -literal -offset 3n
                    787: # Comments allowed at start of line
                    788: cvs.example.net,192.0.2.10 ssh-rsa AAAA1234.....=
1.205     djm       789: # A hashed hostname
                    790: |1|JfKTdBh7rNbXkVAQCRp4OQoPfmI=|USECr3SWf1JUPsms5AqfD5QfxkM= ssh-rsa
                    791: AAAA1234.....=
1.254     djm       792: # A revoked key
                    793: @revoked * ssh-rsa AAAAB5W...
                    794: # A CA key, accepted for any host in *.mydomain.com or *.mydomain.org
                    795: @cert-authority *.mydomain.org,*.mydomain.com ssh-rsa AAAAB5W...
1.120     markus    796: .Ed
1.2       deraadt   797: .Sh FILES
1.223     jmc       798: .Bl -tag -width Ds -compact
1.258     jmc       799: .It Pa ~/.hushlogin
1.204     jmc       800: This file is used to suppress printing the last login time and
                    801: .Pa /etc/motd ,
                    802: if
                    803: .Cm PrintLastLog
                    804: and
                    805: .Cm PrintMotd ,
                    806: respectively,
                    807: are enabled.
                    808: It does not suppress printing of the banner specified by
                    809: .Cm Banner .
1.223     jmc       810: .Pp
1.258     jmc       811: .It Pa ~/.rhosts
1.225     jmc       812: This file is used for host-based authentication (see
                    813: .Xr ssh 1
                    814: for more information).
                    815: On some machines this file may need to be
                    816: world-readable if the user's home directory is on an NFS partition,
                    817: because
                    818: .Nm
                    819: reads it as root.
                    820: Additionally, this file must be owned by the user,
                    821: and must not have write permissions for anyone else.
                    822: The recommended
                    823: permission for most machines is read/write for the user, and not
1.1       deraadt   824: accessible by others.
1.2       deraadt   825: .Pp
1.258     jmc       826: .It Pa ~/.shosts
1.225     jmc       827: This file is used in exactly the same way as
                    828: .Pa .rhosts ,
                    829: but allows host-based authentication without permitting login with
                    830: rlogin/rsh.
1.238     mcbride   831: .Pp
1.258     jmc       832: .It Pa ~/.ssh/
1.238     mcbride   833: This directory is the default location for all user-specific configuration
                    834: and authentication information.
                    835: There is no general requirement to keep the entire contents of this directory
                    836: secret, but the recommended permissions are read/write/execute for the user,
                    837: and not accessible by others.
1.2       deraadt   838: .Pp
1.258     jmc       839: .It Pa ~/.ssh/authorized_keys
1.277     sobrado   840: Lists the public keys (DSA, ECDSA, Ed25519, RSA)
1.273     naddy     841: that can be used for logging in as this user.
1.223     jmc       842: The format of this file is described above.
1.234     dtucker   843: The content of the file is not highly sensitive, but the recommended
1.225     jmc       844: permissions are read/write for the user, and not accessible by others.
1.234     dtucker   845: .Pp
                    846: If this file, the
                    847: .Pa ~/.ssh
                    848: directory, or the user's home directory are writable
                    849: by other users, then the file could be modified or replaced by unauthorized
                    850: users.
                    851: In this case,
                    852: .Nm
                    853: will not allow it to be used unless the
                    854: .Cm StrictModes
                    855: option has been set to
                    856: .Dq no .
1.2       deraadt   857: .Pp
1.258     jmc       858: .It Pa ~/.ssh/environment
1.36      aaron     859: This file is read into the environment at login (if it exists).
                    860: It can only contain empty lines, comment lines (that start with
1.2       deraadt   861: .Ql # ) ,
1.36      aaron     862: and assignment lines of the form name=value.
                    863: The file should be writable
1.6       aaron     864: only by the user; it need not be readable by anyone else.
1.188     stevesk   865: Environment processing is disabled by default and is
                    866: controlled via the
                    867: .Cm PermitUserEnvironment
                    868: option.
1.223     jmc       869: .Pp
1.258     jmc       870: .It Pa ~/.ssh/known_hosts
1.225     jmc       871: Contains a list of host keys for all hosts the user has logged into
                    872: that are not already in the systemwide list of known host keys.
                    873: The format of this file is described above.
                    874: This file should be writable only by root/the owner and
1.223     jmc       875: can, but need not be, world-readable.
                    876: .Pp
1.258     jmc       877: .It Pa ~/.ssh/rc
1.226     jmc       878: Contains initialization routines to be run before
                    879: the user's home directory becomes accessible.
1.1       deraadt   880: This file should be writable only by the user, and need not be
                    881: readable by anyone else.
1.223     jmc       882: .Pp
1.258     jmc       883: .It Pa /etc/hosts.equiv
1.227     jmc       884: This file is for host-based authentication (see
                    885: .Xr ssh 1 ) .
                    886: It should only be writable by root.
1.223     jmc       887: .Pp
1.258     jmc       888: .It Pa /etc/moduli
1.283     djm       889: Contains Diffie-Hellman groups used for the "Diffie-Hellman Group Exchange"
                    890: key exchange method.
1.223     jmc       891: The file format is described in
                    892: .Xr moduli 5 .
1.283     djm       893: If no usable groups are found in this file then fixed internal groups will
                    894: be used.
1.223     jmc       895: .Pp
1.258     jmc       896: .It Pa /etc/motd
1.223     jmc       897: See
                    898: .Xr motd 5 .
                    899: .Pp
1.258     jmc       900: .It Pa /etc/nologin
1.223     jmc       901: If this file exists,
                    902: .Nm
                    903: refuses to let anyone except root log in.
                    904: The contents of the file
                    905: are displayed to anyone trying to log in, and non-root connections are
                    906: refused.
                    907: The file should be world-readable.
                    908: .Pp
1.258     jmc       909: .It Pa /etc/shosts.equiv
1.227     jmc       910: This file is used in exactly the same way as
                    911: .Pa hosts.equiv ,
                    912: but allows host-based authentication without permitting login with
                    913: rlogin/rsh.
1.225     jmc       914: .Pp
1.259     djm       915: .It Pa /etc/ssh/ssh_host_ecdsa_key
1.273     naddy     916: .It Pa /etc/ssh/ssh_host_ed25519_key
1.258     jmc       917: .It Pa /etc/ssh/ssh_host_rsa_key
1.266     dtucker   918: These files contain the private parts of the host keys.
1.223     jmc       919: These files should only be owned by root, readable only by root, and not
                    920: accessible to others.
                    921: Note that
                    922: .Nm
1.228     jmc       923: does not start if these files are group/world-accessible.
1.223     jmc       924: .Pp
1.259     djm       925: .It Pa /etc/ssh/ssh_host_ecdsa_key.pub
1.273     naddy     926: .It Pa /etc/ssh/ssh_host_ed25519_key.pub
1.258     jmc       927: .It Pa /etc/ssh/ssh_host_rsa_key.pub
1.266     dtucker   928: These files contain the public parts of the host keys.
1.223     jmc       929: These files should be world-readable but writable only by
                    930: root.
                    931: Their contents should match the respective private parts.
                    932: These files are not
                    933: really used for anything; they are provided for the convenience of
                    934: the user so their contents can be copied to known hosts files.
                    935: These files are created using
                    936: .Xr ssh-keygen 1 .
                    937: .Pp
1.258     jmc       938: .It Pa /etc/ssh/ssh_known_hosts
1.235     jmc       939: Systemwide list of known host keys.
                    940: This file should be prepared by the
                    941: system administrator to contain the public host keys of all machines in the
                    942: organization.
                    943: The format of this file is described above.
                    944: This file should be writable only by root/the owner and
                    945: should be world-readable.
                    946: .Pp
1.258     jmc       947: .It Pa /etc/ssh/sshd_config
1.223     jmc       948: Contains configuration data for
                    949: .Nm sshd .
                    950: The file format and configuration options are described in
                    951: .Xr sshd_config 5 .
                    952: .Pp
1.258     jmc       953: .It Pa /etc/ssh/sshrc
1.226     jmc       954: Similar to
                    955: .Pa ~/.ssh/rc ,
                    956: it can be used to specify
1.36      aaron     957: machine-specific login-time initializations globally.
                    958: This file should be writable only by root, and should be world-readable.
1.223     jmc       959: .Pp
1.258     jmc       960: .It Pa /var/empty
1.223     jmc       961: .Xr chroot 2
                    962: directory used by
                    963: .Nm
                    964: during privilege separation in the pre-authentication phase.
                    965: The directory should not contain any files and must be owned by root
                    966: and not group or world-writable.
                    967: .Pp
1.258     jmc       968: .It Pa /var/run/sshd.pid
1.223     jmc       969: Contains the process ID of the
                    970: .Nm
                    971: listening for connections (if there are several daemons running
                    972: concurrently for different ports, this contains the process ID of the one
                    973: started last).
                    974: The content of this file is not sensitive; it can be world-readable.
1.56      aaron     975: .El
1.2       deraadt   976: .Sh SEE ALSO
                    977: .Xr scp 1 ,
1.90      djm       978: .Xr sftp 1 ,
1.2       deraadt   979: .Xr ssh 1 ,
1.5       deraadt   980: .Xr ssh-add 1 ,
1.2       deraadt   981: .Xr ssh-agent 1 ,
1.5       deraadt   982: .Xr ssh-keygen 1 ,
1.235     jmc       983: .Xr ssh-keyscan 1 ,
1.200     jmc       984: .Xr chroot 2 ,
1.136     markus    985: .Xr login.conf 5 ,
                    986: .Xr moduli 5 ,
1.184     stevesk   987: .Xr sshd_config 5 ,
1.200     jmc       988: .Xr inetd 8 ,
1.128     mpech     989: .Xr sftp-server 8
1.198     jmc       990: .Sh AUTHORS
                    991: OpenSSH is a derivative of the original and free
                    992: ssh 1.2.12 release by Tatu Ylonen.
                    993: Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos,
                    994: Theo de Raadt and Dug Song
                    995: removed many bugs, re-added newer features and
                    996: created OpenSSH.
                    997: Markus Friedl contributed the support for SSH
                    998: protocol versions 1.5 and 2.0.
                    999: Niels Provos and Markus Friedl contributed support
                   1000: for privilege separation.