Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 1 | .\" -*- nroff -*- |
| 2 | .\" |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 3 | .\" Author: Tatu Ylonen <ylo@cs.hut.fi> |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 4 | .\" Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
| 5 | .\" All rights reserved |
| 6 | .\" |
Damien Miller | e4340be | 2000-09-16 13:29:08 +1100 | [diff] [blame] | 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". |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 12 | .\" |
Ben Lindstrom | 92a2e38 | 2001-03-05 06:59:27 +0000 | [diff] [blame] | 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. |
Damien Miller | e4340be | 2000-09-16 13:29:08 +1100 | [diff] [blame] | 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. |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 36 | .\" |
Darren Tucker | 7499b0c | 2008-07-02 22:35:43 +1000 | [diff] [blame] | 37 | .\" $OpenBSD: sshd.8,v 1.246 2008/07/02 02:24:18 djm Exp $ |
| 38 | .Dd $Mdocdate: July 2 2008 $ |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 39 | .Dt SSHD 8 |
| 40 | .Os |
| 41 | .Sh NAME |
| 42 | .Nm sshd |
Ben Lindstrom | c65e6a0 | 2001-04-23 13:02:16 +0000 | [diff] [blame] | 43 | .Nd OpenSSH SSH daemon |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 44 | .Sh SYNOPSIS |
| 45 | .Nm sshd |
Damien Miller | ffadc58 | 2003-02-24 11:52:26 +1100 | [diff] [blame] | 46 | .Bk -words |
Darren Tucker | e7f3f75 | 2008-06-10 23:06:01 +1000 | [diff] [blame] | 47 | .Op Fl 46DdeiqTt |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 48 | .Op Fl b Ar bits |
Darren Tucker | e7140f2 | 2008-06-10 23:01:51 +1000 | [diff] [blame] | 49 | .Op Fl C Ar connection_spec |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 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 |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 54 | .Op Fl o Ar option |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 55 | .Op Fl p Ar port |
Damien Miller | 942da03 | 2000-08-18 13:59:06 +1000 | [diff] [blame] | 56 | .Op Fl u Ar len |
Damien Miller | ffadc58 | 2003-02-24 11:52:26 +1100 | [diff] [blame] | 57 | .Ek |
Damien Miller | 22c7726 | 2000-04-13 12:26:34 +1000 | [diff] [blame] | 58 | .Sh DESCRIPTION |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 59 | .Nm |
Damien Miller | 99cc4a8 | 2006-01-31 21:45:53 +1100 | [diff] [blame] | 60 | (OpenSSH Daemon) is the daemon program for |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 61 | .Xr ssh 1 . |
Darren Tucker | 04354b9 | 2007-03-21 20:46:54 +1100 | [diff] [blame] | 62 | Together these programs replace |
| 63 | .Xr rlogin 1 |
| 64 | and |
| 65 | .Xr rsh 1 , |
| 66 | and provide secure encrypted communications between two untrusted hosts |
Damien Miller | 450a7a1 | 2000-03-26 13:04:51 +1000 | [diff] [blame] | 67 | over an insecure network. |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 68 | .Pp |
| 69 | .Nm |
Damien Miller | 99cc4a8 | 2006-01-31 21:45:53 +1100 | [diff] [blame] | 70 | listens for connections from clients. |
Damien Miller | 22c7726 | 2000-04-13 12:26:34 +1000 | [diff] [blame] | 71 | It is normally started at boot from |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 72 | .Pa /etc/rc . |
| 73 | It forks a new |
Damien Miller | 450a7a1 | 2000-03-26 13:04:51 +1000 | [diff] [blame] | 74 | daemon for each incoming connection. |
| 75 | The forked daemons handle |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 76 | key exchange, encryption, authentication, command execution, |
| 77 | and data exchange. |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 78 | .Pp |
| 79 | .Nm |
Darren Tucker | 1f20394 | 2003-10-15 15:50:42 +1000 | [diff] [blame] | 80 | can be configured using command-line options or a configuration file |
| 81 | (by default |
Damien Miller | 99cc4a8 | 2006-01-31 21:45:53 +1100 | [diff] [blame] | 82 | .Xr sshd_config 5 ) ; |
| 83 | command-line options override values specified in the |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 84 | configuration file. |
Damien Miller | 6162d12 | 1999-11-21 13:23:52 +1100 | [diff] [blame] | 85 | .Nm |
| 86 | rereads its configuration file when it receives a hangup signal, |
Ben Lindstrom | 49a098d | 2001-03-05 06:55:18 +0000 | [diff] [blame] | 87 | .Dv SIGHUP , |
Damien Miller | 208f1ed | 2006-03-15 11:56:03 +1100 | [diff] [blame] | 88 | by executing itself with the name and options it was started with, e.g.\& |
Ben Lindstrom | 49a098d | 2001-03-05 06:55:18 +0000 | [diff] [blame] | 89 | .Pa /usr/sbin/sshd . |
Damien Miller | 6162d12 | 1999-11-21 13:23:52 +1100 | [diff] [blame] | 90 | .Pp |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 91 | The options are as follows: |
| 92 | .Bl -tag -width Ds |
Darren Tucker | 1f20394 | 2003-10-15 15:50:42 +1000 | [diff] [blame] | 93 | .It Fl 4 |
| 94 | Forces |
| 95 | .Nm |
| 96 | to use IPv4 addresses only. |
| 97 | .It Fl 6 |
| 98 | Forces |
| 99 | .Nm |
| 100 | to use IPv6 addresses only. |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 101 | .It Fl b Ar bits |
Ben Lindstrom | c65e6a0 | 2001-04-23 13:02:16 +0000 | [diff] [blame] | 102 | Specifies the number of bits in the ephemeral protocol version 1 |
Darren Tucker | 7499b0c | 2008-07-02 22:35:43 +1000 | [diff] [blame] | 103 | server key (default 1024). |
Darren Tucker | e7f3f75 | 2008-06-10 23:06:01 +1000 | [diff] [blame] | 104 | .It Fl C Ar connection_spec |
| 105 | Specify the connection parameters to use for the |
| 106 | .Fl T |
| 107 | extended test mode. |
| 108 | If provided, any |
| 109 | .Cm Match |
| 110 | directives in the configuration file |
| 111 | that would apply to the specified user, host, and address will be set before |
| 112 | the configuration is written to standard output. |
| 113 | The connection parameters are supplied as keyword=value pairs. |
| 114 | The keywords are |
| 115 | .Dq user , |
| 116 | .Dq host , |
| 117 | and |
| 118 | .Dq addr . |
| 119 | All are required and may be supplied in any order, either with multiple |
| 120 | .Fl C |
| 121 | options or as a comma-separated list. |
Darren Tucker | 1f20394 | 2003-10-15 15:50:42 +1000 | [diff] [blame] | 122 | .It Fl D |
| 123 | When this option is specified, |
| 124 | .Nm |
| 125 | will not detach and does not become a daemon. |
| 126 | This allows easy monitoring of |
| 127 | .Nm sshd . |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 128 | .It Fl d |
Damien Miller | 450a7a1 | 2000-03-26 13:04:51 +1000 | [diff] [blame] | 129 | Debug mode. |
| 130 | The server sends verbose debug output to the system |
| 131 | log, and does not put itself in the background. |
| 132 | The server also will not fork and will only process one connection. |
| 133 | This option is only intended for debugging for the server. |
Damien Miller | ffadc58 | 2003-02-24 11:52:26 +1100 | [diff] [blame] | 134 | Multiple |
| 135 | .Fl d |
| 136 | options increase the debugging level. |
Damien Miller | 874d77b | 2000-10-14 16:23:11 +1100 | [diff] [blame] | 137 | Maximum is 3. |
Ben Lindstrom | c65e6a0 | 2001-04-23 13:02:16 +0000 | [diff] [blame] | 138 | .It Fl e |
| 139 | When this option is specified, |
| 140 | .Nm |
| 141 | will send the output to the standard error instead of the system log. |
Darren Tucker | 04354b9 | 2007-03-21 20:46:54 +1100 | [diff] [blame] | 142 | .It Fl f Ar config_file |
Damien Miller | 450a7a1 | 2000-03-26 13:04:51 +1000 | [diff] [blame] | 143 | Specifies the name of the configuration file. |
| 144 | The default is |
Damien Miller | 05eda43 | 2002-02-10 18:32:28 +1100 | [diff] [blame] | 145 | .Pa /etc/ssh/sshd_config . |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 146 | .Nm |
| 147 | refuses to start if there is no configuration file. |
| 148 | .It Fl g Ar login_grace_time |
| 149 | Gives the grace time for clients to authenticate themselves (default |
Damien Miller | c134863 | 2002-09-05 14:35:14 +1000 | [diff] [blame] | 150 | 120 seconds). |
Damien Miller | 450a7a1 | 2000-03-26 13:04:51 +1000 | [diff] [blame] | 151 | If the client fails to authenticate the user within |
| 152 | this many seconds, the server disconnects and exits. |
| 153 | A value of zero indicates no limit. |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 154 | .It Fl h Ar host_key_file |
Damien Miller | 7fc2373 | 2002-01-22 23:19:11 +1100 | [diff] [blame] | 155 | Specifies a file from which a host key is read. |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 156 | This option must be given if |
| 157 | .Nm |
| 158 | is not run as root (as the normal |
Damien Miller | 7fc2373 | 2002-01-22 23:19:11 +1100 | [diff] [blame] | 159 | host key files are normally not readable by anyone but root). |
| 160 | The default is |
Damien Miller | 05eda43 | 2002-02-10 18:32:28 +1100 | [diff] [blame] | 161 | .Pa /etc/ssh/ssh_host_key |
Damien Miller | 7fc2373 | 2002-01-22 23:19:11 +1100 | [diff] [blame] | 162 | for protocol version 1, and |
Damien Miller | 05eda43 | 2002-02-10 18:32:28 +1100 | [diff] [blame] | 163 | .Pa /etc/ssh/ssh_host_rsa_key |
Damien Miller | 7fc2373 | 2002-01-22 23:19:11 +1100 | [diff] [blame] | 164 | and |
Damien Miller | 05eda43 | 2002-02-10 18:32:28 +1100 | [diff] [blame] | 165 | .Pa /etc/ssh/ssh_host_dsa_key |
Damien Miller | 7fc2373 | 2002-01-22 23:19:11 +1100 | [diff] [blame] | 166 | for protocol version 2. |
Ben Lindstrom | 4dccfa5 | 2000-12-28 16:40:05 +0000 | [diff] [blame] | 167 | It is possible to have multiple host key files for |
Ben Lindstrom | c65e6a0 | 2001-04-23 13:02:16 +0000 | [diff] [blame] | 168 | the different protocol versions and host key algorithms. |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 169 | .It Fl i |
| 170 | Specifies that |
| 171 | .Nm |
Damien Miller | ffadc58 | 2003-02-24 11:52:26 +1100 | [diff] [blame] | 172 | is being run from |
| 173 | .Xr inetd 8 . |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 174 | .Nm |
| 175 | is normally not run |
| 176 | from inetd because it needs to generate the server key before it can |
Damien Miller | 450a7a1 | 2000-03-26 13:04:51 +1000 | [diff] [blame] | 177 | respond to the client, and this may take tens of seconds. |
| 178 | Clients would have to wait too long if the key was regenerated every time. |
Damien Miller | 208f1ed | 2006-03-15 11:56:03 +1100 | [diff] [blame] | 179 | However, with small key sizes (e.g. 512) using |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 180 | .Nm |
| 181 | from inetd may |
| 182 | be feasible. |
| 183 | .It Fl k Ar key_gen_time |
Ben Lindstrom | c65e6a0 | 2001-04-23 13:02:16 +0000 | [diff] [blame] | 184 | Specifies how often the ephemeral protocol version 1 server key is |
| 185 | regenerated (default 3600 seconds, or one hour). |
Damien Miller | 450a7a1 | 2000-03-26 13:04:51 +1000 | [diff] [blame] | 186 | The motivation for regenerating the key fairly |
Darren Tucker | 1f20394 | 2003-10-15 15:50:42 +1000 | [diff] [blame] | 187 | often is that the key is not stored anywhere, and after about an hour |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 188 | it becomes impossible to recover the key for decrypting intercepted |
| 189 | communications even if the machine is cracked into or physically |
Damien Miller | 450a7a1 | 2000-03-26 13:04:51 +1000 | [diff] [blame] | 190 | seized. |
| 191 | A value of zero indicates that the key will never be regenerated. |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 192 | .It Fl o Ar option |
| 193 | Can be used to give options in the format used in the configuration file. |
| 194 | This is useful for specifying options for which there is no separate |
| 195 | command-line flag. |
Darren Tucker | 1f20394 | 2003-10-15 15:50:42 +1000 | [diff] [blame] | 196 | For full details of the options, and their values, see |
| 197 | .Xr sshd_config 5 . |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 198 | .It Fl p Ar port |
| 199 | Specifies the port on which the server listens for connections |
| 200 | (default 22). |
Damien Miller | 7d1ded4 | 2002-01-22 23:09:41 +1100 | [diff] [blame] | 201 | Multiple port options are permitted. |
Damien Miller | d7f308f | 2005-12-24 14:55:16 +1100 | [diff] [blame] | 202 | Ports specified in the configuration file with the |
| 203 | .Cm Port |
| 204 | option are ignored when a command-line port is specified. |
| 205 | Ports specified using the |
| 206 | .Cm ListenAddress |
| 207 | option override command-line ports. |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 208 | .It Fl q |
Damien Miller | 450a7a1 | 2000-03-26 13:04:51 +1000 | [diff] [blame] | 209 | Quiet mode. |
| 210 | Nothing is sent to the system log. |
| 211 | Normally the beginning, |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 212 | authentication, and termination of each connection is logged. |
Darren Tucker | e7140f2 | 2008-06-10 23:01:51 +1000 | [diff] [blame] | 213 | .It Fl T |
| 214 | Extended test mode. |
| 215 | Check the validity of the configuration file, output the effective configuration |
| 216 | to stdout and then exit. |
| 217 | Optionally, |
| 218 | .Cm Match |
| 219 | rules may be applied by specifying the connection parameters using one or more |
| 220 | .Fl C |
| 221 | options. |
Darren Tucker | e7f3f75 | 2008-06-10 23:06:01 +1000 | [diff] [blame] | 222 | .It Fl t |
| 223 | Test mode. |
| 224 | Only check the validity of the configuration file and sanity of the keys. |
| 225 | This is useful for updating |
| 226 | .Nm |
| 227 | reliably as configuration options may change. |
Damien Miller | 942da03 | 2000-08-18 13:59:06 +1000 | [diff] [blame] | 228 | .It Fl u Ar len |
| 229 | This option is used to specify the size of the field |
| 230 | in the |
| 231 | .Li utmp |
| 232 | structure that holds the remote host name. |
| 233 | If the resolved host name is longer than |
| 234 | .Ar len , |
| 235 | the dotted decimal value will be used instead. |
| 236 | This allows hosts with very long host names that |
| 237 | overflow this field to still be uniquely identified. |
| 238 | Specifying |
| 239 | .Fl u0 |
| 240 | indicates that only dotted decimal addresses |
| 241 | should be put into the |
| 242 | .Pa utmp |
| 243 | file. |
Ben Lindstrom | 6f672c0 | 2001-09-12 17:51:55 +0000 | [diff] [blame] | 244 | .Fl u0 |
Damien Miller | ffadc58 | 2003-02-24 11:52:26 +1100 | [diff] [blame] | 245 | may also be used to prevent |
Ben Lindstrom | 6f672c0 | 2001-09-12 17:51:55 +0000 | [diff] [blame] | 246 | .Nm |
| 247 | from making DNS requests unless the authentication |
| 248 | mechanism or configuration requires it. |
| 249 | Authentication mechanisms that may require DNS include |
Ben Lindstrom | 6f672c0 | 2001-09-12 17:51:55 +0000 | [diff] [blame] | 250 | .Cm RhostsRSAAuthentication , |
Damien Miller | 2ac0577 | 2006-02-01 22:05:42 +1100 | [diff] [blame] | 251 | .Cm HostbasedAuthentication , |
Ben Lindstrom | 6f672c0 | 2001-09-12 17:51:55 +0000 | [diff] [blame] | 252 | and using a |
| 253 | .Cm from="pattern-list" |
| 254 | option in a key file. |
Ben Lindstrom | ea03db9 | 2002-03-05 01:38:57 +0000 | [diff] [blame] | 255 | Configuration options that require DNS include using a |
| 256 | USER@HOST pattern in |
| 257 | .Cm AllowUsers |
| 258 | or |
| 259 | .Cm DenyUsers . |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 260 | .El |
Damien Miller | 8bbdf90 | 2006-02-01 22:05:25 +1100 | [diff] [blame] | 261 | .Sh AUTHENTICATION |
| 262 | The OpenSSH SSH daemon supports SSH protocols 1 and 2. |
| 263 | Both protocols are supported by default, |
| 264 | though this can be changed via the |
| 265 | .Cm Protocol |
| 266 | option in |
| 267 | .Xr sshd_config 5 . |
| 268 | Protocol 2 supports both RSA and DSA keys; |
| 269 | protocol 1 only supports RSA keys. |
| 270 | For both protocols, |
| 271 | each host has a host-specific key, |
| 272 | normally 2048 bits, |
| 273 | used to identify the host. |
Damien Miller | 99cc4a8 | 2006-01-31 21:45:53 +1100 | [diff] [blame] | 274 | .Pp |
Damien Miller | 8bbdf90 | 2006-02-01 22:05:25 +1100 | [diff] [blame] | 275 | Forward security for protocol 1 is provided through |
| 276 | an additional server key, |
| 277 | normally 768 bits, |
| 278 | generated when the server starts. |
Damien Miller | 99cc4a8 | 2006-01-31 21:45:53 +1100 | [diff] [blame] | 279 | This key is normally regenerated every hour if it has been used, and |
| 280 | is never stored on disk. |
Damien Miller | 99cc4a8 | 2006-01-31 21:45:53 +1100 | [diff] [blame] | 281 | Whenever a client connects, the daemon responds with its public |
| 282 | host and server keys. |
| 283 | The client compares the |
| 284 | RSA host key against its own database to verify that it has not changed. |
| 285 | The client then generates a 256-bit random number. |
| 286 | It encrypts this |
| 287 | random number using both the host key and the server key, and sends |
| 288 | the encrypted number to the server. |
| 289 | Both sides then use this |
| 290 | random number as a session key which is used to encrypt all further |
| 291 | communications in the session. |
| 292 | The rest of the session is encrypted |
| 293 | using a conventional cipher, currently Blowfish or 3DES, with 3DES |
| 294 | being used by default. |
| 295 | The client selects the encryption algorithm |
| 296 | to use from those offered by the server. |
| 297 | .Pp |
Damien Miller | 8bbdf90 | 2006-02-01 22:05:25 +1100 | [diff] [blame] | 298 | For protocol 2, |
| 299 | forward security is provided through a Diffie-Hellman key agreement. |
| 300 | This key agreement results in a shared session key. |
| 301 | The rest of the session is encrypted using a symmetric cipher, currently |
| 302 | 128-bit AES, Blowfish, 3DES, CAST128, Arcfour, 192-bit AES, or 256-bit AES. |
| 303 | The client selects the encryption algorithm |
| 304 | to use from those offered by the server. |
| 305 | Additionally, session integrity is provided |
| 306 | through a cryptographic message authentication code |
Damien Miller | e45796f | 2007-06-11 14:01:42 +1000 | [diff] [blame] | 307 | (hmac-md5, hmac-sha1, umac-64 or hmac-ripemd160). |
Damien Miller | 8bbdf90 | 2006-02-01 22:05:25 +1100 | [diff] [blame] | 308 | .Pp |
| 309 | Finally, the server and the client enter an authentication dialog. |
Damien Miller | 99cc4a8 | 2006-01-31 21:45:53 +1100 | [diff] [blame] | 310 | The client tries to authenticate itself using |
Damien Miller | 8bbdf90 | 2006-02-01 22:05:25 +1100 | [diff] [blame] | 311 | host-based authentication, |
| 312 | public key authentication, |
| 313 | challenge-response authentication, |
| 314 | or password authentication. |
Damien Miller | 99cc4a8 | 2006-01-31 21:45:53 +1100 | [diff] [blame] | 315 | .Pp |
| 316 | Regardless of the authentication type, the account is checked to |
| 317 | ensure that it is accessible. An account is not accessible if it is |
| 318 | locked, listed in |
| 319 | .Cm DenyUsers |
| 320 | or its group is listed in |
| 321 | .Cm DenyGroups |
| 322 | \&. The definition of a locked account is system dependant. Some platforms |
| 323 | have their own account database (eg AIX) and some modify the passwd field ( |
| 324 | .Ql \&*LK\&* |
| 325 | on Solaris and UnixWare, |
| 326 | .Ql \&* |
| 327 | on HP-UX, containing |
| 328 | .Ql Nologin |
| 329 | on Tru64, |
| 330 | a leading |
| 331 | .Ql \&*LOCKED\&* |
| 332 | on FreeBSD and a leading |
Darren Tucker | 1a9176b | 2007-08-17 09:42:32 +1000 | [diff] [blame] | 333 | .Ql \&! |
| 334 | on most Linuxes). |
| 335 | If there is a requirement to disable password authentication |
Damien Miller | 99cc4a8 | 2006-01-31 21:45:53 +1100 | [diff] [blame] | 336 | for the account while allowing still public-key, then the passwd field |
| 337 | should be set to something other than these values (eg |
| 338 | .Ql NP |
| 339 | or |
| 340 | .Ql \&*NP\&* |
| 341 | ). |
| 342 | .Pp |
Damien Miller | 99cc4a8 | 2006-01-31 21:45:53 +1100 | [diff] [blame] | 343 | If the client successfully authenticates itself, a dialog for |
| 344 | preparing the session is entered. |
| 345 | At this time the client may request |
| 346 | things like allocating a pseudo-tty, forwarding X11 connections, |
| 347 | forwarding TCP connections, or forwarding the authentication agent |
| 348 | connection over the secure channel. |
| 349 | .Pp |
Damien Miller | c47d7e9 | 2006-03-15 11:27:20 +1100 | [diff] [blame] | 350 | After this, the client either requests a shell or execution of a command. |
Damien Miller | 99cc4a8 | 2006-01-31 21:45:53 +1100 | [diff] [blame] | 351 | The sides then enter session mode. |
| 352 | In this mode, either side may send |
| 353 | data at any time, and such data is forwarded to/from the shell or |
| 354 | command on the server side, and the user terminal in the client side. |
| 355 | .Pp |
| 356 | When the user program terminates and all forwarded X11 and other |
| 357 | connections have been closed, the server sends command exit status to |
| 358 | the client, and both sides exit. |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 359 | .Sh LOGIN PROCESS |
| 360 | When a user successfully logs in, |
| 361 | .Nm |
| 362 | does the following: |
| 363 | .Bl -enum -offset indent |
| 364 | .It |
| 365 | If the login is on a tty, and no command has been specified, |
Damien Miller | 22c7726 | 2000-04-13 12:26:34 +1000 | [diff] [blame] | 366 | prints last login time and |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 367 | .Pa /etc/motd |
| 368 | (unless prevented in the configuration file or by |
Damien Miller | 167ea5d | 2005-05-26 12:04:02 +1000 | [diff] [blame] | 369 | .Pa ~/.hushlogin ; |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 370 | see the |
Damien Miller | 22c7726 | 2000-04-13 12:26:34 +1000 | [diff] [blame] | 371 | .Sx FILES |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 372 | section). |
| 373 | .It |
| 374 | If the login is on a tty, records login time. |
| 375 | .It |
| 376 | Checks |
| 377 | .Pa /etc/nologin ; |
| 378 | if it exists, prints contents and quits |
| 379 | (unless root). |
| 380 | .It |
| 381 | Changes to run with normal user privileges. |
| 382 | .It |
| 383 | Sets up basic environment. |
| 384 | .It |
Darren Tucker | 1f20394 | 2003-10-15 15:50:42 +1000 | [diff] [blame] | 385 | Reads the file |
Damien Miller | 167ea5d | 2005-05-26 12:04:02 +1000 | [diff] [blame] | 386 | .Pa ~/.ssh/environment , |
Darren Tucker | 1f20394 | 2003-10-15 15:50:42 +1000 | [diff] [blame] | 387 | if it exists, and users are allowed to change their environment. |
Ben Lindstrom | bd9bf38 | 2002-08-20 18:54:20 +0000 | [diff] [blame] | 388 | See the |
Ben Lindstrom | dc7adf2 | 2002-08-20 18:38:02 +0000 | [diff] [blame] | 389 | .Cm PermitUserEnvironment |
Ben Lindstrom | bd9bf38 | 2002-08-20 18:54:20 +0000 | [diff] [blame] | 390 | option in |
Ben Lindstrom | dc7adf2 | 2002-08-20 18:38:02 +0000 | [diff] [blame] | 391 | .Xr sshd_config 5 . |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 392 | .It |
| 393 | Changes to user's home directory. |
| 394 | .It |
| 395 | If |
Damien Miller | 167ea5d | 2005-05-26 12:04:02 +1000 | [diff] [blame] | 396 | .Pa ~/.ssh/rc |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 397 | exists, runs it; else if |
Damien Miller | afcc225 | 2002-02-10 18:32:55 +1100 | [diff] [blame] | 398 | .Pa /etc/ssh/sshrc |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 399 | exists, runs |
Damien Miller | 450a7a1 | 2000-03-26 13:04:51 +1000 | [diff] [blame] | 400 | it; otherwise runs xauth. |
| 401 | The |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 402 | .Dq rc |
| 403 | files are given the X11 |
| 404 | authentication protocol and cookie in standard input. |
Damien Miller | fd725cf | 2006-03-15 11:35:54 +1100 | [diff] [blame] | 405 | See |
| 406 | .Sx SSHRC , |
| 407 | below. |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 408 | .It |
| 409 | Runs user's shell or command. |
| 410 | .El |
Damien Miller | fd725cf | 2006-03-15 11:35:54 +1100 | [diff] [blame] | 411 | .Sh SSHRC |
| 412 | If the file |
| 413 | .Pa ~/.ssh/rc |
| 414 | exists, |
| 415 | .Xr sh 1 |
| 416 | runs it after reading the |
| 417 | environment files but before starting the user's shell or command. |
| 418 | It must not produce any output on stdout; stderr must be used |
| 419 | instead. |
| 420 | If X11 forwarding is in use, it will receive the "proto cookie" pair in |
| 421 | its standard input (and |
| 422 | .Ev DISPLAY |
| 423 | in its environment). |
| 424 | The script must call |
| 425 | .Xr xauth 1 |
| 426 | because |
| 427 | .Nm |
| 428 | will not run xauth automatically to add X11 cookies. |
| 429 | .Pp |
| 430 | The primary purpose of this file is to run any initialization routines |
| 431 | which may be needed before the user's home directory becomes |
| 432 | accessible; AFS is a particular example of such an environment. |
| 433 | .Pp |
| 434 | This file will probably contain some initialization code followed by |
| 435 | something similar to: |
| 436 | .Bd -literal -offset 3n |
| 437 | if 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 - |
| 446 | fi |
| 447 | .Ed |
| 448 | .Pp |
| 449 | If this file does not exist, |
| 450 | .Pa /etc/ssh/sshrc |
| 451 | is run, and if that |
| 452 | does not exist either, xauth is used to add the cookie. |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 453 | .Sh AUTHORIZED_KEYS FILE FORMAT |
Ben Lindstrom | f96704d | 2001-06-25 04:17:12 +0000 | [diff] [blame] | 454 | .Cm AuthorizedKeysFile |
Damien Miller | dcfea27 | 2006-03-15 11:31:22 +1100 | [diff] [blame] | 455 | specifies the file containing public keys for |
| 456 | public key authentication; |
| 457 | if none is specified, the default is |
| 458 | .Pa ~/.ssh/authorized_keys . |
Damien Miller | 450a7a1 | 2000-03-26 13:04:51 +1000 | [diff] [blame] | 459 | Each line of the file contains one |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 460 | key (empty lines and lines starting with a |
| 461 | .Ql # |
| 462 | are ignored as |
Damien Miller | 450a7a1 | 2000-03-26 13:04:51 +1000 | [diff] [blame] | 463 | comments). |
Damien Miller | dcfea27 | 2006-03-15 11:31:22 +1100 | [diff] [blame] | 464 | Protocol 1 public keys consist of the following space-separated fields: |
| 465 | options, bits, exponent, modulus, comment. |
| 466 | Protocol 2 public key consist of: |
| 467 | options, keytype, base64-encoded key, comment. |
| 468 | The options field is optional; |
| 469 | its presence is determined by whether the line starts |
Damien Miller | b83df8d | 2002-09-04 16:24:55 +1000 | [diff] [blame] | 470 | with a number or not (the options field never starts with a number). |
Damien Miller | dcfea27 | 2006-03-15 11:31:22 +1100 | [diff] [blame] | 471 | The bits, exponent, modulus, and comment fields give the RSA key for |
Ben Lindstrom | 4dccfa5 | 2000-12-28 16:40:05 +0000 | [diff] [blame] | 472 | protocol version 1; the |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 473 | comment field is not used for anything (but may be convenient for the |
| 474 | user to identify the key). |
Ben Lindstrom | 4dccfa5 | 2000-12-28 16:40:05 +0000 | [diff] [blame] | 475 | For protocol version 2 the keytype is |
| 476 | .Dq ssh-dss |
| 477 | or |
| 478 | .Dq ssh-rsa . |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 479 | .Pp |
| 480 | Note that lines in this file are usually several hundred bytes long |
Darren Tucker | 22cc741 | 2004-12-06 22:47:41 +1100 | [diff] [blame] | 481 | (because of the size of the public key encoding) up to a limit of |
| 482 | 8 kilobytes, which permits DSA keys up to 8 kilobits and RSA |
| 483 | keys up to 16 kilobits. |
Damien Miller | 450a7a1 | 2000-03-26 13:04:51 +1000 | [diff] [blame] | 484 | You don't want to type them in; instead, copy the |
Ben Lindstrom | 18a82ac | 2001-04-11 15:59:35 +0000 | [diff] [blame] | 485 | .Pa identity.pub , |
Damien Miller | dcfea27 | 2006-03-15 11:31:22 +1100 | [diff] [blame] | 486 | .Pa id_dsa.pub , |
Ben Lindstrom | 18a82ac | 2001-04-11 15:59:35 +0000 | [diff] [blame] | 487 | or the |
| 488 | .Pa id_rsa.pub |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 489 | file and edit it. |
| 490 | .Pp |
Ben Lindstrom | 0d0be02 | 2002-04-02 20:39:29 +0000 | [diff] [blame] | 491 | .Nm |
| 492 | enforces a minimum RSA key modulus size for protocol 1 |
| 493 | and protocol 2 keys of 768 bits. |
| 494 | .Pp |
Damien Miller | 942da03 | 2000-08-18 13:59:06 +1000 | [diff] [blame] | 495 | The options (if present) consist of comma-separated option |
Damien Miller | 450a7a1 | 2000-03-26 13:04:51 +1000 | [diff] [blame] | 496 | specifications. |
| 497 | No spaces are permitted, except within double quotes. |
Ben Lindstrom | 1c0fd09 | 2001-09-12 16:36:17 +0000 | [diff] [blame] | 498 | The following option specifications are supported (note |
| 499 | that option keywords are case-insensitive): |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 500 | .Bl -tag -width Ds |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 501 | .It Cm command="command" |
| 502 | Specifies that the command is executed whenever this key is used for |
Damien Miller | 450a7a1 | 2000-03-26 13:04:51 +1000 | [diff] [blame] | 503 | authentication. |
| 504 | The command supplied by the user (if any) is ignored. |
Ben Lindstrom | 23124ea | 2001-09-14 23:14:25 +0000 | [diff] [blame] | 505 | The command is run on a pty if the client requests a pty; |
Damien Miller | 450a7a1 | 2000-03-26 13:04:51 +1000 | [diff] [blame] | 506 | otherwise it is run without a tty. |
Damien Miller | ffadc58 | 2003-02-24 11:52:26 +1100 | [diff] [blame] | 507 | If an 8-bit clean channel is required, |
Ben Lindstrom | 594e203 | 2001-09-12 18:35:30 +0000 | [diff] [blame] | 508 | one must not request a pty or should specify |
Damien Miller | 3380426 | 2001-02-04 23:20:18 +1100 | [diff] [blame] | 509 | .Cm no-pty . |
Damien Miller | 450a7a1 | 2000-03-26 13:04:51 +1000 | [diff] [blame] | 510 | A quote may be included in the command by quoting it with a backslash. |
| 511 | This option might be useful |
Damien Miller | b83df8d | 2002-09-04 16:24:55 +1000 | [diff] [blame] | 512 | to restrict certain public keys to perform just a specific operation. |
Damien Miller | 450a7a1 | 2000-03-26 13:04:51 +1000 | [diff] [blame] | 513 | An example might be a key that permits remote backups but nothing else. |
Damien Miller | 7c24b81 | 2006-01-14 10:09:56 +1100 | [diff] [blame] | 514 | Note that the client may specify TCP and/or X11 |
Damien Miller | 30c3d42 | 2000-05-09 11:02:59 +1000 | [diff] [blame] | 515 | forwarding unless they are explicitly prohibited. |
Damien Miller | e275443 | 2006-07-24 14:06:47 +1000 | [diff] [blame] | 516 | The command originally supplied by the client is available in the |
| 517 | .Ev SSH_ORIGINAL_COMMAND |
| 518 | environment variable. |
Ben Lindstrom | 20daef7 | 2001-09-20 00:54:01 +0000 | [diff] [blame] | 519 | Note that this option applies to shell, command or subsystem execution. |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 520 | .It Cm environment="NAME=value" |
| 521 | Specifies that the string is to be added to the environment when |
Damien Miller | 450a7a1 | 2000-03-26 13:04:51 +1000 | [diff] [blame] | 522 | logging in using this key. |
| 523 | Environment variables set this way |
| 524 | override other default environment values. |
| 525 | Multiple options of this type are permitted. |
Ben Lindstrom | bd9bf38 | 2002-08-20 18:54:20 +0000 | [diff] [blame] | 526 | Environment processing is disabled by default and is |
| 527 | controlled via the |
| 528 | .Cm PermitUserEnvironment |
| 529 | option. |
Ben Lindstrom | 38b951c | 2001-12-06 17:47:47 +0000 | [diff] [blame] | 530 | This option is automatically disabled if |
| 531 | .Cm UseLogin |
| 532 | is enabled. |
Damien Miller | 31bdc52 | 2006-03-15 11:31:44 +1100 | [diff] [blame] | 533 | .It Cm from="pattern-list" |
Darren Tucker | 896ad5a | 2008-06-11 09:34:46 +1000 | [diff] [blame] | 534 | Specifies that in addition to public key authentication, either the canonical |
Darren Tucker | 1199673 | 2008-06-13 04:32:00 +1000 | [diff] [blame] | 535 | name of the remote host or its IP address must be present in the |
Darren Tucker | 896ad5a | 2008-06-11 09:34:46 +1000 | [diff] [blame] | 536 | comma-separated list of patterns. |
Damien Miller | c7d5b5e | 2006-03-15 11:55:08 +1100 | [diff] [blame] | 537 | See |
| 538 | .Sx PATTERNS |
| 539 | in |
| 540 | .Xr ssh_config 5 |
| 541 | for more information on patterns. |
Darren Tucker | 896ad5a | 2008-06-11 09:34:46 +1000 | [diff] [blame] | 542 | .Pp |
| 543 | In addition to the wildcard matching that may be applied to hostnames or |
| 544 | addresses, a |
| 545 | .Cm from |
| 546 | stanza may match IP addressess using CIDR address/masklen notation. |
| 547 | .Pp |
| 548 | The purpose of this option is to optionally increase security: public key |
| 549 | authentication by itself does not trust the network or name servers or |
| 550 | anything (but the key); however, if somebody somehow steals the key, the key |
| 551 | permits an intruder to log in from anywhere in the world. |
| 552 | This additional option makes using a stolen key more difficult (name |
| 553 | servers and/or routers would have to be compromised in addition to |
| 554 | just the key). |
Damien Miller | 31bdc52 | 2006-03-15 11:31:44 +1100 | [diff] [blame] | 555 | .It Cm no-agent-forwarding |
| 556 | Forbids authentication agent forwarding when this key is used for |
| 557 | authentication. |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 558 | .It Cm no-port-forwarding |
Damien Miller | 7c24b81 | 2006-01-14 10:09:56 +1100 | [diff] [blame] | 559 | Forbids TCP forwarding when this key is used for authentication. |
Damien Miller | 450a7a1 | 2000-03-26 13:04:51 +1000 | [diff] [blame] | 560 | Any port forward requests by the client will return an error. |
Damien Miller | 208f1ed | 2006-03-15 11:56:03 +1100 | [diff] [blame] | 561 | This might be used, e.g. in connection with the |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 562 | .Cm command |
| 563 | option. |
Damien Miller | 31bdc52 | 2006-03-15 11:31:44 +1100 | [diff] [blame] | 564 | .It Cm no-pty |
| 565 | Prevents tty allocation (a request to allocate a pty will fail). |
Damien Miller | 95e8095 | 2008-03-27 11:03:05 +1100 | [diff] [blame] | 566 | .It Cm no-user-rc |
Damien Miller | 13ba9c2 | 2008-04-03 20:52:51 +1100 | [diff] [blame] | 567 | Disables execution of |
Damien Miller | 95e8095 | 2008-03-27 11:03:05 +1100 | [diff] [blame] | 568 | .Pa ~/.ssh/rc . |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 569 | .It Cm no-X11-forwarding |
| 570 | Forbids X11 forwarding when this key is used for authentication. |
| 571 | Any X11 forward requests by the client will return an error. |
Damien Miller | a243fde | 2001-03-19 23:16:08 +1100 | [diff] [blame] | 572 | .It Cm permitopen="host:port" |
Ben Lindstrom | 2464322 | 2001-06-25 05:08:11 +0000 | [diff] [blame] | 573 | Limit local |
Damien Miller | a243fde | 2001-03-19 23:16:08 +1100 | [diff] [blame] | 574 | .Li ``ssh -L'' |
Ben Lindstrom | 4b3564e | 2001-04-10 02:41:56 +0000 | [diff] [blame] | 575 | port forwarding such that it may only connect to the specified host and |
Ben Lindstrom | d71ba57 | 2001-09-12 18:03:31 +0000 | [diff] [blame] | 576 | port. |
| 577 | IPv6 addresses can be specified with an alternative syntax: |
Darren Tucker | 1f20394 | 2003-10-15 15:50:42 +1000 | [diff] [blame] | 578 | .Ar host Ns / Ns Ar port . |
Ben Lindstrom | d71ba57 | 2001-09-12 18:03:31 +0000 | [diff] [blame] | 579 | Multiple |
Damien Miller | a243fde | 2001-03-19 23:16:08 +1100 | [diff] [blame] | 580 | .Cm permitopen |
Damien Miller | fbf486b | 2003-05-23 18:44:23 +1000 | [diff] [blame] | 581 | options may be applied separated by commas. |
| 582 | No pattern matching is performed on the specified hostnames, |
| 583 | they must be literal domains or addresses. |
Damien Miller | d27b947 | 2005-12-13 19:29:02 +1100 | [diff] [blame] | 584 | .It Cm tunnel="n" |
| 585 | Force a |
| 586 | .Xr tun 4 |
| 587 | device on the server. |
| 588 | Without this option, the next available device will be used if |
| 589 | the client requests a tunnel. |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 590 | .El |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 591 | .Pp |
Damien Miller | 7d2ef02 | 2006-03-15 11:32:06 +1100 | [diff] [blame] | 592 | An example authorized_keys file: |
Damien Miller | c8f61cf | 2006-03-15 11:33:25 +1100 | [diff] [blame] | 593 | .Bd -literal -offset 3n |
Damien Miller | 7d2ef02 | 2006-03-15 11:32:06 +1100 | [diff] [blame] | 594 | # Comments allowed at start of line |
| 595 | ssh-rsa AAAAB3Nza...LiPk== user@example.net |
Damien Miller | c8f61cf | 2006-03-15 11:33:25 +1100 | [diff] [blame] | 596 | from="*.sales.example.net,!pc.sales.example.net" ssh-rsa |
| 597 | AAAAB2...19Q== john@example.net |
| 598 | command="dump /home",no-pty,no-port-forwarding ssh-dss |
| 599 | AAAAC3...51R== example.net |
| 600 | permitopen="192.0.2.1:80",permitopen="192.0.2.2:25" ssh-dss |
| 601 | AAAAB5...21S== |
| 602 | tunnel="0",command="sh /etc/netstart tun0" ssh-rsa AAAA...== |
| 603 | jane@example.net |
Damien Miller | 7d2ef02 | 2006-03-15 11:32:06 +1100 | [diff] [blame] | 604 | .Ed |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 605 | .Sh SSH_KNOWN_HOSTS FILE FORMAT |
Damien Miller | 22c7726 | 2000-04-13 12:26:34 +1000 | [diff] [blame] | 606 | The |
Damien Miller | ffadc58 | 2003-02-24 11:52:26 +1100 | [diff] [blame] | 607 | .Pa /etc/ssh/ssh_known_hosts |
Damien Miller | 22c7726 | 2000-04-13 12:26:34 +1000 | [diff] [blame] | 608 | and |
Damien Miller | 167ea5d | 2005-05-26 12:04:02 +1000 | [diff] [blame] | 609 | .Pa ~/.ssh/known_hosts |
Damien Miller | 450a7a1 | 2000-03-26 13:04:51 +1000 | [diff] [blame] | 610 | files contain host public keys for all known hosts. |
| 611 | The global file should |
| 612 | be prepared by the administrator (optional), and the per-user file is |
Damien Miller | 9a7f201 | 2006-03-15 11:32:42 +1100 | [diff] [blame] | 613 | maintained automatically: whenever the user connects from an unknown host, |
Damien Miller | 450a7a1 | 2000-03-26 13:04:51 +1000 | [diff] [blame] | 614 | its key is added to the per-user file. |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 615 | .Pp |
| 616 | Each line in these files contains the following fields: hostnames, |
Damien Miller | 450a7a1 | 2000-03-26 13:04:51 +1000 | [diff] [blame] | 617 | bits, exponent, modulus, comment. |
| 618 | The fields are separated by spaces. |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 619 | .Pp |
Damien Miller | 3155432 | 2003-05-14 13:44:58 +1000 | [diff] [blame] | 620 | Hostnames is a comma-separated list of patterns |
Damien Miller | 9a7f201 | 2006-03-15 11:32:42 +1100 | [diff] [blame] | 621 | .Pf ( Ql * |
Damien Miller | fbf486b | 2003-05-23 18:44:23 +1000 | [diff] [blame] | 622 | and |
| 623 | .Ql \&? |
Damien Miller | 049245d | 2003-05-14 13:44:42 +1000 | [diff] [blame] | 624 | act as |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 625 | wildcards); each pattern in turn is matched against the canonical host |
| 626 | name (when authenticating a client) or against the user-supplied |
Damien Miller | 450a7a1 | 2000-03-26 13:04:51 +1000 | [diff] [blame] | 627 | name (when authenticating a server). |
| 628 | A pattern may also be preceded by |
Damien Miller | 049245d | 2003-05-14 13:44:42 +1000 | [diff] [blame] | 629 | .Ql \&! |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 630 | to indicate negation: if the host name matches a negated |
| 631 | pattern, it is not accepted (by that line) even if it matched another |
| 632 | pattern on the line. |
Darren Tucker | da34553 | 2006-07-10 23:04:19 +1000 | [diff] [blame] | 633 | A hostname or address may optionally be enclosed within |
| 634 | .Ql \&[ |
| 635 | and |
| 636 | .Ql \&] |
| 637 | brackets then followed by |
| 638 | .Ql \&: |
Darren Tucker | 1131847 | 2006-07-12 22:07:59 +1000 | [diff] [blame] | 639 | and a non-standard port number. |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 640 | .Pp |
Damien Miller | e177615 | 2005-03-01 21:47:37 +1100 | [diff] [blame] | 641 | Alternately, hostnames may be stored in a hashed form which hides host names |
Damien Miller | 718fd4b | 2005-03-02 12:03:23 +1100 | [diff] [blame] | 642 | and addresses should the file's contents be disclosed. |
| 643 | Hashed hostnames start with a |
| 644 | .Ql | |
Damien Miller | e177615 | 2005-03-01 21:47:37 +1100 | [diff] [blame] | 645 | character. |
| 646 | Only one hashed hostname may appear on a single line and none of the above |
| 647 | negation or wildcard operators may be applied. |
| 648 | .Pp |
Damien Miller | e247cc4 | 2000-05-07 12:03:14 +1000 | [diff] [blame] | 649 | Bits, exponent, and modulus are taken directly from the RSA host key; they |
Damien Miller | 9a7f201 | 2006-03-15 11:32:42 +1100 | [diff] [blame] | 650 | can be obtained, for example, from |
Damien Miller | 05eda43 | 2002-02-10 18:32:28 +1100 | [diff] [blame] | 651 | .Pa /etc/ssh/ssh_host_key.pub . |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 652 | The optional comment field continues to the end of the line, and is not used. |
| 653 | .Pp |
| 654 | Lines starting with |
| 655 | .Ql # |
| 656 | and empty lines are ignored as comments. |
| 657 | .Pp |
| 658 | When performing host authentication, authentication is accepted if any |
Damien Miller | 450a7a1 | 2000-03-26 13:04:51 +1000 | [diff] [blame] | 659 | matching line has the proper key. |
| 660 | It is thus permissible (but not |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 661 | recommended) to have several lines or different host keys for the same |
Damien Miller | 450a7a1 | 2000-03-26 13:04:51 +1000 | [diff] [blame] | 662 | names. |
| 663 | This will inevitably happen when short forms of host names |
| 664 | from different domains are put in the file. |
| 665 | It is possible |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 666 | that the files contain conflicting information; authentication is |
| 667 | accepted if valid information can be found from either file. |
| 668 | .Pp |
| 669 | Note that the lines in these files are typically hundreds of characters |
| 670 | long, and you definitely don't want to type in the host keys by hand. |
| 671 | Rather, generate them by a script |
Damien Miller | 22c7726 | 2000-04-13 12:26:34 +1000 | [diff] [blame] | 672 | or by taking |
Damien Miller | 05eda43 | 2002-02-10 18:32:28 +1100 | [diff] [blame] | 673 | .Pa /etc/ssh/ssh_host_key.pub |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 674 | and adding the host names at the front. |
Damien Miller | cc00f5e | 2006-03-15 11:33:00 +1100 | [diff] [blame] | 675 | .Pp |
| 676 | An example ssh_known_hosts file: |
| 677 | .Bd -literal -offset 3n |
| 678 | # Comments allowed at start of line |
| 679 | closenet,...,192.0.2.53 1024 37 159...93 closenet.example.net |
| 680 | cvs.example.net,192.0.2.10 ssh-rsa AAAA1234.....= |
Damien Miller | e177615 | 2005-03-01 21:47:37 +1100 | [diff] [blame] | 681 | # A hashed hostname |
| 682 | |1|JfKTdBh7rNbXkVAQCRp4OQoPfmI=|USECr3SWf1JUPsms5AqfD5QfxkM= ssh-rsa |
| 683 | AAAA1234.....= |
| 684 | .Ed |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 685 | .Sh FILES |
Damien Miller | d8702e8 | 2006-03-15 11:33:56 +1100 | [diff] [blame] | 686 | .Bl -tag -width Ds -compact |
| 687 | .It ~/.hushlogin |
Damien Miller | 70a908e | 2005-03-01 21:17:09 +1100 | [diff] [blame] | 688 | This file is used to suppress printing the last login time and |
| 689 | .Pa /etc/motd , |
| 690 | if |
| 691 | .Cm PrintLastLog |
| 692 | and |
| 693 | .Cm PrintMotd , |
| 694 | respectively, |
| 695 | are enabled. |
| 696 | It does not suppress printing of the banner specified by |
| 697 | .Cm Banner . |
Damien Miller | d8702e8 | 2006-03-15 11:33:56 +1100 | [diff] [blame] | 698 | .Pp |
| 699 | .It ~/.rhosts |
Damien Miller | adc35b9 | 2006-03-15 11:35:27 +1100 | [diff] [blame] | 700 | This file is used for host-based authentication (see |
| 701 | .Xr ssh 1 |
| 702 | for more information). |
| 703 | On some machines this file may need to be |
| 704 | world-readable if the user's home directory is on an NFS partition, |
| 705 | because |
| 706 | .Nm |
| 707 | reads it as root. |
| 708 | Additionally, this file must be owned by the user, |
| 709 | and must not have write permissions for anyone else. |
| 710 | The recommended |
| 711 | permission for most machines is read/write for the user, and not |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 712 | accessible by others. |
| 713 | .Pp |
Damien Miller | d8702e8 | 2006-03-15 11:33:56 +1100 | [diff] [blame] | 714 | .It ~/.shosts |
Damien Miller | adc35b9 | 2006-03-15 11:35:27 +1100 | [diff] [blame] | 715 | This file is used in exactly the same way as |
| 716 | .Pa .rhosts , |
| 717 | but allows host-based authentication without permitting login with |
| 718 | rlogin/rsh. |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 719 | .Pp |
Damien Miller | 520e615 | 2008-02-10 22:46:22 +1100 | [diff] [blame] | 720 | .It ~/.ssh/ |
| 721 | This directory is the default location for all user-specific configuration |
| 722 | and authentication information. |
| 723 | There is no general requirement to keep the entire contents of this directory |
| 724 | secret, but the recommended permissions are read/write/execute for the user, |
| 725 | and not accessible by others. |
| 726 | .Pp |
Damien Miller | d8702e8 | 2006-03-15 11:33:56 +1100 | [diff] [blame] | 727 | .It ~/.ssh/authorized_keys |
Damien Miller | adc35b9 | 2006-03-15 11:35:27 +1100 | [diff] [blame] | 728 | Lists the public keys (RSA/DSA) that can be used for logging in as this user. |
Damien Miller | d8702e8 | 2006-03-15 11:33:56 +1100 | [diff] [blame] | 729 | The format of this file is described above. |
Damien Miller | 5d43d49 | 2006-08-30 11:07:00 +1000 | [diff] [blame] | 730 | The content of the file is not highly sensitive, but the recommended |
Damien Miller | adc35b9 | 2006-03-15 11:35:27 +1100 | [diff] [blame] | 731 | permissions are read/write for the user, and not accessible by others. |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 732 | .Pp |
Damien Miller | 5d43d49 | 2006-08-30 11:07:00 +1000 | [diff] [blame] | 733 | If this file, the |
| 734 | .Pa ~/.ssh |
| 735 | directory, or the user's home directory are writable |
| 736 | by other users, then the file could be modified or replaced by unauthorized |
| 737 | users. |
| 738 | In this case, |
| 739 | .Nm |
| 740 | will not allow it to be used unless the |
| 741 | .Cm StrictModes |
| 742 | option has been set to |
| 743 | .Dq no . |
| 744 | The recommended permissions can be set by executing |
| 745 | .Dq chmod go-w ~/ ~/.ssh ~/.ssh/authorized_keys . |
| 746 | .Pp |
Damien Miller | d8702e8 | 2006-03-15 11:33:56 +1100 | [diff] [blame] | 747 | .It ~/.ssh/environment |
Damien Miller | 450a7a1 | 2000-03-26 13:04:51 +1000 | [diff] [blame] | 748 | This file is read into the environment at login (if it exists). |
| 749 | It can only contain empty lines, comment lines (that start with |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 750 | .Ql # ) , |
Damien Miller | 450a7a1 | 2000-03-26 13:04:51 +1000 | [diff] [blame] | 751 | and assignment lines of the form name=value. |
| 752 | The file should be writable |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 753 | only by the user; it need not be readable by anyone else. |
Ben Lindstrom | bd9bf38 | 2002-08-20 18:54:20 +0000 | [diff] [blame] | 754 | Environment processing is disabled by default and is |
| 755 | controlled via the |
| 756 | .Cm PermitUserEnvironment |
| 757 | option. |
Damien Miller | d8702e8 | 2006-03-15 11:33:56 +1100 | [diff] [blame] | 758 | .Pp |
| 759 | .It ~/.ssh/known_hosts |
Damien Miller | adc35b9 | 2006-03-15 11:35:27 +1100 | [diff] [blame] | 760 | Contains a list of host keys for all hosts the user has logged into |
| 761 | that are not already in the systemwide list of known host keys. |
| 762 | The format of this file is described above. |
| 763 | This file should be writable only by root/the owner and |
Damien Miller | d8702e8 | 2006-03-15 11:33:56 +1100 | [diff] [blame] | 764 | can, but need not be, world-readable. |
| 765 | .Pp |
| 766 | .It ~/.ssh/rc |
Damien Miller | fd725cf | 2006-03-15 11:35:54 +1100 | [diff] [blame] | 767 | Contains initialization routines to be run before |
| 768 | the user's home directory becomes accessible. |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 769 | This file should be writable only by the user, and need not be |
| 770 | readable by anyone else. |
Damien Miller | d8702e8 | 2006-03-15 11:33:56 +1100 | [diff] [blame] | 771 | .Pp |
| 772 | .It /etc/hosts.allow |
| 773 | .It /etc/hosts.deny |
| 774 | Access controls that should be enforced by tcp-wrappers are defined here. |
| 775 | Further details are described in |
| 776 | .Xr hosts_access 5 . |
| 777 | .Pp |
| 778 | .It /etc/hosts.equiv |
Damien Miller | 445121f | 2006-03-15 11:36:18 +1100 | [diff] [blame] | 779 | This file is for host-based authentication (see |
| 780 | .Xr ssh 1 ) . |
| 781 | It should only be writable by root. |
Damien Miller | d8702e8 | 2006-03-15 11:33:56 +1100 | [diff] [blame] | 782 | .Pp |
| 783 | .It /etc/moduli |
| 784 | Contains Diffie-Hellman groups used for the "Diffie-Hellman Group Exchange". |
| 785 | The file format is described in |
| 786 | .Xr moduli 5 . |
| 787 | .Pp |
| 788 | .It /etc/motd |
| 789 | See |
| 790 | .Xr motd 5 . |
| 791 | .Pp |
| 792 | .It /etc/nologin |
| 793 | If this file exists, |
| 794 | .Nm |
| 795 | refuses to let anyone except root log in. |
| 796 | The contents of the file |
| 797 | are displayed to anyone trying to log in, and non-root connections are |
| 798 | refused. |
| 799 | The file should be world-readable. |
| 800 | .Pp |
| 801 | .It /etc/shosts.equiv |
Damien Miller | 445121f | 2006-03-15 11:36:18 +1100 | [diff] [blame] | 802 | This file is used in exactly the same way as |
| 803 | .Pa hosts.equiv , |
| 804 | but allows host-based authentication without permitting login with |
| 805 | rlogin/rsh. |
Damien Miller | d8702e8 | 2006-03-15 11:33:56 +1100 | [diff] [blame] | 806 | .Pp |
| 807 | .It /etc/ssh/ssh_host_key |
| 808 | .It /etc/ssh/ssh_host_dsa_key |
| 809 | .It /etc/ssh/ssh_host_rsa_key |
| 810 | These three files contain the private parts of the host keys. |
| 811 | These files should only be owned by root, readable only by root, and not |
| 812 | accessible to others. |
| 813 | Note that |
| 814 | .Nm |
Damien Miller | edd0375 | 2006-03-15 11:36:45 +1100 | [diff] [blame] | 815 | does not start if these files are group/world-accessible. |
Damien Miller | d8702e8 | 2006-03-15 11:33:56 +1100 | [diff] [blame] | 816 | .Pp |
| 817 | .It /etc/ssh/ssh_host_key.pub |
| 818 | .It /etc/ssh/ssh_host_dsa_key.pub |
| 819 | .It /etc/ssh/ssh_host_rsa_key.pub |
| 820 | These three files contain the public parts of the host keys. |
| 821 | These files should be world-readable but writable only by |
| 822 | root. |
| 823 | Their contents should match the respective private parts. |
| 824 | These files are not |
| 825 | really used for anything; they are provided for the convenience of |
| 826 | the user so their contents can be copied to known hosts files. |
| 827 | These files are created using |
| 828 | .Xr ssh-keygen 1 . |
| 829 | .Pp |
Darren Tucker | 04354b9 | 2007-03-21 20:46:54 +1100 | [diff] [blame] | 830 | .It /etc/ssh/ssh_known_hosts |
| 831 | Systemwide list of known host keys. |
| 832 | This file should be prepared by the |
| 833 | system administrator to contain the public host keys of all machines in the |
| 834 | organization. |
| 835 | The format of this file is described above. |
| 836 | This file should be writable only by root/the owner and |
| 837 | should be world-readable. |
| 838 | .Pp |
Damien Miller | d8702e8 | 2006-03-15 11:33:56 +1100 | [diff] [blame] | 839 | .It /etc/ssh/sshd_config |
| 840 | Contains configuration data for |
| 841 | .Nm sshd . |
| 842 | The file format and configuration options are described in |
| 843 | .Xr sshd_config 5 . |
| 844 | .Pp |
| 845 | .It /etc/ssh/sshrc |
Damien Miller | fd725cf | 2006-03-15 11:35:54 +1100 | [diff] [blame] | 846 | Similar to |
| 847 | .Pa ~/.ssh/rc , |
| 848 | it can be used to specify |
Damien Miller | 450a7a1 | 2000-03-26 13:04:51 +1000 | [diff] [blame] | 849 | machine-specific login-time initializations globally. |
| 850 | This file should be writable only by root, and should be world-readable. |
Damien Miller | d8702e8 | 2006-03-15 11:33:56 +1100 | [diff] [blame] | 851 | .Pp |
| 852 | .It /var/empty |
| 853 | .Xr chroot 2 |
| 854 | directory used by |
| 855 | .Nm |
| 856 | during privilege separation in the pre-authentication phase. |
| 857 | The directory should not contain any files and must be owned by root |
| 858 | and not group or world-writable. |
| 859 | .Pp |
| 860 | .It /var/run/sshd.pid |
| 861 | Contains the process ID of the |
| 862 | .Nm |
| 863 | listening for connections (if there are several daemons running |
| 864 | concurrently for different ports, this contains the process ID of the one |
| 865 | started last). |
| 866 | The content of this file is not sensitive; it can be world-readable. |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 867 | .El |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 868 | .Sh SEE ALSO |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 869 | .Xr scp 1 , |
Damien Miller | 3380426 | 2001-02-04 23:20:18 +1100 | [diff] [blame] | 870 | .Xr sftp 1 , |
Damien Miller | 32aa144 | 1999-10-29 09:15:49 +1000 | [diff] [blame] | 871 | .Xr ssh 1 , |
| 872 | .Xr ssh-add 1 , |
| 873 | .Xr ssh-agent 1 , |
| 874 | .Xr ssh-keygen 1 , |
Darren Tucker | 04354b9 | 2007-03-21 20:46:54 +1100 | [diff] [blame] | 875 | .Xr ssh-keyscan 1 , |
Darren Tucker | 1f20394 | 2003-10-15 15:50:42 +1000 | [diff] [blame] | 876 | .Xr chroot 2 , |
| 877 | .Xr hosts_access 5 , |
Ben Lindstrom | c8e29ce | 2001-08-06 20:55:28 +0000 | [diff] [blame] | 878 | .Xr login.conf 5 , |
| 879 | .Xr moduli 5 , |
Ben Lindstrom | 9f04903 | 2002-06-21 00:59:05 +0000 | [diff] [blame] | 880 | .Xr sshd_config 5 , |
Darren Tucker | 1f20394 | 2003-10-15 15:50:42 +1000 | [diff] [blame] | 881 | .Xr inetd 8 , |
Ben Lindstrom | d2bf0d6 | 2001-06-25 04:10:54 +0000 | [diff] [blame] | 882 | .Xr sftp-server 8 |
Damien Miller | f1ce505 | 2003-06-11 22:04:39 +1000 | [diff] [blame] | 883 | .Sh AUTHORS |
| 884 | OpenSSH is a derivative of the original and free |
| 885 | ssh 1.2.12 release by Tatu Ylonen. |
| 886 | Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos, |
| 887 | Theo de Raadt and Dug Song |
| 888 | removed many bugs, re-added newer features and |
| 889 | created OpenSSH. |
| 890 | Markus Friedl contributed the support for SSH |
| 891 | protocol versions 1.5 and 2.0. |
| 892 | Niels Provos and Markus Friedl contributed support |
| 893 | for privilege separation. |
Damien Miller | c47d7e9 | 2006-03-15 11:27:20 +1100 | [diff] [blame] | 894 | .Sh CAVEATS |
| 895 | System security is not improved unless |
| 896 | .Nm rshd , |
| 897 | .Nm rlogind , |
| 898 | and |
| 899 | .Nm rexecd |
| 900 | are disabled (thus completely disabling |
| 901 | .Xr rlogin |
| 902 | and |
| 903 | .Xr rsh |
| 904 | into the machine). |