xref: /freebsd/crypto/openssh/sshd.8 (revision 52ec752989b2e6d4e9a59a8ff25d8ff596d85e62)
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.199 2003/08/13 08:46:31 markus Exp $
38.\" $FreeBSD$
39.Dd September 25, 1999
40.Dt SSHD 8
41.Os
42.Sh NAME
43.Nm sshd
44.Nd OpenSSH SSH daemon
45.Sh SYNOPSIS
46.Nm sshd
47.Bk -words
48.Op Fl deiqtD46
49.Op Fl b Ar bits
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(SSH Daemon) is the daemon program for
61.Xr ssh 1 .
62Together these programs replace rlogin and rsh, and
63provide secure encrypted communications between two untrusted hosts
64over an insecure network.
65The programs are intended to be as easy to
66install and use as possible.
67.Pp
68.Nm
69is the daemon that listens for connections from clients.
70It is normally started at boot from
71.Pa /etc/rc.d/sshd .
72It forks a new
73daemon for each incoming connection.
74The forked daemons handle
75key exchange, encryption, authentication, command execution,
76and data exchange.
77This implementation of
78.Nm
79supports both SSH protocol version 1 and 2 simultaneously.
80.Nm
81works as follows:
82.Pp
83.Ss SSH protocol version 1
84.Pp
85Each host has a host-specific RSA key
86(normally 1024 bits) used to identify the host.
87Additionally, when
88the daemon starts, it generates a server RSA key (normally 768 bits).
89This key is normally regenerated every hour if it has been used, and
90is never stored on disk.
91.Pp
92Whenever a client connects, the daemon responds with its public
93host and server keys.
94The client compares the
95RSA host key against its own database to verify that it has not changed.
96The client then generates a 256 bit random number.
97It encrypts this
98random number using both the host key and the server key, and sends
99the encrypted number to the server.
100Both sides then use this
101random number as a session key which is used to encrypt all further
102communications in the session.
103The rest of the session is encrypted
104using a conventional cipher, currently Blowfish or 3DES, with 3DES
105being used by default.
106The client selects the encryption algorithm
107to use from those offered by the server.
108.Pp
109Next, the server and the client enter an authentication dialog.
110The client tries to authenticate itself using
111.Pa .rhosts
112authentication,
113.Pa .rhosts
114authentication combined with RSA host
115authentication, RSA challenge-response authentication, or password
116based authentication.
117.Pp
118Regardless of the authentication type, the account is checked to
119ensure that it is accessible.  An account is not accessible if it is
120locked, listed in
121.Cm DenyUsers
122or its group is listed in
123.Cm DenyGroups
124\&.  The definition of a locked account is system dependant. Some platforms
125have their own account database (eg AIX) and some modify the passwd field (
126.Ql \&*LK\&*
127on Solaris,
128.Ql \&*
129on HP-UX, containing
130.Ql Nologin
131on Tru64 and a leading
132.Ql \&!!
133on Linux).  If there is a requirement to disable password authentication
134for the account while allowing still public-key, then the passwd field
135should be set to something other than these values (eg
136.Ql NP
137or
138.Ql \&*NP\&*
139).
140.Pp
141Rhosts authentication is normally disabled
142because it is fundamentally insecure, but can be enabled in the server
143configuration file if desired.
144System security is not improved unless
145.Nm rshd ,
146.Nm rlogind ,
147and
148.Nm rexecd
149are disabled (thus completely disabling
150.Xr rlogin
151and
152.Xr rsh
153into the machine).
154.Pp
155.Ss SSH protocol version 2
156.Pp
157Version 2 works similarly:
158Each host has a host-specific key (RSA or DSA) used to identify the host.
159However, when the daemon starts, it does not generate a server key.
160Forward security is provided through a Diffie-Hellman key agreement.
161This key agreement results in a shared session key.
162.Pp
163The rest of the session is encrypted using a symmetric cipher, currently
164128 bit AES, Blowfish, 3DES, CAST128, Arcfour, 192 bit AES, or 256 bit AES.
165The client selects the encryption algorithm
166to use from those offered by the server.
167Additionally, session integrity is provided
168through a cryptographic message authentication code
169(hmac-sha1 or hmac-md5).
170.Pp
171Protocol version 2 provides a public key based
172user (PubkeyAuthentication) or
173client host (HostbasedAuthentication) authentication method,
174conventional password authentication and challenge response based methods.
175.Pp
176.Ss Command execution and data forwarding
177.Pp
178If the client successfully authenticates itself, a dialog for
179preparing the session is entered.
180At this time the client may request
181things like allocating a pseudo-tty, forwarding X11 connections,
182forwarding TCP/IP connections, or forwarding the authentication agent
183connection over the secure channel.
184.Pp
185Finally, the client either requests a shell or execution of a command.
186The sides then enter session mode.
187In this mode, either side may send
188data at any time, and such data is forwarded to/from the shell or
189command on the server side, and the user terminal in the client side.
190.Pp
191When the user program terminates and all forwarded X11 and other
192connections have been closed, the server sends command exit status to
193the client, and both sides exit.
194.Pp
195.Nm
196can be configured using command-line options or a configuration
197file.
198Command-line options override values specified in the
199configuration file.
200.Pp
201.Nm
202rereads its configuration file when it receives a hangup signal,
203.Dv SIGHUP ,
204by executing itself with the name it was started as, i.e.,
205.Pa /usr/sbin/sshd .
206.Pp
207The options are as follows:
208.Bl -tag -width Ds
209.It Fl b Ar bits
210Specifies the number of bits in the ephemeral protocol version 1
211server key (default 768).
212.It Fl d
213Debug mode.
214The server sends verbose debug output to the system
215log, and does not put itself in the background.
216The server also will not fork and will only process one connection.
217This option is only intended for debugging for the server.
218Multiple
219.Fl d
220options increase the debugging level.
221Maximum is 3.
222.It Fl e
223When this option is specified,
224.Nm
225will send the output to the standard error instead of the system log.
226.It Fl f Ar configuration_file
227Specifies the name of the configuration file.
228The default is
229.Pa /etc/ssh/sshd_config .
230.Nm
231refuses to start if there is no configuration file.
232.It Fl g Ar login_grace_time
233Gives the grace time for clients to authenticate themselves (default
234120 seconds).
235If the client fails to authenticate the user within
236this many seconds, the server disconnects and exits.
237A value of zero indicates no limit.
238.It Fl h Ar host_key_file
239Specifies a file from which a host key is read.
240This option must be given if
241.Nm
242is not run as root (as the normal
243host key files are normally not readable by anyone but root).
244The default is
245.Pa /etc/ssh/ssh_host_key
246for protocol version 1, and
247.Pa /etc/ssh/ssh_host_dsa_key
248for protocol version 2.
249It is possible to have multiple host key files for
250the different protocol versions and host key algorithms.
251.It Fl i
252Specifies that
253.Nm
254is being run from
255.Xr inetd 8 .
256.Nm
257is normally not run
258from inetd because it needs to generate the server key before it can
259respond to the client, and this may take tens of seconds.
260Clients would have to wait too long if the key was regenerated every time.
261However, with small key sizes (e.g., 512) using
262.Nm
263from inetd may
264be feasible.
265.It Fl k Ar key_gen_time
266Specifies how often the ephemeral protocol version 1 server key is
267regenerated (default 3600 seconds, or one hour).
268The motivation for regenerating the key fairly
269often is that the key is not stored anywhere, and after about an hour,
270it becomes impossible to recover the key for decrypting intercepted
271communications even if the machine is cracked into or physically
272seized.
273A value of zero indicates that the key will never be regenerated.
274.It Fl o Ar option
275Can be used to give options in the format used in the configuration file.
276This is useful for specifying options for which there is no separate
277command-line flag.
278.It Fl p Ar port
279Specifies the port on which the server listens for connections
280(default 22).
281Multiple port options are permitted.
282Ports specified in the configuration file are ignored when a
283command-line port is specified.
284.It Fl q
285Quiet mode.
286Nothing is sent to the system log.
287Normally the beginning,
288authentication, and termination of each connection is logged.
289.It Fl t
290Test mode.
291Only check the validity of the configuration file and sanity of the keys.
292This is useful for updating
293.Nm
294reliably as configuration options may change.
295.It Fl u Ar len
296This option is used to specify the size of the field
297in the
298.Li utmp
299structure that holds the remote host name.
300If the resolved host name is longer than
301.Ar len ,
302the dotted decimal value will be used instead.
303This allows hosts with very long host names that
304overflow this field to still be uniquely identified.
305Specifying
306.Fl u0
307indicates that only dotted decimal addresses
308should be put into the
309.Pa utmp
310file.
311.Fl u0
312may also be used to prevent
313.Nm
314from making DNS requests unless the authentication
315mechanism or configuration requires it.
316Authentication mechanisms that may require DNS include
317.Cm RhostsRSAAuthentication ,
318.Cm HostbasedAuthentication
319and using a
320.Cm from="pattern-list"
321option in a key file.
322Configuration options that require DNS include using a
323USER@HOST pattern in
324.Cm AllowUsers
325or
326.Cm DenyUsers .
327.It Fl D
328When this option is specified
329.Nm
330will not detach and does not become a daemon.
331This allows easy monitoring of
332.Nm sshd .
333.It Fl 4
334Forces
335.Nm
336to use IPv4 addresses only.
337.It Fl 6
338Forces
339.Nm
340to use IPv6 addresses only.
341.El
342.Sh CONFIGURATION FILE
343.Nm
344reads configuration data from
345.Pa /etc/ssh/sshd_config
346(or the file specified with
347.Fl f
348on the command line).
349The file format and configuration options are described in
350.Xr sshd_config 5 .
351.Sh LOGIN PROCESS
352When a user successfully logs in,
353.Nm
354does the following:
355.Bl -enum -offset indent
356.It
357If the login is on a tty, and no command has been specified,
358prints last login time and
359.Pa /etc/motd
360(unless prevented in the configuration file or by
361.Pa $HOME/.hushlogin ;
362see the
363.Sx FILES
364section).
365.It
366If the login is on a tty, records login time.
367.It
368Checks
369.Pa /etc/nologin and
370.Pa /var/run/nologin ;
371if one exists, it prints the contents and quits
372(unless root).
373.It
374Changes to run with normal user privileges.
375.It
376Sets up basic environment.
377.It
378Reads
379.Pa $HOME/.ssh/environment
380if it exists and users are allowed to change their environment.
381See the
382.Cm PermitUserEnvironment
383option in
384.Xr sshd_config 5 .
385.It
386Changes to user's home directory.
387.It
388If
389.Pa $HOME/.ssh/rc
390exists, runs it; else if
391.Pa /etc/ssh/sshrc
392exists, runs
393it; otherwise runs
394.Xr xauth 1 .
395The
396.Dq rc
397files are given the X11
398authentication protocol and cookie (if applicable) in standard input.
399.It
400Runs user's shell or command.
401.El
402.Sh AUTHORIZED_KEYS FILE FORMAT
403.Pa $HOME/.ssh/authorized_keys
404is the default file that lists the public keys that are
405permitted for RSA authentication in protocol version 1
406and for public key authentication (PubkeyAuthentication)
407in protocol version 2.
408.Cm AuthorizedKeysFile
409may be used to specify an alternative file.
410.Pp
411Each line of the file contains one
412key (empty lines and lines starting with a
413.Ql #
414are ignored as
415comments).
416Each RSA public key consists of the following fields, separated by
417spaces: options, bits, exponent, modulus, comment.
418Each protocol version 2 public key consists of:
419options, keytype, base64 encoded key, comment.
420The options field
421is optional; its presence is determined by whether the line starts
422with a number or not (the options field never starts with a number).
423The bits, exponent, modulus and comment fields give the RSA key for
424protocol version 1; the
425comment field is not used for anything (but may be convenient for the
426user to identify the key).
427For protocol version 2 the keytype is
428.Dq ssh-dss
429or
430.Dq ssh-rsa .
431.Pp
432Note that lines in this file are usually several hundred bytes long
433(because of the size of the public key encoding).
434You don't want to type them in; instead, copy the
435.Pa identity.pub ,
436.Pa id_dsa.pub
437or the
438.Pa id_rsa.pub
439file and edit it.
440.Pp
441.Nm
442enforces a minimum RSA key modulus size for protocol 1
443and protocol 2 keys of 768 bits.
444.Pp
445The options (if present) consist of comma-separated option
446specifications.
447No spaces are permitted, except within double quotes.
448The following option specifications are supported (note
449that option keywords are case-insensitive):
450.Bl -tag -width Ds
451.It Cm from="pattern-list"
452Specifies that in addition to public key authentication, the canonical name
453of the remote host must be present in the comma-separated list of
454patterns
455.Pf ( Ql \&*
456and
457.Ql \&?
458serve as wildcards).
459The list may also contain
460patterns negated by prefixing them with
461.Ql \&! ;
462if the canonical host name matches a negated pattern, the key is not accepted.
463The purpose
464of this option is to optionally increase security: public key authentication
465by itself does not trust the network or name servers or anything (but
466the key); however, if somebody somehow steals the key, the key
467permits an intruder to log in from anywhere in the world.
468This additional option makes using a stolen key more difficult (name
469servers and/or routers would have to be compromised in addition to
470just the key).
471.It Cm command="command"
472Specifies that the command is executed whenever this key is used for
473authentication.
474The command supplied by the user (if any) is ignored.
475The command is run on a pty if the client requests a pty;
476otherwise it is run without a tty.
477If an 8-bit clean channel is required,
478one must not request a pty or should specify
479.Cm no-pty .
480A quote may be included in the command by quoting it with a backslash.
481This option might be useful
482to restrict certain public keys to perform just a specific operation.
483An example might be a key that permits remote backups but nothing else.
484Note that the client may specify TCP/IP and/or X11
485forwarding unless they are explicitly prohibited.
486Note that this option applies to shell, command or subsystem execution.
487.It Cm environment="NAME=value"
488Specifies that the string is to be added to the environment when
489logging in using this key.
490Environment variables set this way
491override other default environment values.
492Multiple options of this type are permitted.
493Environment processing is disabled by default and is
494controlled via the
495.Cm PermitUserEnvironment
496option.
497This option is automatically disabled if
498.Cm UseLogin
499is enabled.
500.It Cm no-port-forwarding
501Forbids TCP/IP forwarding when this key is used for authentication.
502Any port forward requests by the client will return an error.
503This might be used, e.g., in connection with the
504.Cm command
505option.
506.It Cm no-X11-forwarding
507Forbids X11 forwarding when this key is used for authentication.
508Any X11 forward requests by the client will return an error.
509.It Cm no-agent-forwarding
510Forbids authentication agent forwarding when this key is used for
511authentication.
512.It Cm no-pty
513Prevents tty allocation (a request to allocate a pty will fail).
514.It Cm permitopen="host:port"
515Limit local
516.Li ``ssh -L''
517port forwarding such that it may only connect to the specified host and
518port.
519IPv6 addresses can be specified with an alternative syntax:
520.Ar host/port .
521Multiple
522.Cm permitopen
523options may be applied separated by commas.
524No pattern matching is performed on the specified hostnames,
525they must be literal domains or addresses.
526.El
527.Ss Examples
5281024 33 12121.\|.\|.\|312314325 ylo@foo.bar
529.Pp
530from="*.niksula.hut.fi,!pc.niksula.hut.fi" 1024 35 23.\|.\|.\|2334 ylo@niksula
531.Pp
532command="dump /home",no-pty,no-port-forwarding 1024 33 23.\|.\|.\|2323 backup.hut.fi
533.Pp
534permitopen="10.2.1.55:80",permitopen="10.2.1.56:25" 1024 33 23.\|.\|.\|2323
535.Sh SSH_KNOWN_HOSTS FILE FORMAT
536The
537.Pa /etc/ssh/ssh_known_hosts
538and
539.Pa $HOME/.ssh/known_hosts
540files contain host public keys for all known hosts.
541The global file should
542be prepared by the administrator (optional), and the per-user file is
543maintained automatically: whenever the user connects from an unknown host
544its key is added to the per-user file.
545.Pp
546Each line in these files contains the following fields: hostnames,
547bits, exponent, modulus, comment.
548The fields are separated by spaces.
549.Pp
550Hostnames is a comma-separated list of patterns
551.Pf ( Ql \&*
552and
553.Ql \&?
554act as
555wildcards); each pattern in turn is matched against the canonical host
556name (when authenticating a client) or against the user-supplied
557name (when authenticating a server).
558A pattern may also be preceded by
559.Ql \&!
560to indicate negation: if the host name matches a negated
561pattern, it is not accepted (by that line) even if it matched another
562pattern on the line.
563.Pp
564Bits, exponent, and modulus are taken directly from the RSA host key; they
565can be obtained, e.g., from
566.Pa /etc/ssh/ssh_host_key.pub .
567The optional comment field continues to the end of the line, and is not used.
568.Pp
569Lines starting with
570.Ql #
571and empty lines are ignored as comments.
572.Pp
573When performing host authentication, authentication is accepted if any
574matching line has the proper key.
575It is thus permissible (but not
576recommended) to have several lines or different host keys for the same
577names.
578This will inevitably happen when short forms of host names
579from different domains are put in the file.
580It is possible
581that the files contain conflicting information; authentication is
582accepted if valid information can be found from either file.
583.Pp
584Note that the lines in these files are typically hundreds of characters
585long, and you definitely don't want to type in the host keys by hand.
586Rather, generate them by a script
587or by taking
588.Pa /etc/ssh/ssh_host_key.pub
589and adding the host names at the front.
590.Ss Examples
591.Bd -literal
592closenet,.\|.\|.\|,130.233.208.41 1024 37 159.\|.\|.93 closenet.hut.fi
593cvs.openbsd.org,199.185.137.3 ssh-rsa AAAA1234.....=
594.Ed
595.Sh FILES
596.Bl -tag -width Ds
597.It Pa /etc/ssh/sshd_config
598Contains configuration data for
599.Nm sshd .
600The file format and configuration options are described in
601.Xr sshd_config 5 .
602.It Pa /etc/ssh/ssh_host_key, /etc/ssh/ssh_host_dsa_key
603These two files contain the private parts of the host keys.
604These files should only be owned by root, readable only by root, and not
605accessible to others.
606Note that
607.Nm
608does not start if this file is group/world-accessible.
609.It Pa /etc/ssh/ssh_host_key.pub, /etc/ssh/ssh_host_dsa_key.pub
610These two files contain the public parts of the host keys.
611These files should be world-readable but writable only by
612root.
613Their contents should match the respective private parts.
614These files are not
615really used for anything; they are provided for the convenience of
616the user so their contents can be copied to known hosts files.
617These files are created using
618.Xr ssh-keygen 1 .
619.It Pa /etc/ssh/moduli
620Contains Diffie-Hellman groups used for the "Diffie-Hellman Group Exchange".
621The file format is described in
622.Xr moduli 5 .
623.It Pa /var/empty
624.Xr chroot 2
625directory used by
626.Nm
627during privilege separation in the pre-authentication phase.
628The directory should not contain any files and must be owned by root
629and not group or world-writable.
630.It Pa /var/run/sshd.pid
631Contains the process ID of the
632.Nm
633listening for connections (if there are several daemons running
634concurrently for different ports, this contains the process ID of the one
635started last).
636The content of this file is not sensitive; it can be world-readable.
637.It Pa $HOME/.ssh/authorized_keys
638Lists the public keys (RSA or DSA) that can be used to log into the user's account.
639This file must be readable by root (which may on some machines imply
640it being world-readable if the user's home directory resides on an NFS
641volume).
642It is recommended that it not be accessible by others.
643The format of this file is described above.
644Users will place the contents of their
645.Pa identity.pub ,
646.Pa id_dsa.pub
647and/or
648.Pa id_rsa.pub
649files into this file, as described in
650.Xr ssh-keygen 1 .
651.It Pa "/etc/ssh/ssh_known_hosts" and "$HOME/.ssh/known_hosts"
652These files are consulted when using rhosts with RSA host
653authentication or protocol version 2 hostbased authentication
654to check the public key of the host.
655The key must be listed in one of these files to be accepted.
656The client uses the same files
657to verify that it is connecting to the correct remote host.
658These files should be writable only by root/the owner.
659.Pa /etc/ssh/ssh_known_hosts
660should be world-readable, and
661.Pa $HOME/.ssh/known_hosts
662can, but need not be, world-readable.
663.It Pa /etc/nologin
664If this file exists,
665.Nm
666refuses to let anyone except root log in.
667The contents of the file
668are displayed to anyone trying to log in, and non-root connections are
669refused.
670The file should be world-readable.
671.It Pa /etc/hosts.allow, /etc/hosts.deny
672Access controls that should be enforced by tcp-wrappers are defined here.
673Further details are described in
674.Xr hosts_access 5 .
675.It Pa $HOME/.rhosts
676This file contains host-username pairs, separated by a space, one per
677line.
678The given user on the corresponding host is permitted to log in
679without a password.
680The same file is used by rlogind and rshd.
681The file must
682be writable only by the user; it is recommended that it not be
683accessible by others.
684.Pp
685If is also possible to use netgroups in the file.
686Either host or user
687name may be of the form +@groupname to specify all hosts or all users
688in the group.
689.It Pa $HOME/.shosts
690For ssh,
691this file is exactly the same as for
692.Pa .rhosts .
693However, this file is
694not used by rlogin and rshd, so using this permits access using SSH only.
695.It Pa /etc/hosts.equiv
696This file is used during
697.Pa .rhosts
698authentication.
699In the simplest form, this file contains host names, one per line.
700Users on
701those hosts are permitted to log in without a password, provided they
702have the same user name on both machines.
703The host name may also be
704followed by a user name; such users are permitted to log in as
705.Em any
706user on this machine (except root).
707Additionally, the syntax
708.Dq +@group
709can be used to specify netgroups.
710Negated entries start with
711.Ql \&- .
712.Pp
713If the client host/user is successfully matched in this file, login is
714automatically permitted provided the client and server user names are the
715same.
716Additionally, successful RSA host authentication is normally required.
717This file must be writable only by root; it is recommended
718that it be world-readable.
719.Pp
720.Sy "Warning: It is almost never a good idea to use user names in"
721.Pa hosts.equiv .
722Beware that it really means that the named user(s) can log in as
723.Em anybody ,
724which includes bin, daemon, adm, and other accounts that own critical
725binaries and directories.
726Using a user name practically grants the user root access.
727The only valid use for user names that I can think
728of is in negative entries.
729.Pp
730Note that this warning also applies to rsh/rlogin.
731.It Pa /etc/ssh/shosts.equiv
732This is processed exactly as
733.Pa /etc/hosts.equiv .
734However, this file may be useful in environments that want to run both
735rsh/rlogin and ssh.
736.It Pa $HOME/.ssh/environment
737This file is read into the environment at login (if it exists).
738It can only contain empty lines, comment lines (that start with
739.Ql # ) ,
740and assignment lines of the form name=value.
741The file should be writable
742only by the user; it need not be readable by anyone else.
743Environment processing is disabled by default and is
744controlled via the
745.Cm PermitUserEnvironment
746option.
747.It Pa $HOME/.ssh/rc
748If this file exists, it is run with
749.Pa /bin/sh
750after reading the
751environment files but before starting the user's shell or command.
752It must not produce any output on stdout; stderr must be used
753instead.
754If X11 forwarding is in use, it will receive the "proto cookie" pair in
755its standard input (and
756.Ev DISPLAY
757in its environment).
758The script must call
759.Xr xauth 1
760because
761.Nm
762will not run xauth automatically to add X11 cookies.
763.Pp
764The primary purpose of this file is to run any initialization routines
765which may be needed before the user's home directory becomes
766accessible; AFS is a particular example of such an environment.
767.Pp
768This file will probably contain some initialization code followed by
769something similar to:
770.Bd -literal
771if read proto cookie && [ -n "$DISPLAY" ]; then
772	if [ `echo $DISPLAY | cut -c1-10` = 'localhost:' ]; then
773		# X11UseLocalhost=yes
774		echo add unix:`echo $DISPLAY |
775		    cut -c11-` $proto $cookie
776	else
777		# X11UseLocalhost=no
778		echo add $DISPLAY $proto $cookie
779	fi | xauth -q -
780fi
781.Ed
782.Pp
783If this file does not exist,
784.Pa /etc/ssh/sshrc
785is run, and if that
786does not exist either, xauth is used to add the cookie.
787.Pp
788This file should be writable only by the user, and need not be
789readable by anyone else.
790.It Pa /etc/ssh/sshrc
791Like
792.Pa $HOME/.ssh/rc .
793This can be used to specify
794machine-specific login-time initializations globally.
795This file should be writable only by root, and should be world-readable.
796.El
797.Sh SEE ALSO
798.Xr scp 1 ,
799.Xr sftp 1 ,
800.Xr ssh 1 ,
801.Xr ssh-add 1 ,
802.Xr ssh-agent 1 ,
803.Xr ssh-keygen 1 ,
804.Xr login.conf 5 ,
805.Xr moduli 5 ,
806.Xr sshd_config 5 ,
807.Xr sftp-server 8
808.Rs
809.%A T. Ylonen
810.%A T. Kivinen
811.%A M. Saarinen
812.%A T. Rinne
813.%A S. Lehtinen
814.%T "SSH Protocol Architecture"
815.%N draft-ietf-secsh-architecture-12.txt
816.%D January 2002
817.%O work in progress material
818.Re
819.Rs
820.%A M. Friedl
821.%A N. Provos
822.%A W. A. Simpson
823.%T "Diffie-Hellman Group Exchange for the SSH Transport Layer Protocol"
824.%N draft-ietf-secsh-dh-group-exchange-02.txt
825.%D January 2002
826.%O work in progress material
827.Re
828.Sh AUTHORS
829OpenSSH is a derivative of the original and free
830ssh 1.2.12 release by Tatu Ylonen.
831Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos,
832Theo de Raadt and Dug Song
833removed many bugs, re-added newer features and
834created OpenSSH.
835Markus Friedl contributed the support for SSH
836protocol versions 1.5 and 2.0.
837Niels Provos and Markus Friedl contributed support
838for privilege separation.
839