xref: /freebsd/crypto/openssh/sshd.8 (revision b601c69bdbe8755d26570261d7fd4c02ee4eff74)
1.\"  -*- nroff -*-
2.\"
3.\" sshd.8.in
4.\"
5.\" Author: Tatu Ylonen <ylo@cs.hut.fi>
6.\"
7.\" Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
8.\"                    All rights reserved
9.\"
10.\" Created: Sat Apr 22 21:55:14 1995 ylo
11.\"
12.\" $Id: sshd.8,v 1.51 2000/05/08 17:42:31 hugh Exp $
13.\" $FreeBSD$
14.\"
15.Dd September 25, 1999
16.Dt SSHD 8
17.Os
18.Sh NAME
19.Nm sshd
20.Nd secure shell daemon
21.Sh SYNOPSIS
22.Nm sshd
23.Op Fl diqQ46
24.Op Fl b Ar bits
25.Op Fl f Ar config_file
26.Op Fl g Ar login_grace_time
27.Op Fl h Ar host_key_file
28.Op Fl k Ar key_gen_time
29.Op Fl p Ar port
30.Op Fl V Ar client_protocol_id
31.Sh DESCRIPTION
32.Nm
33(Secure Shell Daemon) is the daemon program for
34.Xr ssh 1 .
35Together these programs replace rlogin and rsh, and
36provide secure encrypted communications between two untrusted hosts
37over an insecure network.
38The programs are intended to be as easy to
39install and use as possible.
40.Pp
41.Nm
42is the daemon that listens for connections from clients.
43It is normally started at boot from
44.Pa /etc/rc.network .
45It forks a new
46daemon for each incoming connection.
47The forked daemons handle
48key exchange, encryption, authentication, command execution,
49and data exchange.
50This implementation of
51.Nm
52supports both SSH protocol version 1 and 2 simultaneously.
53.Nm
54works as follows.
55.Pp
56.Ss SSH protocol version 1
57.Pp
58Each host has a host-specific RSA key
59(normally 1024 bits) used to identify the host.
60Additionally, when
61the daemon starts, it generates a server RSA key (normally 768 bits).
62This key is normally regenerated every hour if it has been used, and
63is never stored on disk.
64.Pp
65Whenever a client connects the daemon responds with its public
66host and server keys.
67The client compares the
68RSA host key against its own database to verify that it has not changed.
69The client then generates a 256 bit random number.
70It encrypts this
71random number using both the host key and the server key, and sends
72the encrypted number to the server.
73Both sides then use this
74random number as a session key which is used to encrypt all further
75communications in the session.
76The rest of the session is encrypted
77using a conventional cipher, currently Blowfish or 3DES, with 3DES
78being used by default.
79The client selects the encryption algorithm
80to use from those offered by the server.
81.Pp
82Next, the server and the client enter an authentication dialog.
83The client tries to authenticate itself using
84.Pa .rhosts
85authentication,
86.Pa .rhosts
87authentication combined with RSA host
88authentication, RSA challenge-response authentication, or password
89based authentication.
90.Pp
91Rhosts authentication is normally disabled
92because it is fundamentally insecure, but can be enabled in the server
93configuration file if desired.
94System security is not improved unless
95.Xr rshd 8 ,
96.Xr rlogind 8 ,
97.Xr rexecd 8 ,
98and
99.Xr rexd 8
100are disabled (thus completely disabling
101.Xr rlogin 1
102and
103.Xr rsh 1
104into the machine).
105.Pp
106.Ss SSH protocol version 2
107.Pp
108Version 2 works similar:
109Each host has a host-specific DSA key used to identify the host.
110However, when the daemon starts, it does not generate a server key.
111Forward security is provided through a Diffie-Hellman key agreement.
112This key agreement results in a shared session key.
113The rest of the session is encrypted
114using a symmetric cipher, currently
115Blowfish, 3DES or CAST128 in CBC mode or Arcfour.
116The client selects the encryption algorithm
117to use from those offered by the server.
118Additionally, session integrity is provided
119through a cryptographic message authentication code
120(hmac-sha1 or hmac-md5).
121.Pp
122Protocol version 2 provides a public key based
123user authentication method (DSAAuthentication)
124and conventional password authentication.
125.Pp
126.Ss Command execution and data forwarding
127.Pp
128If the client successfully authenticates itself, a dialog for
129preparing the session is entered.
130At this time the client may request
131things like allocating a pseudo-tty, forwarding X11 connections,
132forwarding TCP/IP connections, or forwarding the authentication agent
133connection over the secure channel.
134.Pp
135Finally, the client either requests a shell or execution of a command.
136The sides then enter session mode.
137In this mode, either side may send
138data at any time, and such data is forwarded to/from the shell or
139command on the server side, and the user terminal in the client side.
140.Pp
141When the user program terminates and all forwarded X11 and other
142connections have been closed, the server sends command exit status to
143the client, and both sides exit.
144.Pp
145.Nm
146can be configured using command-line options or a configuration
147file.
148Command-line options override values specified in the
149configuration file.
150.Pp
151.Nm
152rereads its configuration file when it receives a hangup signal,
153.Dv SIGHUP .
154.Pp
155The options are as follows:
156.Bl -tag -width Ds
157.It Fl b Ar bits
158Specifies the number of bits in the server key (default 768).
159.Pp
160.It Fl d
161Debug mode.
162The server sends verbose debug output to the system
163log, and does not put itself in the background.
164The server also will not fork and will only process one connection.
165This option is only intended for debugging for the server.
166.It Fl f Ar configuration_file
167Specifies the name of the configuration file.
168The default is
169.Pa /etc/ssh/sshd_config .
170.Nm
171refuses to start if there is no configuration file.
172.It Fl g Ar login_grace_time
173Gives the grace time for clients to authenticate themselves (default
174300 seconds).
175If the client fails to authenticate the user within
176this many seconds, the server disconnects and exits.
177A value of zero indicates no limit.
178.It Fl h Ar host_key_file
179Specifies the file from which the RSA host key is read (default
180.Pa /etc/ssh/ssh_host_key ) .
181This option must be given if
182.Nm
183is not run as root (as the normal
184host file is normally not readable by anyone but root).
185.It Fl i
186Specifies that
187.Nm
188is being run from inetd.
189.Nm
190is normally not run
191from inetd because it needs to generate the server key before it can
192respond to the client, and this may take tens of seconds.
193Clients would have to wait too long if the key was regenerated every time.
194However, with small key sizes (e.g., 512) using
195.Nm
196from inetd may
197be feasible.
198.It Fl k Ar key_gen_time
199Specifies how often the server key is regenerated (default 3600
200seconds, or one hour).
201The motivation for regenerating the key fairly
202often is that the key is not stored anywhere, and after about an hour,
203it becomes impossible to recover the key for decrypting intercepted
204communications even if the machine is cracked into or physically
205seized.
206A value of zero indicates that the key will never be regenerated.
207.It Fl p Ar port
208Specifies the port on which the server listens for connections
209(default 22).
210.It Fl q
211Quiet mode.
212Nothing is sent to the system log.
213Normally the beginning,
214authentication, and termination of each connection is logged.
215.It Fl Q
216Do not print an error message if RSA support is missing.
217.It Fl V Ar client_protocol_id
218SSH2 compatibility mode.
219When this option is specified
220.Nm
221assumes the client has sent the supplied version string
222and skips the
223Protocol Version Identification Exchange.
224.It Fl 4
225Forces
226.Nm
227to use IPv4 addresses only.
228.It Fl 6
229Forces
230.Nm
231to use IPv6 addresses only.
232.El
233.Sh CONFIGURATION FILE
234.Nm
235reads configuration data from
236.Pa /etc/ssh/sshd_config
237(or the file specified with
238.Fl f
239on the command line).
240The file contains keyword-value pairs, one per line.
241Lines starting with
242.Ql #
243and empty lines are interpreted as comments.
244.Pp
245The following keywords are possible.
246.Bl -tag -width Ds
247.It Cm AFSTokenPassing
248Specifies whether an AFS token may be forwarded to the server.
249Default is
250.Dq yes .
251.It Cm AllowGroups
252This keyword can be followed by a number of group names, separated
253by spaces.
254If specified, login is allowed only for users whose primary
255group matches one of the patterns.
256.Ql \&*
257and
258.Ql ?
259can be used as
260wildcards in the patterns.
261Only group names are valid, a numerical group ID isn't recognized.
262By default login is allowed regardless of the primary group.
263.Pp
264.It Cm AllowUsers
265This keyword can be followed by a number of user names, separated
266by spaces.
267If specified, login is allowed only for users names that
268match one of the patterns.
269.Ql \&*
270and
271.Ql ?
272can be used as
273wildcards in the patterns.
274Only user names are valid, a numerical user ID isn't recognized.
275By default login is allowed regardless of the user name.
276.Pp
277.It Cm Ciphers
278Specifies the ciphers allowed for protocol version 2.
279Multiple ciphers must be comma-separated.
280The default is
281.Dq 3des-cbc,blowfish-cbc,arcfour,cast128-cbc .
282.It Cm CheckMail
283Specifies whether
284.Nm
285should check for new mail for interactive logins.
286The default is
287.Dq yes .
288.It Cm ConnectionsPerPeriod
289This keyword allows for rate-limiting of connections, and
290is followed by two numbers in the format
291.Dq n/s ,
292where
293.Ar n
294is the number of connections from a certain address group
295accepted per period of
296.Ar s
297seconds.  Any connection after the number
298.Ar n
299connection in the period of
300.Ar s
301seconds will be dropped, and an informational message will be logged.
302A connection will belong to a certain group, of which there are 13
303by default, according to its IP address.
304The default for this keyword is
305.Dq 0/0 ,
306and rate-limiting can be explicitly turned off by using an
307.Ar n
308parameter of
309.Ql 0
310and any
311.Ar s
312parameter.
313.It Cm DenyGroups
314This keyword can be followed by a number of group names, separated
315by spaces.
316Users whose primary group matches one of the patterns
317aren't allowed to log in.
318.Ql \&*
319and
320.Ql ?
321can be used as
322wildcards in the patterns.
323Only group names are valid, a numerical group ID isn't recognized.
324By default login is allowed regardless of the primary group.
325.Pp
326.It Cm DenyUsers
327This keyword can be followed by a number of user names, separated
328by spaces.
329Login is disallowed for user names that match one of the patterns.
330.Ql \&*
331and
332.Ql ?
333can be used as wildcards in the patterns.
334Only user names are valid, a numerical user ID isn't recognized.
335By default login is allowed regardless of the user name.
336.It Cm DSAAuthentication
337Specifies whether DSA authentication is allowed.
338The default is
339.Dq yes .
340Note that this option applies to protocol version 2 only.
341.It Cm GatewayPorts
342Specifies whether remote hosts are allowed to connect to ports
343forwarded for the client.
344The argument must be
345.Dq yes
346or
347.Dq no .
348The default is
349.Dq no .
350.It Cm HostDsaKey
351Specifies the file containing the private DSA host key (default
352.Pa /etc/ssh/ssh_host_dsa_key )
353used by SSH protocol 2.0.
354Note that
355.Nm
356disables protocol 2.0 if this file is group/world-accessible.
357.It Cm HostKey
358Specifies the file containing the private RSA host key (default
359.Pa /etc/ssh/ssh_host_key )
360used by SSH protocols 1.3 and 1.5.
361Note that
362.Nm
363disables protocols 1.3 and 1.5 if this file is group/world-accessible.
364.It Cm IgnoreRhosts
365Specifies that
366.Pa .rhosts
367and
368.Pa .shosts
369files will not be used in authentication.
370.Pa /etc/hosts.equiv
371and
372.Pa /etc/ssh/shosts.equiv
373are still used.
374The default is
375.Dq yes .
376.It Cm IgnoreUserKnownHosts
377Specifies whether
378.Nm
379should ignore the user's
380.Pa $HOME/.ssh/known_hosts
381during
382.Cm RhostsRSAAuthentication .
383The default is
384.Dq no .
385.It Cm KeepAlive
386Specifies whether the system should send keepalive messages to the
387other side.
388If they are sent, death of the connection or crash of one
389of the machines will be properly noticed.
390However, this means that
391connections will die if the route is down temporarily, and some people
392find it annoying.
393On the other hand, if keepalives are not sent,
394sessions may hang indefinitely on the server, leaving
395.Dq ghost
396users and consuming server resources.
397.Pp
398The default is
399.Dq yes
400(to send keepalives), and the server will notice
401if the network goes down or the client host reboots.
402This avoids infinitely hanging sessions.
403.Pp
404To disable keepalives, the value should be set to
405.Dq no
406in both the server and the client configuration files.
407.It Cm KerberosAuthentication
408Specifies whether Kerberos authentication is allowed.
409This can be in the form of a Kerberos ticket, or if
410.Cm PasswordAuthentication
411is yes, the password provided by the user will be validated through
412the Kerberos KDC.
413Default is
414.Dq yes .
415.It Cm KerberosOrLocalPasswd
416If set then if password authentication through Kerberos fails then
417the password will be validated via any additional local mechanism
418such as
419.Pa /etc/passwd
420or SecurID.
421Default is
422.Dq yes .
423.It Cm KerberosTgtPassing
424Specifies whether a Kerberos TGT may be forwarded to the server.
425Default is
426.Dq no ,
427as this only works when the Kerberos KDC is actually an AFS kaserver.
428.It Cm KerberosTicketCleanup
429Specifies whether to automatically destroy the user's ticket cache
430file on logout.
431Default is
432.Dq yes .
433.It Cm KeyRegenerationInterval
434The server key is automatically regenerated after this many seconds
435(if it has been used).
436The purpose of regeneration is to prevent
437decrypting captured sessions by later breaking into the machine and
438stealing the keys.
439The key is never stored anywhere.
440If the value is 0, the key is never regenerated.
441The default is 3600 (seconds).
442.It Cm ListenAddress
443Specifies what local address
444.Nm
445should listen on.
446The default is to listen to all local addresses.
447Multiple options of this type are permitted.
448Additionally, the
449.Cm Ports
450options must precede this option.
451.It Cm LoginGraceTime
452The server disconnects after this time if the user has not
453successfully logged in.
454If the value is 0, there is no time limit.
455The default is 60 (seconds).
456.It Cm LogLevel
457Gives the verbosity level that is used when logging messages from
458.Nm sshd .
459The possible values are:
460QUIET, FATAL, ERROR, INFO, VERBOSE and DEBUG.
461The default is INFO.
462Logging with level DEBUG violates the privacy of users
463and is not recommended.
464.It Cm PasswordAuthentication
465Specifies whether password authentication is allowed.
466The default is
467.Dq yes .
468Note that this option applies to both protocol version 1 and 2.
469.It Cm PermitEmptyPasswords
470When password authentication is allowed, it specifies whether the
471server allows login to accounts with empty password strings.
472The default is
473.Dq no .
474.It Cm PermitRootLogin
475Specifies whether the root can log in using
476.Xr ssh 1 .
477The argument must be
478.Dq yes ,
479.Dq without-password
480or
481.Dq no .
482The default is
483.Dq no .
484If this options is set to
485.Dq without-password
486only password authentication is disabled for root.
487.Pp
488Root login with RSA authentication when the
489.Ar command
490option has been
491specified will be allowed regardless of the value of this setting
492(which may be useful for taking remote backups even if root login is
493normally not allowed).
494.It Cm PidFile
495Specifies the file that contains the process identifier of the
496.Nm
497daemon.
498The default is
499.Pa /var/run/sshd.pid .
500.It Cm Port
501Specifies the port number that
502.Nm
503listens on.
504The default is 22.
505Multiple options of this type are permitted.
506.It Cm PrintMotd
507Specifies whether
508.Nm
509should print
510.Pa /etc/motd
511when a user logs in interactively.
512(On some systems it is also printed by the shell,
513.Pa /etc/profile ,
514or equivalent.)
515The default is
516.Dq yes .
517.It Cm Protocol
518Specifies the protocol versions
519.Nm
520should support.
521The possible values are
522.Dq 1
523and
524.Dq 2 .
525Multiple versions must be comma-separated.
526The default is
527.Dq 1 .
528.It Cm RandomSeed
529Obsolete - accepted and ignored with a warning.
530Random number generation uses other techniques.
531.It Cm RhostsAuthentication
532Specifies whether authentication using rhosts or
533.Pa /etc/hosts.equiv
534files is sufficient.
535Normally, this method should not be permitted because it is insecure.
536.Cm RhostsRSAAuthentication
537should be used
538instead, because it performs RSA-based host authentication in addition
539to normal rhosts or
540.Pa /etc/hosts.equiv
541authentication.
542The default is
543.Dq no .
544.It Cm RhostsRSAAuthentication
545Specifies whether rhosts or
546.Pa /etc/hosts.equiv
547authentication together
548with successful RSA host authentication is allowed.
549The default is
550.Dq no .
551.It Cm RSAAuthentication
552Specifies whether pure RSA authentication is allowed.
553The default is
554.Dq yes .
555Note that this option applies to protocol version 1 only.
556.It Cm ServerKeyBits
557Defines the number of bits in the server key.
558The minimum value is 512, and the default is 768.
559.It Cm SkeyAuthentication
560Specifies whether
561.Xr skey 1
562authentication is allowed.
563The default is
564.Dq yes .
565Note that OPIE authentication is enabled only if
566.Cm PasswordAuthentication
567is allowed, too.
568.It Cm StrictModes
569Specifies whether
570.Nm
571should check file modes and ownership of the
572user's files and home directory before accepting login.
573This is normally desirable because novices sometimes accidentally leave their
574directory or files world-writable.
575The default is
576.Dq yes .
577.It Cm SyslogFacility
578Gives the facility code that is used when logging messages from
579.Nm sshd .
580The possible values are: DAEMON, USER, AUTH, LOCAL0, LOCAL1, LOCAL2,
581LOCAL3, LOCAL4, LOCAL5, LOCAL6, LOCAL7.
582The default is AUTH.
583.It Cm UseLogin
584Specifies whether
585.Xr login 1
586is used.
587The default is
588.Dq no .
589.It Cm X11DisplayOffset
590Specifies the first display number available for
591.Nm sshd Ns 's
592X11 forwarding.
593This prevents
594.Nm
595from interfering with real X11 servers.
596The default is 10.
597.It Cm X11Forwarding
598Specifies whether X11 forwarding is permitted.
599The default is
600.Dq no .
601Note that disabling X11 forwarding does not improve security in any
602way, as users can always install their own forwarders.
603.El
604.Sh LOGIN PROCESS
605When a user successfully logs in,
606.Nm
607does the following:
608.Bl -enum -offset indent
609.It
610If the login is on a tty, and no command has been specified,
611prints last login time and
612.Pa /etc/motd
613(unless prevented in the configuration file or by
614.Pa $HOME/.hushlogin ;
615see the
616.Sx FILES
617section).
618.It
619If the login is on a tty, records login time.
620.It
621Checks
622.Pa /etc/nologin and
623.Pa /var/run/nologin ;
624if one exists, it prints the contents and quits
625(unless root).
626.It
627Changes to run with normal user privileges.
628.It
629Sets up basic environment.
630.It
631Reads
632.Pa $HOME/.ssh/environment
633if it exists.
634.It
635Changes to user's home directory.
636.It
637If
638.Pa $HOME/.ssh/rc
639exists, runs it; else if
640.Pa /etc/ssh/sshrc
641exists, runs
642it; otherwise runs
643.Xr xauth 1 .
644The
645.Dq rc
646files are given the X11
647authentication protocol and cookie (if applicable) in standard input.
648.It
649Runs user's shell or command.
650.El
651.Sh AUTHORIZED_KEYS FILE FORMAT
652The
653.Pa $HOME/.ssh/authorized_keys
654file lists the RSA keys that are
655permitted for RSA authentication in SSH protocols 1.3 and 1.5
656Similarly, the
657.Pa $HOME/.ssh/authorized_keys2
658file lists the DSA keys that are
659permitted for DSA authentication in SSH protocol 2.0.
660Each line of the file contains one
661key (empty lines and lines starting with a
662.Ql #
663are ignored as
664comments).
665Each line consists of the following fields, separated by
666spaces: options, bits, exponent, modulus, comment.
667The options field
668is optional; its presence is determined by whether the line starts
669with a number or not (the option field never starts with a number).
670The bits, exponent, modulus and comment fields give the RSA key; the
671comment field is not used for anything (but may be convenient for the
672user to identify the key).
673.Pp
674Note that lines in this file are usually several hundred bytes long
675(because of the size of the RSA key modulus).
676You don't want to type them in; instead, copy the
677.Pa identity.pub
678file and edit it.
679.Pp
680The options (if present) consists of comma-separated option
681specifications.
682No spaces are permitted, except within double quotes.
683The following option specifications are supported:
684.Bl -tag -width Ds
685.It Cm from="pattern-list"
686Specifies that in addition to RSA authentication, the canonical name
687of the remote host must be present in the comma-separated list of
688patterns
689.Pf ( Ql *
690and
691.Ql ?
692serve as wildcards).
693The list may also contain
694patterns negated by prefixing them with
695.Ql ! ;
696if the canonical host name matches a negated pattern, the key is not accepted.
697The purpose
698of this option is to optionally increase security: RSA authentication
699by itself does not trust the network or name servers or anything (but
700the key); however, if somebody somehow steals the key, the key
701permits an intruder to log in from anywhere in the world.
702This additional option makes using a stolen key more difficult (name
703servers and/or routers would have to be compromised in addition to
704just the key).
705.It Cm command="command"
706Specifies that the command is executed whenever this key is used for
707authentication.
708The command supplied by the user (if any) is ignored.
709The command is run on a pty if the connection requests a pty;
710otherwise it is run without a tty.
711A quote may be included in the command by quoting it with a backslash.
712This option might be useful
713to restrict certain RSA keys to perform just a specific operation.
714An example might be a key that permits remote backups but nothing else.
715Note that the client may specify TCP/IP and/or X11
716forwarding unless they are explicitly prohibited.
717.It Cm environment="NAME=value"
718Specifies that the string is to be added to the environment when
719logging in using this key.
720Environment variables set this way
721override other default environment values.
722Multiple options of this type are permitted.
723.It Cm no-port-forwarding
724Forbids TCP/IP forwarding when this key is used for authentication.
725Any port forward requests by the client will return an error.
726This might be used, e.g., in connection with the
727.Cm command
728option.
729.It Cm no-X11-forwarding
730Forbids X11 forwarding when this key is used for authentication.
731Any X11 forward requests by the client will return an error.
732.It Cm no-agent-forwarding
733Forbids authentication agent forwarding when this key is used for
734authentication.
735.It Cm no-pty
736Prevents tty allocation (a request to allocate a pty will fail).
737.El
738.Ss Examples
739.Bd -literal
7401024 33 12121...312314325 ylo@foo.bar
741from="*.niksula.hut.fi,!pc.niksula.hut.fi" 1024 35 23...2334 ylo@niksula
742command="dump /home",no-pty,no-port-forwarding 1024 33 23...2323 backup.hut.fi
743.Ed
744.Sh SSH_KNOWN_HOSTS FILE FORMAT
745The
746.Pa /etc/ssh/ssh_known_hosts ,
747.Pa /etc/ssh/ssh_known_hosts2 ,
748.Pa $HOME/.ssh/known_hosts ,
749and
750.Pa $HOME/.ssh/known_hosts2
751files contain host public keys for all known hosts.
752The global file should
753be prepared by the administrator (optional), and the per-user file is
754maintained automatically: whenever the user connects an unknown host
755its key is added to the per-user file.
756.Pp
757Each line in these files contains the following fields: hostnames,
758bits, exponent, modulus, comment.
759The fields are separated by spaces.
760.Pp
761Hostnames is a comma-separated list of patterns ('*' and '?' act as
762wildcards); each pattern in turn is matched against the canonical host
763name (when authenticating a client) or against the user-supplied
764name (when authenticating a server).
765A pattern may also be preceded by
766.Ql !
767to indicate negation: if the host name matches a negated
768pattern, it is not accepted (by that line) even if it matched another
769pattern on the line.
770.Pp
771Bits, exponent, and modulus are taken directly from the RSA host key; they
772can be obtained, e.g., from
773.Pa /etc/ssh/ssh_host_key.pub .
774The optional comment field continues to the end of the line, and is not used.
775.Pp
776Lines starting with
777.Ql #
778and empty lines are ignored as comments.
779.Pp
780When performing host authentication, authentication is accepted if any
781matching line has the proper key.
782It is thus permissible (but not
783recommended) to have several lines or different host keys for the same
784names.
785This will inevitably happen when short forms of host names
786from different domains are put in the file.
787It is possible
788that the files contain conflicting information; authentication is
789accepted if valid information can be found from either file.
790.Pp
791Note that the lines in these files are typically hundreds of characters
792long, and you definitely don't want to type in the host keys by hand.
793Rather, generate them by a script
794or by taking
795.Pa /etc/ssh/ssh_host_key.pub
796and adding the host names at the front.
797.Ss Examples
798.Bd -literal
799closenet,closenet.hut.fi,...,130.233.208.41 1024 37 159...93 closenet.hut.fi
800.Ed
801.Sh FILES
802.Bl -tag -width Ds
803.It Pa /etc/ssh/sshd_config
804Contains configuration data for
805.Nm sshd .
806This file should be writable by root only, but it is recommended
807(though not necessary) that it be world-readable.
808.It Pa /etc/ssh/ssh_host_key
809Contains the private part of the host key.
810This file should only be owned by root, readable only by root, and not
811accessible to others.
812Note that
813.Nm
814does not start if this file is group/world-accessible.
815.It Pa /etc/ssh/ssh_host_key.pub
816Contains the public part of the host key.
817This file should be world-readable but writable only by
818root.
819Its contents should match the private part.
820This file is not
821really used for anything; it is only provided for the convenience of
822the user so its contents can be copied to known hosts files.
823These two files are created using
824.Xr ssh-keygen 1 .
825.It Pa /var/run/sshd.pid
826Contains the process ID of the
827.Nm
828listening for connections (if there are several daemons running
829concurrently for different ports, this contains the pid of the one
830started last).
831The contents of this file are not sensitive; it can be world-readable.
832.It Pa $HOME/.ssh/authorized_keys
833Lists the RSA keys that can be used to log into the user's account.
834This file must be readable by root (which may on some machines imply
835it being world-readable if the user's home directory resides on an NFS
836volume).
837It is recommended that it not be accessible by others.
838The format of this file is described above.
839Users will place the contents of their
840.Pa identity.pub
841files into this file, as described in
842.Xr ssh-keygen 1 .
843.It Pa $HOME/.ssh/authorized_keys2
844Lists the DSA keys that can be used to log into the user's account.
845This file must be readable by root (which may on some machines imply
846it being world-readable if the user's home directory resides on an NFS
847volume).
848It is recommended that it not be accessible by others.
849The format of this file is described above.
850Users will place the contents of their
851.Pa id_dsa.pub
852files into this file, as described in
853.Xr ssh-keygen 1 .
854.It Pa "/etc/ssh/ssh_known_hosts" and "$HOME/.ssh/known_hosts"
855These files are consulted when using rhosts with RSA host
856authentication to check the public key of the host.
857The key must be listed in one of these files to be accepted.
858The client uses the same files
859to verify that the remote host is the one we intended to connect.
860These files should be writable only by root/the owner.
861.Pa /etc/ssh/ssh_known_hosts
862should be world-readable, and
863.Pa $HOME/.ssh/known_hosts
864can but need not be world-readable.
865.It Pa /etc/nologin
866If this file exists,
867.Nm
868refuses to let anyone except root log in.
869The contents of the file
870are displayed to anyone trying to log in, and non-root connections are
871refused.
872The file should be world-readable.
873.It Pa /etc/hosts.allow
874If compiled with
875.Sy LIBWRAP
876support, tcp-wrappers access controls may be defined here as described in
877.Xr hosts_access 5 .
878.It Pa $HOME/.rhosts
879This file contains host-username pairs, separated by a space, one per
880line.
881The given user on the corresponding host is permitted to log in
882without password.
883The same file is used by rlogind and rshd.
884The file must
885be writable only by the user; it is recommended that it not be
886accessible by others.
887.Pp
888If is also possible to use netgroups in the file.
889Either host or user
890name may be of the form +@groupname to specify all hosts or all users
891in the group.
892.It Pa $HOME/.shosts
893For ssh,
894this file is exactly the same as for
895.Pa .rhosts .
896However, this file is
897not used by rlogin and rshd, so using this permits access using SSH only.
898.It Pa /etc/hosts.equiv
899This file is used during
900.Pa .rhosts
901authentication.
902In the simplest form, this file contains host names, one per line.
903Users on
904those hosts are permitted to log in without a password, provided they
905have the same user name on both machines.
906The host name may also be
907followed by a user name; such users are permitted to log in as
908.Em any
909user on this machine (except root).
910Additionally, the syntax
911.Dq +@group
912can be used to specify netgroups.
913Negated entries start with
914.Ql \&- .
915.Pp
916If the client host/user is successfully matched in this file, login is
917automatically permitted provided the client and server user names are the
918same.
919Additionally, successful RSA host authentication is normally required.
920This file must be writable only by root; it is recommended
921that it be world-readable.
922.Pp
923.Sy "Warning: It is almost never a good idea to use user names in"
924.Pa hosts.equiv .
925Beware that it really means that the named user(s) can log in as
926.Em anybody ,
927which includes bin, daemon, adm, and other accounts that own critical
928binaries and directories.
929Using a user name practically grants the user root access.
930The only valid use for user names that I can think
931of is in negative entries.
932.Pp
933Note that this warning also applies to rsh/rlogin.
934.It Pa /etc/ssh/shosts.equiv
935This is processed exactly as
936.Pa /etc/hosts.equiv .
937However, this file may be useful in environments that want to run both
938rsh/rlogin and ssh.
939.It Pa $HOME/.ssh/environment
940This file is read into the environment at login (if it exists).
941It can only contain empty lines, comment lines (that start with
942.Ql # ) ,
943and assignment lines of the form name=value.
944The file should be writable
945only by the user; it need not be readable by anyone else.
946.It Pa $HOME/.ssh/rc
947If this file exists, it is run with
948.Pa /bin/sh
949after reading the
950environment files but before starting the user's shell or command.
951If X11 spoofing is in use, this will receive the "proto cookie" pair in
952standard input (and
953.Ev DISPLAY
954in environment).
955This must call
956.Xr xauth 1
957in that case.
958.Pp
959The primary purpose of this file is to run any initialization routines
960which may be needed before the user's home directory becomes
961accessible; AFS is a particular example of such an environment.
962.Pp
963This file will probably contain some initialization code followed by
964something similar to:
965.Bd -literal -offset indent
966if [ -n "$DISPLAY" ] && read proto cookie; then
967    echo add $DISPLAY $proto $cookie | xauth -q -
968fi
969.Ed
970.Pp
971If this file does not exist,
972.Pa /etc/ssh/sshrc
973is run, and if that
974does not exist either,
975.Xr xauth 1
976is used to store the cookie.
977.Pp
978This file should be writable only by the user, and need not be
979readable by anyone else.
980.It Pa /etc/ssh/sshrc
981Like
982.Pa $HOME/.ssh/rc .
983This can be used to specify
984machine-specific login-time initializations globally.
985This file should be writable only by root, and should be world-readable.
986.Sh AUTHOR
987OpenSSH
988is a derivative of the original (free) ssh 1.2.12 release by Tatu Ylonen,
989but with bugs removed and newer features re-added.
990Rapidly after the
9911.2.12 release, newer versions of the original ssh bore successively
992more restrictive licenses, and thus demand for a free version was born.
993.Pp
994This version of OpenSSH
995.Bl -bullet
996.It
997has all components of a restrictive nature (i.e., patents, see
998.Xr ssl 8 )
999directly removed from the source code; any licensed or patented components
1000are chosen from
1001external libraries.
1002.It
1003has been updated to support SSH protocol 1.5 and 2, making it compatible with
1004all other SSH clients and servers.
1005.It
1006contains added support for
1007.Xr kerberos 8
1008authentication and ticket passing.
1009.It
1010supports one-time password authentication with
1011.Xr skey 1 .
1012.El
1013.Pp
1014The libraries described in
1015.Xr ssl 8
1016are required for proper operation.
1017.Pp
1018OpenSSH has been created by Aaron Campbell, Bob Beck, Markus Friedl,
1019Niels Provos, Theo de Raadt, and Dug Song.
1020.Pp
1021The support for SSH protocol 2 was written by Markus Friedl.
1022.Sh SEE ALSO
1023.Xr scp 1 ,
1024.Xr ssh 1 ,
1025.Xr ssh-add 1 ,
1026.Xr ssh-agent 1 ,
1027.Xr ssh-keygen 1 ,
1028.Xr ssl 8 ,
1029.Xr rlogin 1 ,
1030.Xr rsh 1
1031