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