blob: 1ec135ca9443a1a7918cbcdd19c499ce4081f52b [file] [log] [blame]
Damien Miller32aa1441999-10-29 09:15:49 +10001.\" -*- nroff -*-
2.\"
Damien Miller32aa1441999-10-29 09:15:49 +10003.\" Author: Tatu Ylonen <ylo@cs.hut.fi>
Damien Miller32aa1441999-10-29 09:15:49 +10004.\" Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
5.\" All rights reserved
6.\"
Damien Millere4340be2000-09-16 13:29:08 +11007.\" 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".
Damien Miller32aa1441999-10-29 09:15:49 +100012.\"
Ben Lindstrom92a2e382001-03-05 06:59:27 +000013.\" 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.
Damien Millere4340be2000-09-16 13:29:08 +110016.\"
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.
Damien Miller32aa1441999-10-29 09:15:49 +100036.\"
Darren Tuckere7f3f752008-06-10 23:06:01 +100037.\" $OpenBSD: sshd.8,v 1.243 2008/06/10 08:17:40 jmc Exp $
Darren Tuckere7140f22008-06-10 23:01:51 +100038.Dd $Mdocdate: June 10 2008 $
Damien Miller32aa1441999-10-29 09:15:49 +100039.Dt SSHD 8
40.Os
41.Sh NAME
42.Nm sshd
Ben Lindstromc65e6a02001-04-23 13:02:16 +000043.Nd OpenSSH SSH daemon
Damien Miller32aa1441999-10-29 09:15:49 +100044.Sh SYNOPSIS
45.Nm sshd
Damien Millerffadc582003-02-24 11:52:26 +110046.Bk -words
Darren Tuckere7f3f752008-06-10 23:06:01 +100047.Op Fl 46DdeiqTt
Damien Miller32aa1441999-10-29 09:15:49 +100048.Op Fl b Ar bits
Darren Tuckere7140f22008-06-10 23:01:51 +100049.Op Fl C Ar connection_spec
Damien Miller32aa1441999-10-29 09:15:49 +100050.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
Ben Lindstromade03f62001-12-06 18:22:17 +000054.Op Fl o Ar option
Damien Miller32aa1441999-10-29 09:15:49 +100055.Op Fl p Ar port
Damien Miller942da032000-08-18 13:59:06 +100056.Op Fl u Ar len
Damien Millerffadc582003-02-24 11:52:26 +110057.Ek
Damien Miller22c77262000-04-13 12:26:34 +100058.Sh DESCRIPTION
Damien Miller32aa1441999-10-29 09:15:49 +100059.Nm
Damien Miller99cc4a82006-01-31 21:45:53 +110060(OpenSSH Daemon) is the daemon program for
Damien Miller32aa1441999-10-29 09:15:49 +100061.Xr ssh 1 .
Darren Tucker04354b92007-03-21 20:46:54 +110062Together these programs replace
63.Xr rlogin 1
64and
65.Xr rsh 1 ,
66and provide secure encrypted communications between two untrusted hosts
Damien Miller450a7a12000-03-26 13:04:51 +100067over an insecure network.
Damien Miller32aa1441999-10-29 09:15:49 +100068.Pp
69.Nm
Damien Miller99cc4a82006-01-31 21:45:53 +110070listens for connections from clients.
Damien Miller22c77262000-04-13 12:26:34 +100071It is normally started at boot from
Damien Miller32aa1441999-10-29 09:15:49 +100072.Pa /etc/rc .
73It forks a new
Damien Miller450a7a12000-03-26 13:04:51 +100074daemon for each incoming connection.
75The forked daemons handle
Damien Miller32aa1441999-10-29 09:15:49 +100076key exchange, encryption, authentication, command execution,
77and data exchange.
Damien Miller32aa1441999-10-29 09:15:49 +100078.Pp
79.Nm
Darren Tucker1f203942003-10-15 15:50:42 +100080can be configured using command-line options or a configuration file
81(by default
Damien Miller99cc4a82006-01-31 21:45:53 +110082.Xr sshd_config 5 ) ;
83command-line options override values specified in the
Damien Miller32aa1441999-10-29 09:15:49 +100084configuration file.
Damien Miller6162d121999-11-21 13:23:52 +110085.Nm
86rereads its configuration file when it receives a hangup signal,
Ben Lindstrom49a098d2001-03-05 06:55:18 +000087.Dv SIGHUP ,
Damien Miller208f1ed2006-03-15 11:56:03 +110088by executing itself with the name and options it was started with, e.g.\&
Ben Lindstrom49a098d2001-03-05 06:55:18 +000089.Pa /usr/sbin/sshd .
Damien Miller6162d121999-11-21 13:23:52 +110090.Pp
Damien Miller32aa1441999-10-29 09:15:49 +100091The options are as follows:
92.Bl -tag -width Ds
Darren Tucker1f203942003-10-15 15:50:42 +100093.It Fl 4
94Forces
95.Nm
96to use IPv4 addresses only.
97.It Fl 6
98Forces
99.Nm
100to use IPv6 addresses only.
Damien Miller32aa1441999-10-29 09:15:49 +1000101.It Fl b Ar bits
Ben Lindstromc65e6a02001-04-23 13:02:16 +0000102Specifies the number of bits in the ephemeral protocol version 1
103server key (default 768).
Darren Tuckere7f3f752008-06-10 23:06:01 +1000104.It Fl C Ar connection_spec
105Specify the connection parameters to use for the
106.Fl T
107extended test mode.
108If provided, any
109.Cm Match
110directives in the configuration file
111that would apply to the specified user, host, and address will be set before
112the configuration is written to standard output.
113The connection parameters are supplied as keyword=value pairs.
114The keywords are
115.Dq user ,
116.Dq host ,
117and
118.Dq addr .
119All are required and may be supplied in any order, either with multiple
120.Fl C
121options or as a comma-separated list.
Darren Tucker1f203942003-10-15 15:50:42 +1000122.It Fl D
123When this option is specified,
124.Nm
125will not detach and does not become a daemon.
126This allows easy monitoring of
127.Nm sshd .
Damien Miller32aa1441999-10-29 09:15:49 +1000128.It Fl d
Damien Miller450a7a12000-03-26 13:04:51 +1000129Debug mode.
130The server sends verbose debug output to the system
131log, and does not put itself in the background.
132The server also will not fork and will only process one connection.
133This option is only intended for debugging for the server.
Damien Millerffadc582003-02-24 11:52:26 +1100134Multiple
135.Fl d
136options increase the debugging level.
Damien Miller874d77b2000-10-14 16:23:11 +1100137Maximum is 3.
Ben Lindstromc65e6a02001-04-23 13:02:16 +0000138.It Fl e
139When this option is specified,
140.Nm
141will send the output to the standard error instead of the system log.
Darren Tucker04354b92007-03-21 20:46:54 +1100142.It Fl f Ar config_file
Damien Miller450a7a12000-03-26 13:04:51 +1000143Specifies the name of the configuration file.
144The default is
Damien Miller05eda432002-02-10 18:32:28 +1100145.Pa /etc/ssh/sshd_config .
Damien Miller32aa1441999-10-29 09:15:49 +1000146.Nm
147refuses to start if there is no configuration file.
148.It Fl g Ar login_grace_time
149Gives the grace time for clients to authenticate themselves (default
Damien Millerc1348632002-09-05 14:35:14 +1000150120 seconds).
Damien Miller450a7a12000-03-26 13:04:51 +1000151If the client fails to authenticate the user within
152this many seconds, the server disconnects and exits.
153A value of zero indicates no limit.
Damien Miller32aa1441999-10-29 09:15:49 +1000154.It Fl h Ar host_key_file
Damien Miller7fc23732002-01-22 23:19:11 +1100155Specifies a file from which a host key is read.
Damien Miller32aa1441999-10-29 09:15:49 +1000156This option must be given if
157.Nm
158is not run as root (as the normal
Damien Miller7fc23732002-01-22 23:19:11 +1100159host key files are normally not readable by anyone but root).
160The default is
Damien Miller05eda432002-02-10 18:32:28 +1100161.Pa /etc/ssh/ssh_host_key
Damien Miller7fc23732002-01-22 23:19:11 +1100162for protocol version 1, and
Damien Miller05eda432002-02-10 18:32:28 +1100163.Pa /etc/ssh/ssh_host_rsa_key
Damien Miller7fc23732002-01-22 23:19:11 +1100164and
Damien Miller05eda432002-02-10 18:32:28 +1100165.Pa /etc/ssh/ssh_host_dsa_key
Damien Miller7fc23732002-01-22 23:19:11 +1100166for protocol version 2.
Ben Lindstrom4dccfa52000-12-28 16:40:05 +0000167It is possible to have multiple host key files for
Ben Lindstromc65e6a02001-04-23 13:02:16 +0000168the different protocol versions and host key algorithms.
Damien Miller32aa1441999-10-29 09:15:49 +1000169.It Fl i
170Specifies that
171.Nm
Damien Millerffadc582003-02-24 11:52:26 +1100172is being run from
173.Xr inetd 8 .
Damien Miller32aa1441999-10-29 09:15:49 +1000174.Nm
175is normally not run
176from inetd because it needs to generate the server key before it can
Damien Miller450a7a12000-03-26 13:04:51 +1000177respond to the client, and this may take tens of seconds.
178Clients would have to wait too long if the key was regenerated every time.
Damien Miller208f1ed2006-03-15 11:56:03 +1100179However, with small key sizes (e.g. 512) using
Damien Miller32aa1441999-10-29 09:15:49 +1000180.Nm
181from inetd may
182be feasible.
183.It Fl k Ar key_gen_time
Ben Lindstromc65e6a02001-04-23 13:02:16 +0000184Specifies how often the ephemeral protocol version 1 server key is
185regenerated (default 3600 seconds, or one hour).
Damien Miller450a7a12000-03-26 13:04:51 +1000186The motivation for regenerating the key fairly
Darren Tucker1f203942003-10-15 15:50:42 +1000187often is that the key is not stored anywhere, and after about an hour
Damien Miller32aa1441999-10-29 09:15:49 +1000188it becomes impossible to recover the key for decrypting intercepted
189communications even if the machine is cracked into or physically
Damien Miller450a7a12000-03-26 13:04:51 +1000190seized.
191A value of zero indicates that the key will never be regenerated.
Ben Lindstromade03f62001-12-06 18:22:17 +0000192.It Fl o Ar option
193Can be used to give options in the format used in the configuration file.
194This is useful for specifying options for which there is no separate
195command-line flag.
Darren Tucker1f203942003-10-15 15:50:42 +1000196For full details of the options, and their values, see
197.Xr sshd_config 5 .
Damien Miller32aa1441999-10-29 09:15:49 +1000198.It Fl p Ar port
199Specifies the port on which the server listens for connections
200(default 22).
Damien Miller7d1ded42002-01-22 23:09:41 +1100201Multiple port options are permitted.
Damien Millerd7f308f2005-12-24 14:55:16 +1100202Ports specified in the configuration file with the
203.Cm Port
204option are ignored when a command-line port is specified.
205Ports specified using the
206.Cm ListenAddress
207option override command-line ports.
Damien Miller32aa1441999-10-29 09:15:49 +1000208.It Fl q
Damien Miller450a7a12000-03-26 13:04:51 +1000209Quiet mode.
210Nothing is sent to the system log.
211Normally the beginning,
Damien Miller32aa1441999-10-29 09:15:49 +1000212authentication, and termination of each connection is logged.
Darren Tuckere7140f22008-06-10 23:01:51 +1000213.It Fl T
214Extended test mode.
215Check the validity of the configuration file, output the effective configuration
216to stdout and then exit.
217Optionally,
218.Cm Match
219rules may be applied by specifying the connection parameters using one or more
220.Fl C
221options.
Darren Tuckere7f3f752008-06-10 23:06:01 +1000222.It Fl t
223Test mode.
224Only check the validity of the configuration file and sanity of the keys.
225This is useful for updating
226.Nm
227reliably as configuration options may change.
Damien Miller942da032000-08-18 13:59:06 +1000228.It Fl u Ar len
229This option is used to specify the size of the field
230in the
231.Li utmp
232structure that holds the remote host name.
233If the resolved host name is longer than
234.Ar len ,
235the dotted decimal value will be used instead.
236This allows hosts with very long host names that
237overflow this field to still be uniquely identified.
238Specifying
239.Fl u0
240indicates that only dotted decimal addresses
241should be put into the
242.Pa utmp
243file.
Ben Lindstrom6f672c02001-09-12 17:51:55 +0000244.Fl u0
Damien Millerffadc582003-02-24 11:52:26 +1100245may also be used to prevent
Ben Lindstrom6f672c02001-09-12 17:51:55 +0000246.Nm
247from making DNS requests unless the authentication
248mechanism or configuration requires it.
249Authentication mechanisms that may require DNS include
Ben Lindstrom6f672c02001-09-12 17:51:55 +0000250.Cm RhostsRSAAuthentication ,
Damien Miller2ac05772006-02-01 22:05:42 +1100251.Cm HostbasedAuthentication ,
Ben Lindstrom6f672c02001-09-12 17:51:55 +0000252and using a
253.Cm from="pattern-list"
254option in a key file.
Ben Lindstromea03db92002-03-05 01:38:57 +0000255Configuration options that require DNS include using a
256USER@HOST pattern in
257.Cm AllowUsers
258or
259.Cm DenyUsers .
Damien Miller32aa1441999-10-29 09:15:49 +1000260.El
Damien Miller8bbdf902006-02-01 22:05:25 +1100261.Sh AUTHENTICATION
262The OpenSSH SSH daemon supports SSH protocols 1 and 2.
263Both protocols are supported by default,
264though this can be changed via the
265.Cm Protocol
266option in
267.Xr sshd_config 5 .
268Protocol 2 supports both RSA and DSA keys;
269protocol 1 only supports RSA keys.
270For both protocols,
271each host has a host-specific key,
272normally 2048 bits,
273used to identify the host.
Damien Miller99cc4a82006-01-31 21:45:53 +1100274.Pp
Damien Miller8bbdf902006-02-01 22:05:25 +1100275Forward security for protocol 1 is provided through
276an additional server key,
277normally 768 bits,
278generated when the server starts.
Damien Miller99cc4a82006-01-31 21:45:53 +1100279This key is normally regenerated every hour if it has been used, and
280is never stored on disk.
Damien Miller99cc4a82006-01-31 21:45:53 +1100281Whenever a client connects, the daemon responds with its public
282host and server keys.
283The client compares the
284RSA host key against its own database to verify that it has not changed.
285The client then generates a 256-bit random number.
286It encrypts this
287random number using both the host key and the server key, and sends
288the encrypted number to the server.
289Both sides then use this
290random number as a session key which is used to encrypt all further
291communications in the session.
292The rest of the session is encrypted
293using a conventional cipher, currently Blowfish or 3DES, with 3DES
294being used by default.
295The client selects the encryption algorithm
296to use from those offered by the server.
297.Pp
Damien Miller8bbdf902006-02-01 22:05:25 +1100298For protocol 2,
299forward security is provided through a Diffie-Hellman key agreement.
300This key agreement results in a shared session key.
301The rest of the session is encrypted using a symmetric cipher, currently
302128-bit AES, Blowfish, 3DES, CAST128, Arcfour, 192-bit AES, or 256-bit AES.
303The client selects the encryption algorithm
304to use from those offered by the server.
305Additionally, session integrity is provided
306through a cryptographic message authentication code
Damien Millere45796f2007-06-11 14:01:42 +1000307(hmac-md5, hmac-sha1, umac-64 or hmac-ripemd160).
Damien Miller8bbdf902006-02-01 22:05:25 +1100308.Pp
309Finally, the server and the client enter an authentication dialog.
Damien Miller99cc4a82006-01-31 21:45:53 +1100310The client tries to authenticate itself using
Damien Miller8bbdf902006-02-01 22:05:25 +1100311host-based authentication,
312public key authentication,
313challenge-response authentication,
314or password authentication.
Damien Miller99cc4a82006-01-31 21:45:53 +1100315.Pp
316Regardless of the authentication type, the account is checked to
317ensure that it is accessible. An account is not accessible if it is
318locked, listed in
319.Cm DenyUsers
320or its group is listed in
321.Cm DenyGroups
322\&. The definition of a locked account is system dependant. Some platforms
323have their own account database (eg AIX) and some modify the passwd field (
324.Ql \&*LK\&*
325on Solaris and UnixWare,
326.Ql \&*
327on HP-UX, containing
328.Ql Nologin
329on Tru64,
330a leading
331.Ql \&*LOCKED\&*
332on FreeBSD and a leading
Darren Tucker1a9176b2007-08-17 09:42:32 +1000333.Ql \&!
334on most Linuxes).
335If there is a requirement to disable password authentication
Damien Miller99cc4a82006-01-31 21:45:53 +1100336for the account while allowing still public-key, then the passwd field
337should be set to something other than these values (eg
338.Ql NP
339or
340.Ql \&*NP\&*
341).
342.Pp
Damien Miller99cc4a82006-01-31 21:45:53 +1100343If the client successfully authenticates itself, a dialog for
344preparing the session is entered.
345At this time the client may request
346things like allocating a pseudo-tty, forwarding X11 connections,
347forwarding TCP connections, or forwarding the authentication agent
348connection over the secure channel.
349.Pp
Damien Millerc47d7e92006-03-15 11:27:20 +1100350After this, the client either requests a shell or execution of a command.
Damien Miller99cc4a82006-01-31 21:45:53 +1100351The sides then enter session mode.
352In this mode, either side may send
353data at any time, and such data is forwarded to/from the shell or
354command on the server side, and the user terminal in the client side.
355.Pp
356When the user program terminates and all forwarded X11 and other
357connections have been closed, the server sends command exit status to
358the client, and both sides exit.
Damien Miller32aa1441999-10-29 09:15:49 +1000359.Sh LOGIN PROCESS
360When a user successfully logs in,
361.Nm
362does the following:
363.Bl -enum -offset indent
364.It
365If the login is on a tty, and no command has been specified,
Damien Miller22c77262000-04-13 12:26:34 +1000366prints last login time and
Damien Miller32aa1441999-10-29 09:15:49 +1000367.Pa /etc/motd
368(unless prevented in the configuration file or by
Damien Miller167ea5d2005-05-26 12:04:02 +1000369.Pa ~/.hushlogin ;
Damien Miller32aa1441999-10-29 09:15:49 +1000370see the
Damien Miller22c77262000-04-13 12:26:34 +1000371.Sx FILES
Damien Miller32aa1441999-10-29 09:15:49 +1000372section).
373.It
374If the login is on a tty, records login time.
375.It
376Checks
377.Pa /etc/nologin ;
378if it exists, prints contents and quits
379(unless root).
380.It
381Changes to run with normal user privileges.
382.It
383Sets up basic environment.
384.It
Darren Tucker1f203942003-10-15 15:50:42 +1000385Reads the file
Damien Miller167ea5d2005-05-26 12:04:02 +1000386.Pa ~/.ssh/environment ,
Darren Tucker1f203942003-10-15 15:50:42 +1000387if it exists, and users are allowed to change their environment.
Ben Lindstrombd9bf382002-08-20 18:54:20 +0000388See the
Ben Lindstromdc7adf22002-08-20 18:38:02 +0000389.Cm PermitUserEnvironment
Ben Lindstrombd9bf382002-08-20 18:54:20 +0000390option in
Ben Lindstromdc7adf22002-08-20 18:38:02 +0000391.Xr sshd_config 5 .
Damien Miller32aa1441999-10-29 09:15:49 +1000392.It
393Changes to user's home directory.
394.It
395If
Damien Miller167ea5d2005-05-26 12:04:02 +1000396.Pa ~/.ssh/rc
Damien Miller32aa1441999-10-29 09:15:49 +1000397exists, runs it; else if
Damien Millerafcc2252002-02-10 18:32:55 +1100398.Pa /etc/ssh/sshrc
Damien Miller32aa1441999-10-29 09:15:49 +1000399exists, runs
Damien Miller450a7a12000-03-26 13:04:51 +1000400it; otherwise runs xauth.
401The
Damien Miller32aa1441999-10-29 09:15:49 +1000402.Dq rc
403files are given the X11
404authentication protocol and cookie in standard input.
Damien Millerfd725cf2006-03-15 11:35:54 +1100405See
406.Sx SSHRC ,
407below.
Damien Miller32aa1441999-10-29 09:15:49 +1000408.It
409Runs user's shell or command.
410.El
Damien Millerfd725cf2006-03-15 11:35:54 +1100411.Sh SSHRC
412If the file
413.Pa ~/.ssh/rc
414exists,
415.Xr sh 1
416runs it after reading the
417environment files but before starting the user's shell or command.
418It must not produce any output on stdout; stderr must be used
419instead.
420If X11 forwarding is in use, it will receive the "proto cookie" pair in
421its standard input (and
422.Ev DISPLAY
423in its environment).
424The script must call
425.Xr xauth 1
426because
427.Nm
428will not run xauth automatically to add X11 cookies.
429.Pp
430The primary purpose of this file is to run any initialization routines
431which may be needed before the user's home directory becomes
432accessible; AFS is a particular example of such an environment.
433.Pp
434This file will probably contain some initialization code followed by
435something similar to:
436.Bd -literal -offset 3n
437if read proto cookie && [ -n "$DISPLAY" ]; then
438 if [ `echo $DISPLAY | cut -c1-10` = 'localhost:' ]; then
439 # X11UseLocalhost=yes
440 echo add unix:`echo $DISPLAY |
441 cut -c11-` $proto $cookie
442 else
443 # X11UseLocalhost=no
444 echo add $DISPLAY $proto $cookie
445 fi | xauth -q -
446fi
447.Ed
448.Pp
449If this file does not exist,
450.Pa /etc/ssh/sshrc
451is run, and if that
452does not exist either, xauth is used to add the cookie.
Damien Miller32aa1441999-10-29 09:15:49 +1000453.Sh AUTHORIZED_KEYS FILE FORMAT
Ben Lindstromf96704d2001-06-25 04:17:12 +0000454.Cm AuthorizedKeysFile
Damien Millerdcfea272006-03-15 11:31:22 +1100455specifies the file containing public keys for
456public key authentication;
457if none is specified, the default is
458.Pa ~/.ssh/authorized_keys .
Damien Miller450a7a12000-03-26 13:04:51 +1000459Each line of the file contains one
Damien Miller32aa1441999-10-29 09:15:49 +1000460key (empty lines and lines starting with a
461.Ql #
462are ignored as
Damien Miller450a7a12000-03-26 13:04:51 +1000463comments).
Damien Millerdcfea272006-03-15 11:31:22 +1100464Protocol 1 public keys consist of the following space-separated fields:
465options, bits, exponent, modulus, comment.
466Protocol 2 public key consist of:
467options, keytype, base64-encoded key, comment.
468The options field is optional;
469its presence is determined by whether the line starts
Damien Millerb83df8d2002-09-04 16:24:55 +1000470with a number or not (the options field never starts with a number).
Damien Millerdcfea272006-03-15 11:31:22 +1100471The bits, exponent, modulus, and comment fields give the RSA key for
Ben Lindstrom4dccfa52000-12-28 16:40:05 +0000472protocol version 1; the
Damien Miller32aa1441999-10-29 09:15:49 +1000473comment field is not used for anything (but may be convenient for the
474user to identify the key).
Ben Lindstrom4dccfa52000-12-28 16:40:05 +0000475For protocol version 2 the keytype is
476.Dq ssh-dss
477or
478.Dq ssh-rsa .
Damien Miller32aa1441999-10-29 09:15:49 +1000479.Pp
480Note that lines in this file are usually several hundred bytes long
Darren Tucker22cc7412004-12-06 22:47:41 +1100481(because of the size of the public key encoding) up to a limit of
4828 kilobytes, which permits DSA keys up to 8 kilobits and RSA
483keys up to 16 kilobits.
Damien Miller450a7a12000-03-26 13:04:51 +1000484You don't want to type them in; instead, copy the
Ben Lindstrom18a82ac2001-04-11 15:59:35 +0000485.Pa identity.pub ,
Damien Millerdcfea272006-03-15 11:31:22 +1100486.Pa id_dsa.pub ,
Ben Lindstrom18a82ac2001-04-11 15:59:35 +0000487or the
488.Pa id_rsa.pub
Damien Miller32aa1441999-10-29 09:15:49 +1000489file and edit it.
490.Pp
Ben Lindstrom0d0be022002-04-02 20:39:29 +0000491.Nm
492enforces a minimum RSA key modulus size for protocol 1
493and protocol 2 keys of 768 bits.
494.Pp
Damien Miller942da032000-08-18 13:59:06 +1000495The options (if present) consist of comma-separated option
Damien Miller450a7a12000-03-26 13:04:51 +1000496specifications.
497No spaces are permitted, except within double quotes.
Ben Lindstrom1c0fd092001-09-12 16:36:17 +0000498The following option specifications are supported (note
499that option keywords are case-insensitive):
Damien Miller32aa1441999-10-29 09:15:49 +1000500.Bl -tag -width Ds
Damien Miller32aa1441999-10-29 09:15:49 +1000501.It Cm command="command"
502Specifies that the command is executed whenever this key is used for
Damien Miller450a7a12000-03-26 13:04:51 +1000503authentication.
504The command supplied by the user (if any) is ignored.
Ben Lindstrom23124ea2001-09-14 23:14:25 +0000505The command is run on a pty if the client requests a pty;
Damien Miller450a7a12000-03-26 13:04:51 +1000506otherwise it is run without a tty.
Damien Millerffadc582003-02-24 11:52:26 +1100507If an 8-bit clean channel is required,
Ben Lindstrom594e2032001-09-12 18:35:30 +0000508one must not request a pty or should specify
Damien Miller33804262001-02-04 23:20:18 +1100509.Cm no-pty .
Damien Miller450a7a12000-03-26 13:04:51 +1000510A quote may be included in the command by quoting it with a backslash.
511This option might be useful
Damien Millerb83df8d2002-09-04 16:24:55 +1000512to restrict certain public keys to perform just a specific operation.
Damien Miller450a7a12000-03-26 13:04:51 +1000513An example might be a key that permits remote backups but nothing else.
Damien Miller7c24b812006-01-14 10:09:56 +1100514Note that the client may specify TCP and/or X11
Damien Miller30c3d422000-05-09 11:02:59 +1000515forwarding unless they are explicitly prohibited.
Damien Millere2754432006-07-24 14:06:47 +1000516The command originally supplied by the client is available in the
517.Ev SSH_ORIGINAL_COMMAND
518environment variable.
Ben Lindstrom20daef72001-09-20 00:54:01 +0000519Note that this option applies to shell, command or subsystem execution.
Damien Miller32aa1441999-10-29 09:15:49 +1000520.It Cm environment="NAME=value"
521Specifies that the string is to be added to the environment when
Damien Miller450a7a12000-03-26 13:04:51 +1000522logging in using this key.
523Environment variables set this way
524override other default environment values.
525Multiple options of this type are permitted.
Ben Lindstrombd9bf382002-08-20 18:54:20 +0000526Environment processing is disabled by default and is
527controlled via the
528.Cm PermitUserEnvironment
529option.
Ben Lindstrom38b951c2001-12-06 17:47:47 +0000530This option is automatically disabled if
531.Cm UseLogin
532is enabled.
Damien Miller31bdc522006-03-15 11:31:44 +1100533.It Cm from="pattern-list"
534Specifies that in addition to public key authentication, the canonical name
535of the remote host must be present in the comma-separated list of
Damien Millerc7d5b5e2006-03-15 11:55:08 +1100536patterns.
Damien Miller31bdc522006-03-15 11:31:44 +1100537The purpose
538of this option is to optionally increase security: public key authentication
539by itself does not trust the network or name servers or anything (but
540the key); however, if somebody somehow steals the key, the key
541permits an intruder to log in from anywhere in the world.
542This additional option makes using a stolen key more difficult (name
543servers and/or routers would have to be compromised in addition to
544just the key).
Damien Millerc7d5b5e2006-03-15 11:55:08 +1100545.Pp
546See
547.Sx PATTERNS
548in
549.Xr ssh_config 5
550for more information on patterns.
Damien Miller31bdc522006-03-15 11:31:44 +1100551.It Cm no-agent-forwarding
552Forbids authentication agent forwarding when this key is used for
553authentication.
Damien Miller32aa1441999-10-29 09:15:49 +1000554.It Cm no-port-forwarding
Damien Miller7c24b812006-01-14 10:09:56 +1100555Forbids TCP forwarding when this key is used for authentication.
Damien Miller450a7a12000-03-26 13:04:51 +1000556Any port forward requests by the client will return an error.
Damien Miller208f1ed2006-03-15 11:56:03 +1100557This might be used, e.g. in connection with the
Damien Miller32aa1441999-10-29 09:15:49 +1000558.Cm command
559option.
Damien Miller31bdc522006-03-15 11:31:44 +1100560.It Cm no-pty
561Prevents tty allocation (a request to allocate a pty will fail).
Damien Miller95e80952008-03-27 11:03:05 +1100562.It Cm no-user-rc
Damien Miller13ba9c22008-04-03 20:52:51 +1100563Disables execution of
Damien Miller95e80952008-03-27 11:03:05 +1100564.Pa ~/.ssh/rc .
Damien Miller32aa1441999-10-29 09:15:49 +1000565.It Cm no-X11-forwarding
566Forbids X11 forwarding when this key is used for authentication.
567Any X11 forward requests by the client will return an error.
Damien Millera243fde2001-03-19 23:16:08 +1100568.It Cm permitopen="host:port"
Ben Lindstrom24643222001-06-25 05:08:11 +0000569Limit local
Damien Millera243fde2001-03-19 23:16:08 +1100570.Li ``ssh -L''
Ben Lindstrom4b3564e2001-04-10 02:41:56 +0000571port forwarding such that it may only connect to the specified host and
Ben Lindstromd71ba572001-09-12 18:03:31 +0000572port.
573IPv6 addresses can be specified with an alternative syntax:
Darren Tucker1f203942003-10-15 15:50:42 +1000574.Ar host Ns / Ns Ar port .
Ben Lindstromd71ba572001-09-12 18:03:31 +0000575Multiple
Damien Millera243fde2001-03-19 23:16:08 +1100576.Cm permitopen
Damien Millerfbf486b2003-05-23 18:44:23 +1000577options may be applied separated by commas.
578No pattern matching is performed on the specified hostnames,
579they must be literal domains or addresses.
Damien Millerd27b9472005-12-13 19:29:02 +1100580.It Cm tunnel="n"
581Force a
582.Xr tun 4
583device on the server.
584Without this option, the next available device will be used if
585the client requests a tunnel.
Damien Miller32aa1441999-10-29 09:15:49 +1000586.El
Damien Miller32aa1441999-10-29 09:15:49 +1000587.Pp
Damien Miller7d2ef022006-03-15 11:32:06 +1100588An example authorized_keys file:
Damien Millerc8f61cf2006-03-15 11:33:25 +1100589.Bd -literal -offset 3n
Damien Miller7d2ef022006-03-15 11:32:06 +1100590# Comments allowed at start of line
591ssh-rsa AAAAB3Nza...LiPk== user@example.net
Damien Millerc8f61cf2006-03-15 11:33:25 +1100592from="*.sales.example.net,!pc.sales.example.net" ssh-rsa
593AAAAB2...19Q== john@example.net
594command="dump /home",no-pty,no-port-forwarding ssh-dss
595AAAAC3...51R== example.net
596permitopen="192.0.2.1:80",permitopen="192.0.2.2:25" ssh-dss
597AAAAB5...21S==
598tunnel="0",command="sh /etc/netstart tun0" ssh-rsa AAAA...==
599jane@example.net
Damien Miller7d2ef022006-03-15 11:32:06 +1100600.Ed
Damien Miller32aa1441999-10-29 09:15:49 +1000601.Sh SSH_KNOWN_HOSTS FILE FORMAT
Damien Miller22c77262000-04-13 12:26:34 +1000602The
Damien Millerffadc582003-02-24 11:52:26 +1100603.Pa /etc/ssh/ssh_known_hosts
Damien Miller22c77262000-04-13 12:26:34 +1000604and
Damien Miller167ea5d2005-05-26 12:04:02 +1000605.Pa ~/.ssh/known_hosts
Damien Miller450a7a12000-03-26 13:04:51 +1000606files contain host public keys for all known hosts.
607The global file should
608be prepared by the administrator (optional), and the per-user file is
Damien Miller9a7f2012006-03-15 11:32:42 +1100609maintained automatically: whenever the user connects from an unknown host,
Damien Miller450a7a12000-03-26 13:04:51 +1000610its key is added to the per-user file.
Damien Miller32aa1441999-10-29 09:15:49 +1000611.Pp
612Each line in these files contains the following fields: hostnames,
Damien Miller450a7a12000-03-26 13:04:51 +1000613bits, exponent, modulus, comment.
614The fields are separated by spaces.
Damien Miller32aa1441999-10-29 09:15:49 +1000615.Pp
Damien Miller31554322003-05-14 13:44:58 +1000616Hostnames is a comma-separated list of patterns
Damien Miller9a7f2012006-03-15 11:32:42 +1100617.Pf ( Ql *
Damien Millerfbf486b2003-05-23 18:44:23 +1000618and
619.Ql \&?
Damien Miller049245d2003-05-14 13:44:42 +1000620act as
Damien Miller32aa1441999-10-29 09:15:49 +1000621wildcards); each pattern in turn is matched against the canonical host
622name (when authenticating a client) or against the user-supplied
Damien Miller450a7a12000-03-26 13:04:51 +1000623name (when authenticating a server).
624A pattern may also be preceded by
Damien Miller049245d2003-05-14 13:44:42 +1000625.Ql \&!
Damien Miller32aa1441999-10-29 09:15:49 +1000626to indicate negation: if the host name matches a negated
627pattern, it is not accepted (by that line) even if it matched another
628pattern on the line.
Darren Tuckerda345532006-07-10 23:04:19 +1000629A hostname or address may optionally be enclosed within
630.Ql \&[
631and
632.Ql \&]
633brackets then followed by
634.Ql \&:
Darren Tucker11318472006-07-12 22:07:59 +1000635and a non-standard port number.
Damien Miller32aa1441999-10-29 09:15:49 +1000636.Pp
Damien Millere1776152005-03-01 21:47:37 +1100637Alternately, hostnames may be stored in a hashed form which hides host names
Damien Miller718fd4b2005-03-02 12:03:23 +1100638and addresses should the file's contents be disclosed.
639Hashed hostnames start with a
640.Ql |
Damien Millere1776152005-03-01 21:47:37 +1100641character.
642Only one hashed hostname may appear on a single line and none of the above
643negation or wildcard operators may be applied.
644.Pp
Damien Millere247cc42000-05-07 12:03:14 +1000645Bits, exponent, and modulus are taken directly from the RSA host key; they
Damien Miller9a7f2012006-03-15 11:32:42 +1100646can be obtained, for example, from
Damien Miller05eda432002-02-10 18:32:28 +1100647.Pa /etc/ssh/ssh_host_key.pub .
Damien Miller32aa1441999-10-29 09:15:49 +1000648The optional comment field continues to the end of the line, and is not used.
649.Pp
650Lines starting with
651.Ql #
652and empty lines are ignored as comments.
653.Pp
654When performing host authentication, authentication is accepted if any
Damien Miller450a7a12000-03-26 13:04:51 +1000655matching line has the proper key.
656It is thus permissible (but not
Damien Miller32aa1441999-10-29 09:15:49 +1000657recommended) to have several lines or different host keys for the same
Damien Miller450a7a12000-03-26 13:04:51 +1000658names.
659This will inevitably happen when short forms of host names
660from different domains are put in the file.
661It is possible
Damien Miller32aa1441999-10-29 09:15:49 +1000662that the files contain conflicting information; authentication is
663accepted if valid information can be found from either file.
664.Pp
665Note that the lines in these files are typically hundreds of characters
666long, and you definitely don't want to type in the host keys by hand.
667Rather, generate them by a script
Damien Miller22c77262000-04-13 12:26:34 +1000668or by taking
Damien Miller05eda432002-02-10 18:32:28 +1100669.Pa /etc/ssh/ssh_host_key.pub
Damien Miller32aa1441999-10-29 09:15:49 +1000670and adding the host names at the front.
Damien Millercc00f5e2006-03-15 11:33:00 +1100671.Pp
672An example ssh_known_hosts file:
673.Bd -literal -offset 3n
674# Comments allowed at start of line
675closenet,...,192.0.2.53 1024 37 159...93 closenet.example.net
676cvs.example.net,192.0.2.10 ssh-rsa AAAA1234.....=
Damien Millere1776152005-03-01 21:47:37 +1100677# A hashed hostname
678|1|JfKTdBh7rNbXkVAQCRp4OQoPfmI=|USECr3SWf1JUPsms5AqfD5QfxkM= ssh-rsa
679AAAA1234.....=
680.Ed
Damien Miller32aa1441999-10-29 09:15:49 +1000681.Sh FILES
Damien Millerd8702e82006-03-15 11:33:56 +1100682.Bl -tag -width Ds -compact
683.It ~/.hushlogin
Damien Miller70a908e2005-03-01 21:17:09 +1100684This file is used to suppress printing the last login time and
685.Pa /etc/motd ,
686if
687.Cm PrintLastLog
688and
689.Cm PrintMotd ,
690respectively,
691are enabled.
692It does not suppress printing of the banner specified by
693.Cm Banner .
Damien Millerd8702e82006-03-15 11:33:56 +1100694.Pp
695.It ~/.rhosts
Damien Milleradc35b92006-03-15 11:35:27 +1100696This file is used for host-based authentication (see
697.Xr ssh 1
698for more information).
699On some machines this file may need to be
700world-readable if the user's home directory is on an NFS partition,
701because
702.Nm
703reads it as root.
704Additionally, this file must be owned by the user,
705and must not have write permissions for anyone else.
706The recommended
707permission for most machines is read/write for the user, and not
Damien Miller32aa1441999-10-29 09:15:49 +1000708accessible by others.
709.Pp
Damien Millerd8702e82006-03-15 11:33:56 +1100710.It ~/.shosts
Damien Milleradc35b92006-03-15 11:35:27 +1100711This file is used in exactly the same way as
712.Pa .rhosts ,
713but allows host-based authentication without permitting login with
714rlogin/rsh.
Damien Miller32aa1441999-10-29 09:15:49 +1000715.Pp
Damien Miller520e6152008-02-10 22:46:22 +1100716.It ~/.ssh/
717This directory is the default location for all user-specific configuration
718and authentication information.
719There is no general requirement to keep the entire contents of this directory
720secret, but the recommended permissions are read/write/execute for the user,
721and not accessible by others.
722.Pp
Damien Millerd8702e82006-03-15 11:33:56 +1100723.It ~/.ssh/authorized_keys
Damien Milleradc35b92006-03-15 11:35:27 +1100724Lists the public keys (RSA/DSA) that can be used for logging in as this user.
Damien Millerd8702e82006-03-15 11:33:56 +1100725The format of this file is described above.
Damien Miller5d43d492006-08-30 11:07:00 +1000726The content of the file is not highly sensitive, but the recommended
Damien Milleradc35b92006-03-15 11:35:27 +1100727permissions are read/write for the user, and not accessible by others.
Damien Miller32aa1441999-10-29 09:15:49 +1000728.Pp
Damien Miller5d43d492006-08-30 11:07:00 +1000729If this file, the
730.Pa ~/.ssh
731directory, or the user's home directory are writable
732by other users, then the file could be modified or replaced by unauthorized
733users.
734In this case,
735.Nm
736will not allow it to be used unless the
737.Cm StrictModes
738option has been set to
739.Dq no .
740The recommended permissions can be set by executing
741.Dq chmod go-w ~/ ~/.ssh ~/.ssh/authorized_keys .
742.Pp
Damien Millerd8702e82006-03-15 11:33:56 +1100743.It ~/.ssh/environment
Damien Miller450a7a12000-03-26 13:04:51 +1000744This file is read into the environment at login (if it exists).
745It can only contain empty lines, comment lines (that start with
Damien Miller32aa1441999-10-29 09:15:49 +1000746.Ql # ) ,
Damien Miller450a7a12000-03-26 13:04:51 +1000747and assignment lines of the form name=value.
748The file should be writable
Damien Miller32aa1441999-10-29 09:15:49 +1000749only by the user; it need not be readable by anyone else.
Ben Lindstrombd9bf382002-08-20 18:54:20 +0000750Environment processing is disabled by default and is
751controlled via the
752.Cm PermitUserEnvironment
753option.
Damien Millerd8702e82006-03-15 11:33:56 +1100754.Pp
755.It ~/.ssh/known_hosts
Damien Milleradc35b92006-03-15 11:35:27 +1100756Contains a list of host keys for all hosts the user has logged into
757that are not already in the systemwide list of known host keys.
758The format of this file is described above.
759This file should be writable only by root/the owner and
Damien Millerd8702e82006-03-15 11:33:56 +1100760can, but need not be, world-readable.
761.Pp
762.It ~/.ssh/rc
Damien Millerfd725cf2006-03-15 11:35:54 +1100763Contains initialization routines to be run before
764the user's home directory becomes accessible.
Damien Miller32aa1441999-10-29 09:15:49 +1000765This file should be writable only by the user, and need not be
766readable by anyone else.
Damien Millerd8702e82006-03-15 11:33:56 +1100767.Pp
768.It /etc/hosts.allow
769.It /etc/hosts.deny
770Access controls that should be enforced by tcp-wrappers are defined here.
771Further details are described in
772.Xr hosts_access 5 .
773.Pp
774.It /etc/hosts.equiv
Damien Miller445121f2006-03-15 11:36:18 +1100775This file is for host-based authentication (see
776.Xr ssh 1 ) .
777It should only be writable by root.
Damien Millerd8702e82006-03-15 11:33:56 +1100778.Pp
779.It /etc/moduli
780Contains Diffie-Hellman groups used for the "Diffie-Hellman Group Exchange".
781The file format is described in
782.Xr moduli 5 .
783.Pp
784.It /etc/motd
785See
786.Xr motd 5 .
787.Pp
788.It /etc/nologin
789If this file exists,
790.Nm
791refuses to let anyone except root log in.
792The contents of the file
793are displayed to anyone trying to log in, and non-root connections are
794refused.
795The file should be world-readable.
796.Pp
797.It /etc/shosts.equiv
Damien Miller445121f2006-03-15 11:36:18 +1100798This file is used in exactly the same way as
799.Pa hosts.equiv ,
800but allows host-based authentication without permitting login with
801rlogin/rsh.
Damien Millerd8702e82006-03-15 11:33:56 +1100802.Pp
803.It /etc/ssh/ssh_host_key
804.It /etc/ssh/ssh_host_dsa_key
805.It /etc/ssh/ssh_host_rsa_key
806These three files contain the private parts of the host keys.
807These files should only be owned by root, readable only by root, and not
808accessible to others.
809Note that
810.Nm
Damien Milleredd03752006-03-15 11:36:45 +1100811does not start if these files are group/world-accessible.
Damien Millerd8702e82006-03-15 11:33:56 +1100812.Pp
813.It /etc/ssh/ssh_host_key.pub
814.It /etc/ssh/ssh_host_dsa_key.pub
815.It /etc/ssh/ssh_host_rsa_key.pub
816These three files contain the public parts of the host keys.
817These files should be world-readable but writable only by
818root.
819Their contents should match the respective private parts.
820These files are not
821really used for anything; they are provided for the convenience of
822the user so their contents can be copied to known hosts files.
823These files are created using
824.Xr ssh-keygen 1 .
825.Pp
Darren Tucker04354b92007-03-21 20:46:54 +1100826.It /etc/ssh/ssh_known_hosts
827Systemwide list of known host keys.
828This file should be prepared by the
829system administrator to contain the public host keys of all machines in the
830organization.
831The format of this file is described above.
832This file should be writable only by root/the owner and
833should be world-readable.
834.Pp
Damien Millerd8702e82006-03-15 11:33:56 +1100835.It /etc/ssh/sshd_config
836Contains configuration data for
837.Nm sshd .
838The file format and configuration options are described in
839.Xr sshd_config 5 .
840.Pp
841.It /etc/ssh/sshrc
Damien Millerfd725cf2006-03-15 11:35:54 +1100842Similar to
843.Pa ~/.ssh/rc ,
844it can be used to specify
Damien Miller450a7a12000-03-26 13:04:51 +1000845machine-specific login-time initializations globally.
846This file should be writable only by root, and should be world-readable.
Damien Millerd8702e82006-03-15 11:33:56 +1100847.Pp
848.It /var/empty
849.Xr chroot 2
850directory used by
851.Nm
852during privilege separation in the pre-authentication phase.
853The directory should not contain any files and must be owned by root
854and not group or world-writable.
855.Pp
856.It /var/run/sshd.pid
857Contains the process ID of the
858.Nm
859listening for connections (if there are several daemons running
860concurrently for different ports, this contains the process ID of the one
861started last).
862The content of this file is not sensitive; it can be world-readable.
Damien Miller37023962000-07-11 17:31:38 +1000863.El
Damien Miller32aa1441999-10-29 09:15:49 +1000864.Sh SEE ALSO
Damien Miller32aa1441999-10-29 09:15:49 +1000865.Xr scp 1 ,
Damien Miller33804262001-02-04 23:20:18 +1100866.Xr sftp 1 ,
Damien Miller32aa1441999-10-29 09:15:49 +1000867.Xr ssh 1 ,
868.Xr ssh-add 1 ,
869.Xr ssh-agent 1 ,
870.Xr ssh-keygen 1 ,
Darren Tucker04354b92007-03-21 20:46:54 +1100871.Xr ssh-keyscan 1 ,
Darren Tucker1f203942003-10-15 15:50:42 +1000872.Xr chroot 2 ,
873.Xr hosts_access 5 ,
Ben Lindstromc8e29ce2001-08-06 20:55:28 +0000874.Xr login.conf 5 ,
875.Xr moduli 5 ,
Ben Lindstrom9f049032002-06-21 00:59:05 +0000876.Xr sshd_config 5 ,
Darren Tucker1f203942003-10-15 15:50:42 +1000877.Xr inetd 8 ,
Ben Lindstromd2bf0d62001-06-25 04:10:54 +0000878.Xr sftp-server 8
Damien Millerf1ce5052003-06-11 22:04:39 +1000879.Sh AUTHORS
880OpenSSH is a derivative of the original and free
881ssh 1.2.12 release by Tatu Ylonen.
882Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos,
883Theo de Raadt and Dug Song
884removed many bugs, re-added newer features and
885created OpenSSH.
886Markus Friedl contributed the support for SSH
887protocol versions 1.5 and 2.0.
888Niels Provos and Markus Friedl contributed support
889for privilege separation.
Damien Millerc47d7e92006-03-15 11:27:20 +1100890.Sh CAVEATS
891System security is not improved unless
892.Nm rshd ,
893.Nm rlogind ,
894and
895.Nm rexecd
896are disabled (thus completely disabling
897.Xr rlogin
898and
899.Xr rsh
900into the machine).