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