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