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

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