| 1 | <!DOCTYPE html> |
| 2 | <html> |
| 3 | <head> |
| 4 | <title>ProFTPD: Configuring ProFTPD</title> |
| 5 | </head> |
| 6 | |
| 7 | <body bgcolor=white> |
| 8 | |
| 9 | <hr> |
| 10 | <center><h2><b>ProFTPD: Configuring ProFTPD</b></h2></center> |
| 11 | <hr> |
| 12 | |
| 13 | <p> |
| 14 | <b>The Configuration File</b><br> |
| 15 | The first step in configuring a <code>proftpd</code> daemon is knowing where |
| 16 | the configuration file, usually named <code>proftpd.conf</code>, is located. |
| 17 | The default location for this file is <code>/etc/proftpd.conf</code> or |
| 18 | <code>/usr/local/etc/proftpd.conf</code>, depending on your installation. |
| 19 | When starting the daemon, the exact path to the configuration file to be |
| 20 | used can always be specified using the <code>-c</code> command-line option. |
| 21 | |
| 22 | <p> |
| 23 | The idea behind <code>proftpd</code>'s handling of the configuration file |
| 24 | is that a blank file can be used, and the daemon will still operate. This |
| 25 | means that, unlike Apache, there is a "default" server configuration |
| 26 | in every <code>proftpd.conf</code>; ProFTPD does not require that all |
| 27 | server configurations be explicitly written in the <code>proftpd.conf</code> |
| 28 | file. This default server attempts to bind to the IP address of the hostname |
| 29 | indicated by the <code>hostname(1)</code> command. |
| 30 | |
| 31 | <p><a name="Format"> |
| 32 | <b>Configuration Format</b><br> |
| 33 | The format of the <code>proftpd.conf</code> file is deliberately designed |
| 34 | to resemble the format used by Apache: lines of configuration <i>directives</i> |
| 35 | contained with different <i>contexts</i> (or <i>sections</i>). |
| 36 | |
| 37 | <p> |
| 38 | Each of configuration <i>directive</i> has the following properties: |
| 39 | <ul> |
| 40 | <li><a href="#Syntax">Syntax</a> |
| 41 | <li><a href="#Default">Default</a> |
| 42 | <li><a href="#Context">Context</a> |
| 43 | <li><a href="#Module">Module</a> |
| 44 | <li><a href="#Compatibility">Compatibility</a> |
| 45 | </ul> |
| 46 | |
| 47 | <p><a name="Syntax"> |
| 48 | <b><i>Syntax</i></b><br> |
| 49 | The directive <em>syntax</em> indicates the format of the directive as it would |
| 50 | appear in a configuration file. This syntax is extremely directive-specific, |
| 51 | so refer to the text of the directive's description for details. |
| 52 | |
| 53 | <p><a name="Default"> |
| 54 | <b><i>Default</i></b><br> |
| 55 | If the directive has a default value (<i>i.e.</i>, if you omit it from your |
| 56 | configuration entirely, the ProFTPD server will behave as though you set it to |
| 57 | this particular value), it is described here. If there is no default value, |
| 58 | this section should say "<em>None</em>". |
| 59 | |
| 60 | <p><a name="Context"> |
| 61 | <b><i>Context</i></b><br> |
| 62 | The <em>context</em> of a directive indicates where in the server's |
| 63 | configuration files the directive is legal/allowed. It is a comma-separated |
| 64 | list of one or more of the following values: |
| 65 | <ul> |
| 66 | <li><strong><i>server config</i></strong><br> |
| 67 | <p> |
| 68 | This means that the directive may be used in the server configuration |
| 69 | file (<i>e.g.</i>, <code>proftpd.conf</code>) <b>outside of any other |
| 70 | context</b> (<i>i.e.</i> not inside a <code><VirtualHost></code> or |
| 71 | <code><Global></code> context). This context defines a |
| 72 | "main" or "default" server.<br> |
| 73 | </li> |
| 74 | |
| 75 | <p> |
| 76 | <li><strong><i><code><VirtualHost></code></i></strong><br> |
| 77 | <p> |
| 78 | This context means that the directive may appear inside |
| 79 | <a href="../modules/mod_core.html#VirtualHost"><code><VirtualHost></code></a> sections in the server configuration file.<br> |
| 80 | </li> |
| 81 | |
| 82 | <p> |
| 83 | <li><strong><i><code><Global></code></i></strong><br> |
| 84 | <p> |
| 85 | This context means that the directive may appear inside |
| 86 | <a href="../modules/mod_core.html#Global"><code><Global></code></a> |
| 87 | sections in the server configuration file. This context is used as a |
| 88 | shortcut for placing directives with all server contexts, <i>i.e.</i> the |
| 89 | "server config" context as well as any |
| 90 | <code><VirtualHost></code> contexts within the configuration file. |
| 91 | Any directives of the same name <em>within</em> those server sections will |
| 92 | have precedence over a <code><Global></code> setting.<br> |
| 93 | </li> |
| 94 | |
| 95 | <p> |
| 96 | <li><strong><i><code><Anonymous></code></i></strong><br> |
| 97 | <p> |
| 98 | This context means that the directive may appear inside any |
| 99 | <a href="../modules/mod_core.html#Anonymous"><code><Anonymous></code></a> |
| 100 | sections in the server configuration file. An <Anonymous> section is |
| 101 | not a true virtual server, but rather is a section <i>within</i> a server |
| 102 | context (<i>i.e.</i> "server config", |
| 103 | <code><VirtualHost></code> or <code><Global></code>). |
| 104 | Anonymous sections are <b>automatically <code>chroot()</code>ed</b>. Any |
| 105 | configuration directives set for the containing server will be in effect |
| 106 | for the anonymous section as well, unless overridden by a directive of |
| 107 | the same name within the anonymous section.<br> |
| 108 | </li> |
| 109 | |
| 110 | <p> |
| 111 | <li><strong><i><code><Limit></code></i></strong><br> |
| 112 | <p> |
| 113 | This context means that the directive may appear inside any |
| 114 | <a href="../modules/mod_core.html#Limit"><code><Limit></code></a> |
| 115 | sections in the server configuration file. This context is used to place |
| 116 | limits on who and how individual FTP commands, or groupings of FTP |
| 117 | commands, may be used.<br> |
| 118 | </li> |
| 119 | |
| 120 | <p> |
| 121 | <li><strong><i><code><Directory></code></i></strong><br> |
| 122 | <p> |
| 123 | A directive marked as being valid in this context may be used inside |
| 124 | <a href="../modules/mod_core.html#Directory"><code><Directory></code></a> |
| 125 | sections in the server configuration file. This context configures views |
| 126 | of the contained files based on the logged-in user's username or group |
| 127 | membership, or on the name of the files (<i>e.g.</i> Unix-style |
| 128 | "hidden" files), and on whether the user has permission to see |
| 129 | the files. By definition, directives set using a |
| 130 | <a href="ftpaccess.html"><code>.ftpaccess</code></a> file are considered |
| 131 | to be occurring within a <code><Directory></code> context.<br> |
| 132 | </li> |
| 133 | |
| 134 | <p> |
| 135 | <li><strong><i>.ftpaccess</i></strong><br> |
| 136 | <p> |
| 137 | If a directive is valid in this context, it means that it can appear |
| 138 | inside <em>per</em>-directory |
| 139 | <a href="ftpaccess.html"><code>.ftpaccess</code></a> files. |
| 140 | These files are akin to Apache's <code>.htaccess</code> files: |
| 141 | parsed-on-the-fly mini-configuration files that users can place within |
| 142 | their own directories.<br> |
| 143 | </li> |
| 144 | </ul> |
| 145 | |
| 146 | <p> |
| 147 | A configuration directive is <em>only</em> allowed within the designated |
| 148 | contexts; if you try to use that directive elsewhere, you will get a |
| 149 | configuration error that will either prevent the server from handling requests |
| 150 | in that context correctly, or will keep the server from operating at all |
| 151 | <em>i.e.</em>, the server will not even start. A directive that is marked as |
| 152 | being valid in "<code>server config, .ftpaccess</code>" can be used |
| 153 | in the <code>proftpd.conf</code> file and in <code>.ftpaccess</code> files, |
| 154 | but not within any <code><Directory></code>, |
| 155 | <code><VirtualHost></code>, or other contexts. |
| 156 | |
| 157 | <p> |
| 158 | Two new configuration directives were introduced in |
| 159 | <code>proftpd-1.2.6rc1</code>: <code><IfModule></code> and |
| 160 | <code><IfDefine></code>. These work exactly like Apache's directives of |
| 161 | the same names, providing the ability to have conditional sections in the |
| 162 | configuration file. |
| 163 | |
| 164 | <p><a name="Module"> |
| 165 | <b><i>Module</i></b><br> |
| 166 | This quite simply lists the name of the module (<i>e.g.</i> |
| 167 | <code>mod_xfer</code>, <code>mod_tls</code>, <code>mod_sql</code>, <i>etc</i>) |
| 168 | which defines and implements the directive. |
| 169 | |
| 170 | <p><a name="Compatibility"> |
| 171 | <b><i>Compatibility</i></b><br> |
| 172 | This usually lists the version in which the directive first appeared. |
| 173 | |
| 174 | <p> |
| 175 | A list of the configuration directives for ProFTPD is available here: |
| 176 | <pre> |
| 177 | <a href="http://www.proftpd.org/docs/">http://www.proftpd.org/docs/</a> |
| 178 | </pre> |
| 179 | |
| 180 | When reading the description for the configuration directives, this key |
| 181 | might be useful: |
| 182 | It describes the description format, and lists the different contexts in the |
| 183 | configuration file. The "server config" context is the one in |
| 184 | which most of your configuration directives will most likely be placed. |
| 185 | |
| 186 | <p><a name="Starting"> |
| 187 | <b>Starting the Daemon</b><br> |
| 188 | One of the first decisions you will need to make is whether you will be running |
| 189 | your ProFTPD server as an <code>inetd</code> service, or as a |
| 190 | <code>standalone</code> server. This is controlled in the |
| 191 | <code>proftpd.conf</code> using the <code>ServerType</code> configuration |
| 192 | directive (see the <a href="ServerType.html">ServerType</a> page). |
| 193 | |
| 194 | <p><a name="Identity"> |
| 195 | <b>Server Identity</b><br> |
| 196 | The daemon must be started with root privileges in order to do things like |
| 197 | binding to port 21 and chrooting FTP sessions. However, it is not a good |
| 198 | idea to leave a long-lived process running as root. The <code>User</code> |
| 199 | and <code>Group</code> configuration directives are thus recommended. These |
| 200 | directives configure the identity to which the daemon will switch, after |
| 201 | accomplishing its startup tasks. The daemon will switch to the configured |
| 202 | <code>User</code> and <code>Group</code> in the "server config" |
| 203 | context. (Note that this switch uses the <i>effective</i> UID/GID, |
| 204 | not the <i>real</i> UID/GID. Some programs, such as <code>top</code>, |
| 205 | will continue to report <code>proftpd</code> as running as <code>root</code>; |
| 206 | this is because the program displays the real UID/GID of processes. |
| 207 | The <code>proftpd</code> daemon retains root privileges for operations |
| 208 | such as chroots and binding to port 20 for active data transfers. |
| 209 | If you wish <code>proftpd</code> to drop all root privileges, use the |
| 210 | <a href="../modules/mod_auth.html#RootRevoke"><code>RootRevoke</code></a> |
| 211 | configuration directive.) |
| 212 | |
| 213 | <p> |
| 214 | For this reason, it is recommended that a non-privileged identity be |
| 215 | used. Many sites choose to use user <code>nobody</code>. Historically, |
| 216 | this role account was used by NFS-related processes; over time, many other |
| 217 | applications default to using user <code>nobody</code>. This has the |
| 218 | side-effect of adding to the "privileges" held by user |
| 219 | <code>nobody</code>, in terms of files owned and/or accessible by that user. |
| 220 | Instead, I personally recommend that a new role account be created for use |
| 221 | specifically by the daemon, a user <code>ftpd</code>, and perhaps even a |
| 222 | group <code>ftpd</code>. Many systems that run Apache have a user |
| 223 | <code>www</code> or user <code>apache</code> for use by the <code>httpd</code> |
| 224 | daemon; similarly, a separate user should be created for the |
| 225 | <code>proftpd</code> daemon. |
| 226 | |
| 227 | <p> |
| 228 | In the default configuration file that accompanies the proftpd source code, |
| 229 | there appears: |
| 230 | <pre> |
| 231 | User nobody |
| 232 | Group nogroup |
| 233 | </pre> |
| 234 | When trying to start the daemon, many users encounter the "no such group |
| 235 | 'nogroup'" error message. There are really no reasonable defaults |
| 236 | for those directives. The error message is a way of telling you to create the |
| 237 | role accounts mentioned above. |
| 238 | |
| 239 | <p> |
| 240 | For every connection, <code>proftpd</code> creates a new process to handle |
| 241 | that client/connection. Once that client has successfully authenticated, |
| 242 | then that process switches to the identity/privileges (<i>e.g.</i> UID, primary |
| 243 | and supplemental GIDs, <i>etc</i>) of the authenticated user. Thus all |
| 244 | browsing, uploads, and downloads that clients do happen as the user as which |
| 245 | they are logged in. |
| 246 | |
| 247 | <p><a name="Login"> |
| 248 | <b>Logging in</b><br> |
| 249 | By default, the <code>proftpd</code> daemon reads the host's |
| 250 | <code>/etc/passwd</code> file for logging in users. This means that to |
| 251 | add FTP users, you simply need to create new system accounts for those users in |
| 252 | your <code>/etc/passwd</code> file. |
| 253 | |
| 254 | <p> |
| 255 | Sometimes, though, sites want "virtual", FTP-only users. In order |
| 256 | to support such configurations, the <code>AuthUserFile</code> configuration |
| 257 | directive can be used (see <a href="AuthFiles.html">here</a> for details). |
| 258 | |
| 259 | <p> |
| 260 | For the purpose of authenticating users using other means, there are various |
| 261 | authentication modules: |
| 262 | <a href="../contrib/mod_sql.html"><code>mod_sql</code></a>, |
| 263 | <a href="../contrib/mod_ldap.html"><code>mod_ldap</code></a>, |
| 264 | <a href="../contrib/mod_radius.html"><code>mod_radius</code></a>, <i>etc</i>. |
| 265 | Authentication and the login process is discussed |
| 266 | <a href="Authentication.html">here</a> in more detail. |
| 267 | |
| 268 | <p> |
| 269 | For setting up anonymous logins, there is the <a href="../modules/mod_core.html#Anonymous"><code><Anonymous></code></a> configuration context. If there |
| 270 | are no <code><Anonymous></code> sections in your |
| 271 | <code>proftpd.conf</code>, then no anonymous logins will be allowed - simple. |
| 272 | As mentioned in the description, the <code>User</code> directive in an |
| 273 | <code><Anonymous></code> context determines what username is treated as |
| 274 | an anonymous login. The main other thing to know about anonymous logins is |
| 275 | that ProFTPD automatically chroots anonymous logins. |
| 276 | |
| 277 | <p><a name="Jailing"> |
| 278 | For normal, non-anonymous logins, jails/chroots are configured using the |
| 279 | <a href="../modules/mod_auth.html#DefaultRoot"><code>DefaultRoot</code></a> |
| 280 | directive. This is the configuration directive used to restrict users to |
| 281 | their home directories, to keep them from browsing around the site. There is |
| 282 | a page covering chrooting <a href="Chroot.html">here</a>. |
| 283 | |
| 284 | <p> |
| 285 | If you use <code><VirtualHost></code> sections, and it seems that your |
| 286 | server configuration is not being seen by connecting clients, you might |
| 287 | need to check that, if using a DNS name instead of an IP address in your |
| 288 | <code><VirtualHost></code> line, that name resolves to an IP address |
| 289 | different from that of the "default" server. Many people new |
| 290 | to ProFTPD get the impression that since the configuration syntax looks |
| 291 | similar to Apache's, things like name-based virtual hosting will work as well. |
| 292 | Unfortunately, this is not possible. It is not a limitation in ProFTPD, |
| 293 | but rather in the RFCs that define FTP. See the |
| 294 | <a href="Vhost.html">virtual server</a> page for more information. |
| 295 | |
| 296 | <p> |
| 297 | As a workaround, some sites configure virtual servers to run on non-standard |
| 298 | ports, using the <code>Port</code> configuration directive. As long as |
| 299 | the clients are aware of the non-standard port, this scheme works well. One |
| 300 | minor little caveat to keep in mind, when using this approach, is the numbers |
| 301 | used: the RFCs mandate that the daemon, for the purposes of active data |
| 302 | transfers (as opposed to passive) use port <code><i>L</i>-1</code> as the source |
| 303 | port for the data connection, where <code><i>L</i></code> is the port number |
| 304 | at which the client contacted the server. This means that servers that use the |
| 305 | standard port 21 for FTP will use port 20 as the <i>source</i> port for their |
| 306 | active data transfers. (<b>Note</b> that this <i>also</i> means that you do |
| 307 | <b>not</b> need to have port 20 open in your firewall for <i>inbound</i> |
| 308 | connections for FTP data transfers). Passive data transfers do not have this |
| 309 | restriction. The restriction comes into play when choosing non-standard port |
| 310 | numbers for virtual hosts. For example, this configuration would cause |
| 311 | problems for clients of the second virtual server that wanted to use active |
| 312 | data transfers: |
| 313 | <pre> |
| 314 | <VirtualHost <i>a.b.c.d</i>> |
| 315 | Port 2121 |
| 316 | ... |
| 317 | </VirtualHost> |
| 318 | |
| 319 | <VirtualHost <i>a.b.c.d</i>> |
| 320 | Port 2122 |
| 321 | ... |
| 322 | </VirtualHost> |
| 323 | </pre> |
| 324 | The second virtual would attempt to use port 2121 as the source port for |
| 325 | an active data transfer, but would be blocked, as the first virtual server |
| 326 | is already using that port for listening. |
| 327 | |
| 328 | <p><a name="Access"> |
| 329 | <b>Access Restrictions</b><br> |
| 330 | Many sites like to have specific directories for uploads, and other directories |
| 331 | only for downloads; some sites like to allow downloads, but no browsing |
| 332 | of directories or their contents. For configurations to achieve this, |
| 333 | use combinations of the <code><Directory></code> and |
| 334 | <code><Limit></code> configuration directives. There are separate |
| 335 | pages that cover these configuration sections: |
| 336 | <ul> |
| 337 | <li><a href="Directory.html"><code><Directory></code></a> |
| 338 | <li><a href="Limit.html"><code><Limit></code></a> |
| 339 | </ul> |
| 340 | |
| 341 | <p><a name="Questions"> |
| 342 | <b>Further Questions</b><br> |
| 343 | Hopefully this document answers some of your questions, or at least enough |
| 344 | to get you started. In addition, you should take a look at some of the |
| 345 | <a href="http://www.proftpd.org/docs/example-conf.html">example configuration |
| 346 | files</a>. Once you are comfortable with the configuration file format, a |
| 347 | reading of all the configuration directives' descriptions is recommended, |
| 348 | especially if you plan on having more complex configurations. When trying to |
| 349 | figure out why something is not working, make use of server |
| 350 | <a href="Debugging.html">debugging</a> output. |
| 351 | |
| 352 | <p> |
| 353 | If you still have questions, the <a href="http://www.proftpd.org/lists.html"> |
| 354 | users</a> mailing list is the best place to post them. |
| 355 | |
| 356 | <p> |
| 357 | <hr> |
| 358 | <font size=2><b><i> |
| 359 | © Copyright 2000-2016 The ProFTPD Project<br> |
| 360 | All Rights Reserved<br> |
| 361 | </i></b></font> |
| 362 | <hr> |
| 363 | |
| 364 | </body> |
| 365 | </html> |