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