xref: /openbsd-src/usr.bin/ssh/sshd.8 (revision 2b0358df1d88d06ef4139321dd05bd5e05d91eaf)
1.\"  -*- nroff -*-
2.\"
3.\" Author: Tatu Ylonen <ylo@cs.hut.fi>
4.\" Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
5.\"                    All rights reserved
6.\"
7.\" As far as I am concerned, the code I have written for this software
8.\" can be used freely for any purpose.  Any derived versions of this
9.\" software must be clearly marked as such, and if the derived work is
10.\" incompatible with the protocol description in the RFC file, it must be
11.\" called by a name other than "ssh" or "Secure Shell".
12.\"
13.\" Copyright (c) 1999,2000 Markus Friedl.  All rights reserved.
14.\" Copyright (c) 1999 Aaron Campbell.  All rights reserved.
15.\" Copyright (c) 1999 Theo de Raadt.  All rights reserved.
16.\"
17.\" Redistribution and use in source and binary forms, with or without
18.\" modification, are permitted provided that the following conditions
19.\" are met:
20.\" 1. Redistributions of source code must retain the above copyright
21.\"    notice, this list of conditions and the following disclaimer.
22.\" 2. Redistributions in binary form must reproduce the above copyright
23.\"    notice, this list of conditions and the following disclaimer in the
24.\"    documentation and/or other materials provided with the distribution.
25.\"
26.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
27.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
28.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
29.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
30.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
31.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
35.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36.\"
37.\" $OpenBSD: sshd.8,v 1.248 2009/03/26 08:38:39 sobrado Exp $
38.Dd $Mdocdate: March 26 2009 $
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 f Ar config_file
51.Op Fl g Ar login_grace_time
52.Op Fl h Ar host_key_file
53.Op Fl k Ar key_gen_time
54.Op Fl o Ar option
55.Op Fl p Ar port
56.Op Fl u Ar len
57.Ek
58.Sh DESCRIPTION
59.Nm
60(OpenSSH Daemon) is the daemon program for
61.Xr ssh 1 .
62Together these programs replace
63.Xr rlogin 1
64and
65.Xr rsh 1 ,
66and provide secure encrypted communications between two untrusted hosts
67over an insecure network.
68.Pp
69.Nm
70listens for connections from clients.
71It is normally started at boot from
72.Pa /etc/rc .
73It forks a new
74daemon for each incoming connection.
75The forked daemons handle
76key exchange, encryption, authentication, command execution,
77and data exchange.
78.Pp
79.Nm
80can be configured using command-line options or a configuration file
81(by default
82.Xr sshd_config 5 ) ;
83command-line options override values specified in the
84configuration file.
85.Nm
86rereads its configuration file when it receives a hangup signal,
87.Dv SIGHUP ,
88by executing itself with the name and options it was started with, e.g.\&
89.Pa /usr/sbin/sshd .
90.Pp
91The options are as follows:
92.Bl -tag -width Ds
93.It Fl 4
94Forces
95.Nm
96to use IPv4 addresses only.
97.It Fl 6
98Forces
99.Nm
100to use IPv6 addresses only.
101.It Fl b Ar bits
102Specifies the number of bits in the ephemeral protocol version 1
103server key (default 1024).
104.It Fl C Ar connection_spec
105Specify the connection parameters to use for the
106.Fl T
107extended test mode.
108If provided, any
109.Cm Match
110directives in the configuration file
111that would apply to the specified user, host, and address will be set before
112the configuration is written to standard output.
113The connection parameters are supplied as keyword=value pairs.
114The keywords are
115.Dq user ,
116.Dq host ,
117and
118.Dq addr .
119All are required and may be supplied in any order, either with multiple
120.Fl C
121options or as a comma-separated list.
122.It Fl D
123When this option is specified,
124.Nm
125will not detach and does not become a daemon.
126This allows easy monitoring of
127.Nm sshd .
128.It Fl d
129Debug mode.
130The server sends verbose debug output to the system
131log, and does not put itself in the background.
132The server also will not fork and will only process one connection.
133This option is only intended for debugging for the server.
134Multiple
135.Fl d
136options increase the debugging level.
137Maximum is 3.
138.It Fl e
139When this option is specified,
140.Nm
141will send the output to the standard error instead of the system log.
142.It Fl f Ar config_file
143Specifies the name of the configuration file.
144The default is
145.Pa /etc/ssh/sshd_config .
146.Nm
147refuses to start if there is no configuration file.
148.It Fl g Ar login_grace_time
149Gives the grace time for clients to authenticate themselves (default
150120 seconds).
151If the client fails to authenticate the user within
152this many seconds, the server disconnects and exits.
153A value of zero indicates no limit.
154.It Fl h Ar host_key_file
155Specifies a file from which a host key is read.
156This option must be given if
157.Nm
158is not run as root (as the normal
159host key files are normally not readable by anyone but root).
160The default is
161.Pa /etc/ssh/ssh_host_key
162for protocol version 1, and
163.Pa /etc/ssh/ssh_host_rsa_key
164and
165.Pa /etc/ssh/ssh_host_dsa_key
166for protocol version 2.
167It is possible to have multiple host key files for
168the different protocol versions and host key algorithms.
169.It Fl i
170Specifies that
171.Nm
172is being run from
173.Xr inetd 8 .
174.Nm
175is normally not run
176from inetd because it needs to generate the server key before it can
177respond to the client, and this may take tens of seconds.
178Clients would have to wait too long if the key was regenerated every time.
179However, with small key sizes (e.g. 512) using
180.Nm
181from inetd may
182be feasible.
183.It Fl k Ar key_gen_time
184Specifies how often the ephemeral protocol version 1 server key is
185regenerated (default 3600 seconds, or one hour).
186The motivation for regenerating the key fairly
187often is that the key is not stored anywhere, and after about an hour
188it becomes impossible to recover the key for decrypting intercepted
189communications even if the machine is cracked into or physically
190seized.
191A value of zero indicates that the key will never be regenerated.
192.It Fl o Ar option
193Can be used to give options in the format used in the configuration file.
194This is useful for specifying options for which there is no separate
195command-line flag.
196For full details of the options, and their values, see
197.Xr sshd_config 5 .
198.It Fl p Ar port
199Specifies the port on which the server listens for connections
200(default 22).
201Multiple port options are permitted.
202Ports specified in the configuration file with the
203.Cm Port
204option are ignored when a command-line port is specified.
205Ports specified using the
206.Cm ListenAddress
207option override command-line ports.
208.It Fl q
209Quiet mode.
210Nothing is sent to the system log.
211Normally the beginning,
212authentication, and termination of each connection is logged.
213.It Fl T
214Extended test mode.
215Check the validity of the configuration file, output the effective configuration
216to stdout and then exit.
217Optionally,
218.Cm Match
219rules may be applied by specifying the connection parameters using one or more
220.Fl C
221options.
222.It Fl t
223Test mode.
224Only check the validity of the configuration file and sanity of the keys.
225This is useful for updating
226.Nm
227reliably as configuration options may change.
228.It Fl u Ar len
229This option is used to specify the size of the field
230in the
231.Li utmp
232structure that holds the remote host name.
233If the resolved host name is longer than
234.Ar len ,
235the dotted decimal value will be used instead.
236This allows hosts with very long host names that
237overflow this field to still be uniquely identified.
238Specifying
239.Fl u0
240indicates that only dotted decimal addresses
241should be put into the
242.Pa utmp
243file.
244.Fl u0
245may also be used to prevent
246.Nm
247from making DNS requests unless the authentication
248mechanism or configuration requires it.
249Authentication mechanisms that may require DNS include
250.Cm RhostsRSAAuthentication ,
251.Cm HostbasedAuthentication ,
252and using a
253.Cm from="pattern-list"
254option in a key file.
255Configuration options that require DNS include using a
256USER@HOST pattern in
257.Cm AllowUsers
258or
259.Cm DenyUsers .
260.El
261.Sh AUTHENTICATION
262The OpenSSH SSH daemon supports SSH protocols 1 and 2.
263Both protocols are supported by default,
264though this can be changed via the
265.Cm Protocol
266option in
267.Xr sshd_config 5 .
268Protocol 2 supports both RSA and DSA keys;
269protocol 1 only supports RSA keys.
270For both protocols,
271each host has a host-specific key,
272normally 2048 bits,
273used to identify the host.
274.Pp
275Forward security for protocol 1 is provided through
276an additional server key,
277normally 768 bits,
278generated when the server starts.
279This key is normally regenerated every hour if it has been used, and
280is never stored on disk.
281Whenever a client connects, the daemon responds with its public
282host and server keys.
283The client compares the
284RSA host key against its own database to verify that it has not changed.
285The client then generates a 256-bit random number.
286It encrypts this
287random number using both the host key and the server key, and sends
288the encrypted number to the server.
289Both sides then use this
290random number as a session key which is used to encrypt all further
291communications in the session.
292The rest of the session is encrypted
293using a conventional cipher, currently Blowfish or 3DES, with 3DES
294being used by default.
295The client selects the encryption algorithm
296to use from those offered by the server.
297.Pp
298For protocol 2,
299forward security is provided through a Diffie-Hellman key agreement.
300This key agreement results in a shared session key.
301The rest of the session is encrypted using a symmetric cipher, currently
302128-bit AES, Blowfish, 3DES, CAST128, Arcfour, 192-bit AES, or 256-bit AES.
303The client selects the encryption algorithm
304to use from those offered by the server.
305Additionally, session integrity is provided
306through a cryptographic message authentication code
307(hmac-md5, hmac-sha1, umac-64 or hmac-ripemd160).
308.Pp
309Finally, the server and the client enter an authentication dialog.
310The client tries to authenticate itself using
311host-based authentication,
312public key authentication,
313challenge-response authentication,
314or password authentication.
315.Pp
316If the client successfully authenticates itself, a dialog for
317preparing the session is entered.
318At this time the client may request
319things like allocating a pseudo-tty, forwarding X11 connections,
320forwarding TCP connections, or forwarding the authentication agent
321connection over the secure channel.
322.Pp
323After this, the client either requests a shell or execution of a command.
324The sides then enter session mode.
325In this mode, either side may send
326data at any time, and such data is forwarded to/from the shell or
327command on the server side, and the user terminal in the client side.
328.Pp
329When the user program terminates and all forwarded X11 and other
330connections have been closed, the server sends command exit status to
331the client, and both sides exit.
332.Sh LOGIN PROCESS
333When a user successfully logs in,
334.Nm
335does the following:
336.Bl -enum -offset indent
337.It
338If the login is on a tty, and no command has been specified,
339prints last login time and
340.Pa /etc/motd
341(unless prevented in the configuration file or by
342.Pa ~/.hushlogin ;
343see the
344.Sx FILES
345section).
346.It
347If the login is on a tty, records login time.
348.It
349Checks
350.Pa /etc/nologin ;
351if it exists, prints contents and quits
352(unless root).
353.It
354Changes to run with normal user privileges.
355.It
356Sets up basic environment.
357.It
358Reads the file
359.Pa ~/.ssh/environment ,
360if it exists, and users are allowed to change their environment.
361See the
362.Cm PermitUserEnvironment
363option in
364.Xr sshd_config 5 .
365.It
366Changes to user's home directory.
367.It
368If
369.Pa ~/.ssh/rc
370exists, runs it; else if
371.Pa /etc/ssh/sshrc
372exists, runs
373it; otherwise runs xauth.
374The
375.Dq rc
376files are given the X11
377authentication protocol and cookie in standard input.
378See
379.Sx SSHRC ,
380below.
381.It
382Runs user's shell or command.
383.El
384.Sh SSHRC
385If the file
386.Pa ~/.ssh/rc
387exists,
388.Xr sh 1
389runs it after reading the
390environment files but before starting the user's shell or command.
391It must not produce any output on stdout; stderr must be used
392instead.
393If X11 forwarding is in use, it will receive the "proto cookie" pair in
394its standard input (and
395.Ev DISPLAY
396in its environment).
397The script must call
398.Xr xauth 1
399because
400.Nm
401will not run xauth automatically to add X11 cookies.
402.Pp
403The primary purpose of this file is to run any initialization routines
404which may be needed before the user's home directory becomes
405accessible; AFS is a particular example of such an environment.
406.Pp
407This file will probably contain some initialization code followed by
408something similar to:
409.Bd -literal -offset 3n
410if read proto cookie && [ -n "$DISPLAY" ]; then
411	if [ `echo $DISPLAY | cut -c1-10` = 'localhost:' ]; then
412		# X11UseLocalhost=yes
413		echo add unix:`echo $DISPLAY |
414		    cut -c11-` $proto $cookie
415	else
416		# X11UseLocalhost=no
417		echo add $DISPLAY $proto $cookie
418	fi | xauth -q -
419fi
420.Ed
421.Pp
422If this file does not exist,
423.Pa /etc/ssh/sshrc
424is run, and if that
425does not exist either, xauth is used to add the cookie.
426.Sh AUTHORIZED_KEYS FILE FORMAT
427.Cm AuthorizedKeysFile
428specifies the file containing public keys for
429public key authentication;
430if none is specified, the default is
431.Pa ~/.ssh/authorized_keys .
432Each line of the file contains one
433key (empty lines and lines starting with a
434.Ql #
435are ignored as
436comments).
437Protocol 1 public keys consist of the following space-separated fields:
438options, bits, exponent, modulus, comment.
439Protocol 2 public key consist of:
440options, keytype, base64-encoded key, comment.
441The options field is optional;
442its presence is determined by whether the line starts
443with a number or not (the options field never starts with a number).
444The bits, exponent, modulus, and comment fields give the RSA key for
445protocol version 1; the
446comment field is not used for anything (but may be convenient for the
447user to identify the key).
448For protocol version 2 the keytype is
449.Dq ssh-dss
450or
451.Dq ssh-rsa .
452.Pp
453Note that lines in this file are usually several hundred bytes long
454(because of the size of the public key encoding) up to a limit of
4558 kilobytes, which permits DSA keys up to 8 kilobits and RSA
456keys up to 16 kilobits.
457You don't want to type them in; instead, copy the
458.Pa identity.pub ,
459.Pa id_dsa.pub ,
460or the
461.Pa id_rsa.pub
462file and edit it.
463.Pp
464.Nm
465enforces a minimum RSA key modulus size for protocol 1
466and protocol 2 keys of 768 bits.
467.Pp
468The options (if present) consist of comma-separated option
469specifications.
470No spaces are permitted, except within double quotes.
471The following option specifications are supported (note
472that option keywords are case-insensitive):
473.Bl -tag -width Ds
474.It Cm command="command"
475Specifies that the command is executed whenever this key is used for
476authentication.
477The command supplied by the user (if any) is ignored.
478The command is run on a pty if the client requests a pty;
479otherwise it is run without a tty.
480If an 8-bit clean channel is required,
481one must not request a pty or should specify
482.Cm no-pty .
483A quote may be included in the command by quoting it with a backslash.
484This option might be useful
485to restrict certain public keys to perform just a specific operation.
486An example might be a key that permits remote backups but nothing else.
487Note that the client may specify TCP and/or X11
488forwarding unless they are explicitly prohibited.
489The command originally supplied by the client is available in the
490.Ev SSH_ORIGINAL_COMMAND
491environment variable.
492Note that this option applies to shell, command or subsystem execution.
493.It Cm environment="NAME=value"
494Specifies that the string is to be added to the environment when
495logging in using this key.
496Environment variables set this way
497override other default environment values.
498Multiple options of this type are permitted.
499Environment processing is disabled by default and is
500controlled via the
501.Cm PermitUserEnvironment
502option.
503This option is automatically disabled if
504.Cm UseLogin
505is enabled.
506.It Cm from="pattern-list"
507Specifies that in addition to public key authentication, either the canonical
508name of the remote host or its IP address must be present in the
509comma-separated list of patterns.
510See
511.Sx PATTERNS
512in
513.Xr ssh_config 5
514for more information on patterns.
515.Pp
516In addition to the wildcard matching that may be applied to hostnames or
517addresses, a
518.Cm from
519stanza may match IP addresses using CIDR address/masklen notation.
520.Pp
521The purpose of this option is to optionally increase security: public key
522authentication by itself does not trust the network or name servers or
523anything (but the key); however, if somebody somehow steals the key, the key
524permits an intruder to log in from anywhere in the world.
525This additional option makes using a stolen key more difficult (name
526servers and/or routers would have to be compromised in addition to
527just the key).
528.It Cm no-agent-forwarding
529Forbids authentication agent forwarding when this key is used for
530authentication.
531.It Cm no-port-forwarding
532Forbids TCP forwarding when this key is used for authentication.
533Any port forward requests by the client will return an error.
534This might be used, e.g. in connection with the
535.Cm command
536option.
537.It Cm no-pty
538Prevents tty allocation (a request to allocate a pty will fail).
539.It Cm no-user-rc
540Disables execution of
541.Pa ~/.ssh/rc .
542.It Cm no-X11-forwarding
543Forbids X11 forwarding when this key is used for authentication.
544Any X11 forward requests by the client will return an error.
545.It Cm permitopen="host:port"
546Limit local
547.Li ``ssh -L''
548port forwarding such that it may only connect to the specified host and
549port.
550IPv6 addresses can be specified with an alternative syntax:
551.Ar host Ns / Ns Ar port .
552Multiple
553.Cm permitopen
554options may be applied separated by commas.
555No pattern matching is performed on the specified hostnames,
556they must be literal domains or addresses.
557.It Cm tunnel="n"
558Force a
559.Xr tun 4
560device on the server.
561Without this option, the next available device will be used if
562the client requests a tunnel.
563.El
564.Pp
565An example authorized_keys file:
566.Bd -literal -offset 3n
567# Comments allowed at start of line
568ssh-rsa AAAAB3Nza...LiPk== user@example.net
569from="*.sales.example.net,!pc.sales.example.net" ssh-rsa
570AAAAB2...19Q== john@example.net
571command="dump /home",no-pty,no-port-forwarding ssh-dss
572AAAAC3...51R== example.net
573permitopen="192.0.2.1:80",permitopen="192.0.2.2:25" ssh-dss
574AAAAB5...21S==
575tunnel="0",command="sh /etc/netstart tun0" ssh-rsa AAAA...==
576jane@example.net
577.Ed
578.Sh SSH_KNOWN_HOSTS FILE FORMAT
579The
580.Pa /etc/ssh/ssh_known_hosts
581and
582.Pa ~/.ssh/known_hosts
583files contain host public keys for all known hosts.
584The global file should
585be prepared by the administrator (optional), and the per-user file is
586maintained automatically: whenever the user connects from an unknown host,
587its key is added to the per-user file.
588.Pp
589Each line in these files contains the following fields: hostnames,
590bits, exponent, modulus, comment.
591The fields are separated by spaces.
592.Pp
593Hostnames is a comma-separated list of patterns
594.Pf ( Ql *
595and
596.Ql \&?
597act as
598wildcards); each pattern in turn is matched against the canonical host
599name (when authenticating a client) or against the user-supplied
600name (when authenticating a server).
601A pattern may also be preceded by
602.Ql \&!
603to indicate negation: if the host name matches a negated
604pattern, it is not accepted (by that line) even if it matched another
605pattern on the line.
606A hostname or address may optionally be enclosed within
607.Ql \&[
608and
609.Ql \&]
610brackets then followed by
611.Ql \&:
612and a non-standard port number.
613.Pp
614Alternately, hostnames may be stored in a hashed form which hides host names
615and addresses should the file's contents be disclosed.
616Hashed hostnames start with a
617.Ql |
618character.
619Only one hashed hostname may appear on a single line and none of the above
620negation or wildcard operators may be applied.
621.Pp
622Bits, exponent, and modulus are taken directly from the RSA host key; they
623can be obtained, for example, from
624.Pa /etc/ssh/ssh_host_key.pub .
625The optional comment field continues to the end of the line, and is not used.
626.Pp
627Lines starting with
628.Ql #
629and empty lines are ignored as comments.
630.Pp
631When performing host authentication, authentication is accepted if any
632matching line has the proper key.
633It is thus permissible (but not
634recommended) to have several lines or different host keys for the same
635names.
636This will inevitably happen when short forms of host names
637from different domains are put in the file.
638It is possible
639that the files contain conflicting information; authentication is
640accepted if valid information can be found from either file.
641.Pp
642Note that the lines in these files are typically hundreds of characters
643long, and you definitely don't want to type in the host keys by hand.
644Rather, generate them by a script
645or by taking
646.Pa /etc/ssh/ssh_host_key.pub
647and adding the host names at the front.
648.Pp
649An example ssh_known_hosts file:
650.Bd -literal -offset 3n
651# Comments allowed at start of line
652closenet,...,192.0.2.53 1024 37 159...93 closenet.example.net
653cvs.example.net,192.0.2.10 ssh-rsa AAAA1234.....=
654# A hashed hostname
655|1|JfKTdBh7rNbXkVAQCRp4OQoPfmI=|USECr3SWf1JUPsms5AqfD5QfxkM= ssh-rsa
656AAAA1234.....=
657.Ed
658.Sh FILES
659.Bl -tag -width Ds -compact
660.It ~/.hushlogin
661This file is used to suppress printing the last login time and
662.Pa /etc/motd ,
663if
664.Cm PrintLastLog
665and
666.Cm PrintMotd ,
667respectively,
668are enabled.
669It does not suppress printing of the banner specified by
670.Cm Banner .
671.Pp
672.It ~/.rhosts
673This file is used for host-based authentication (see
674.Xr ssh 1
675for more information).
676On some machines this file may need to be
677world-readable if the user's home directory is on an NFS partition,
678because
679.Nm
680reads it as root.
681Additionally, this file must be owned by the user,
682and must not have write permissions for anyone else.
683The recommended
684permission for most machines is read/write for the user, and not
685accessible by others.
686.Pp
687.It ~/.shosts
688This file is used in exactly the same way as
689.Pa .rhosts ,
690but allows host-based authentication without permitting login with
691rlogin/rsh.
692.Pp
693.It ~/.ssh/
694This directory is the default location for all user-specific configuration
695and authentication information.
696There is no general requirement to keep the entire contents of this directory
697secret, but the recommended permissions are read/write/execute for the user,
698and not accessible by others.
699.Pp
700.It ~/.ssh/authorized_keys
701Lists the public keys (RSA/DSA) that can be used for logging in as this user.
702The format of this file is described above.
703The content of the file is not highly sensitive, but the recommended
704permissions are read/write for the user, and not accessible by others.
705.Pp
706If this file, the
707.Pa ~/.ssh
708directory, or the user's home directory are writable
709by other users, then the file could be modified or replaced by unauthorized
710users.
711In this case,
712.Nm
713will not allow it to be used unless the
714.Cm StrictModes
715option has been set to
716.Dq no .
717.Pp
718.It ~/.ssh/environment
719This file is read into the environment at login (if it exists).
720It can only contain empty lines, comment lines (that start with
721.Ql # ) ,
722and assignment lines of the form name=value.
723The file should be writable
724only by the user; it need not be readable by anyone else.
725Environment processing is disabled by default and is
726controlled via the
727.Cm PermitUserEnvironment
728option.
729.Pp
730.It ~/.ssh/known_hosts
731Contains a list of host keys for all hosts the user has logged into
732that are not already in the systemwide list of known host keys.
733The format of this file is described above.
734This file should be writable only by root/the owner and
735can, but need not be, world-readable.
736.Pp
737.It ~/.ssh/rc
738Contains initialization routines to be run before
739the user's home directory becomes accessible.
740This file should be writable only by the user, and need not be
741readable by anyone else.
742.Pp
743.It /etc/hosts.allow
744.It /etc/hosts.deny
745Access controls that should be enforced by tcp-wrappers are defined here.
746Further details are described in
747.Xr hosts_access 5 .
748.Pp
749.It /etc/hosts.equiv
750This file is for host-based authentication (see
751.Xr ssh 1 ) .
752It should only be writable by root.
753.Pp
754.It /etc/moduli
755Contains Diffie-Hellman groups used for the "Diffie-Hellman Group Exchange".
756The file format is described in
757.Xr moduli 5 .
758.Pp
759.It /etc/motd
760See
761.Xr motd 5 .
762.Pp
763.It /etc/nologin
764If this file exists,
765.Nm
766refuses to let anyone except root log in.
767The contents of the file
768are displayed to anyone trying to log in, and non-root connections are
769refused.
770The file should be world-readable.
771.Pp
772.It /etc/shosts.equiv
773This file is used in exactly the same way as
774.Pa hosts.equiv ,
775but allows host-based authentication without permitting login with
776rlogin/rsh.
777.Pp
778.It /etc/ssh/ssh_host_key
779.It /etc/ssh/ssh_host_dsa_key
780.It /etc/ssh/ssh_host_rsa_key
781These three files contain the private parts of the host keys.
782These files should only be owned by root, readable only by root, and not
783accessible to others.
784Note that
785.Nm
786does not start if these files are group/world-accessible.
787.Pp
788.It /etc/ssh/ssh_host_key.pub
789.It /etc/ssh/ssh_host_dsa_key.pub
790.It /etc/ssh/ssh_host_rsa_key.pub
791These three files contain the public parts of the host keys.
792These files should be world-readable but writable only by
793root.
794Their contents should match the respective private parts.
795These files are not
796really used for anything; they are provided for the convenience of
797the user so their contents can be copied to known hosts files.
798These files are created using
799.Xr ssh-keygen 1 .
800.Pp
801.It /etc/ssh/ssh_known_hosts
802Systemwide list of known host keys.
803This file should be prepared by the
804system administrator to contain the public host keys of all machines in the
805organization.
806The format of this file is described above.
807This file should be writable only by root/the owner and
808should be world-readable.
809.Pp
810.It /etc/ssh/sshd_config
811Contains configuration data for
812.Nm sshd .
813The file format and configuration options are described in
814.Xr sshd_config 5 .
815.Pp
816.It /etc/ssh/sshrc
817Similar to
818.Pa ~/.ssh/rc ,
819it can be used to specify
820machine-specific login-time initializations globally.
821This file should be writable only by root, and should be world-readable.
822.Pp
823.It /var/empty
824.Xr chroot 2
825directory used by
826.Nm
827during privilege separation in the pre-authentication phase.
828The directory should not contain any files and must be owned by root
829and not group or world-writable.
830.Pp
831.It /var/run/sshd.pid
832Contains the process ID of the
833.Nm
834listening for connections (if there are several daemons running
835concurrently for different ports, this contains the process ID of the one
836started last).
837The content of this file is not sensitive; it can be world-readable.
838.El
839.Sh SEE ALSO
840.Xr scp 1 ,
841.Xr sftp 1 ,
842.Xr ssh 1 ,
843.Xr ssh-add 1 ,
844.Xr ssh-agent 1 ,
845.Xr ssh-keygen 1 ,
846.Xr ssh-keyscan 1 ,
847.Xr chroot 2 ,
848.Xr hosts_access 5 ,
849.Xr login.conf 5 ,
850.Xr moduli 5 ,
851.Xr sshd_config 5 ,
852.Xr inetd 8 ,
853.Xr sftp-server 8
854.Sh AUTHORS
855OpenSSH is a derivative of the original and free
856ssh 1.2.12 release by Tatu Ylonen.
857Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos,
858Theo de Raadt and Dug Song
859removed many bugs, re-added newer features and
860created OpenSSH.
861Markus Friedl contributed the support for SSH
862protocol versions 1.5 and 2.0.
863Niels Provos and Markus Friedl contributed support
864for privilege separation.
865.Sh CAVEATS
866System security is not improved unless
867.Nm rshd ,
868.Nm rlogind ,
869and
870.Nm rexecd
871are disabled (thus completely disabling
872.Xr rlogin
873and
874.Xr rsh
875into the machine).
876