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