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