| 1 | <!DOCTYPE html> |
| 2 | <html> |
| 3 | <head> |
| 4 | <title>ProFTPD: Running by Nonroot User</title> |
| 5 | </head> |
| 6 | |
| 7 | <body bgcolor=white> |
| 8 | |
| 9 | <hr> |
| 10 | <center><h2><b><i>ProFTPD: Running as a Nonroot User</i></b></h2></center> |
| 11 | <hr> |
| 12 | |
| 13 | <p> |
| 14 | Occasionally, one might want to run ProFTPD on a system where root privs |
| 15 | are not available to you as a user. It is still possible to setup a |
| 16 | functioning FTP server without root privileges. There are a few catches |
| 17 | and special considerations for this, however. |
| 18 | |
| 19 | <p> |
| 20 | Here are the configuration directives that you will need to use in order |
| 21 | to run the server without root privileges:<br> |
| 22 | |
| 23 | <ul> |
| 24 | <li><b><code>Port</code></b><br> |
| 25 | This needs to be a number greater than 1023. Lower number ports require |
| 26 | root privileges in order for the process to bind to that address. This |
| 27 | will also mean that clients wishing to contact your server will need to |
| 28 | know the port on which it is listening. Most FTP clients connect to the |
| 29 | standard FTP port (21). |
| 30 | |
| 31 | <p> |
| 32 | Example: |
| 33 | <pre> |
| 34 | Port 20021 |
| 35 | </pre> |
| 36 | </li> |
| 37 | |
| 38 | <li><b><code>AuthUserFile, AuthGroupFile</code></b><br> |
| 39 | In order to authenticate users, by default the server looks in |
| 40 | <code>/etc/passwd</code> for account information, and in |
| 41 | <code>/etc/shadow</code> for the password. Comparing stored passwords |
| 42 | requires root privileges, which this nonroot-running daemon will not have. |
| 43 | You can get around this requirement by supplying your own passwd (and |
| 44 | possibly group) files via the <a href="../modules/mod_auth_file.html#AuthUserFile"><code>AuthUserFile</code></a> and |
| 45 | <a href="../modules/mod_auth_file.html#AuthGroupFile"><code>AuthGroupFile</code></a> directives. Make sure the permissions on your |
| 46 | custom files allow for the daemon to read them (but hopefully not other |
| 47 | users). |
| 48 | |
| 49 | <p> |
| 50 | Example: |
| 51 | <pre> |
| 52 | AuthUserFile /path/to/custom/ftpd.passwd |
| 53 | AuthGroupFile /path/to/custom/ftpd.group |
| 54 | </pre> |
| 55 | </li> |
| 56 | |
| 57 | <li><b><code>AuthPAM</code></b><br> |
| 58 | PAM authentication requires root privileges. This directive will need |
| 59 | to be set <i>off</i>. |
| 60 | |
| 61 | <p> |
| 62 | Example: |
| 63 | <pre> |
| 64 | AuthPAM off |
| 65 | </pre> |
| 66 | </li> |
| 67 | |
| 68 | <p> |
| 69 | <li><b><code>PidFile</code></b><br> |
| 70 | This directive will need to be used to cause the server to write its PID |
| 71 | to some file writable by the user. |
| 72 | |
| 73 | <p> |
| 74 | Example: |
| 75 | <pre> |
| 76 | PidFile /home/bob/ftpd/proftpd.pid |
| 77 | </pre> |
| 78 | </li> |
| 79 | |
| 80 | <p> |
| 81 | <li><b><code>ScoreboardFile</code></b><br> |
| 82 | This directive will need to be used to cause the server to write its |
| 83 | scoreboard to some file writable by the user. |
| 84 | |
| 85 | <p> |
| 86 | Example: |
| 87 | <pre> |
| 88 | ScoreboardFile /home/bob/ftpd/proftpd.scoreboard |
| 89 | </pre> |
| 90 | </li> |
| 91 | |
| 92 | <li><b><code>WtmpLog</code></b><br> |
| 93 | Logging to <code>wtmp</code> files requires root privileges. While it is |
| 94 | not strictly necessary for this directive to be set to <i>off</i>, failure |
| 95 | to do so will result in server log messages like: |
| 96 | <pre> |
| 97 | host.domain.net (localhost[127.0.0.1]) - wtmpx /var/adm/wtmpx: Permission denied |
| 98 | </pre> |
| 99 | |
| 100 | <p> |
| 101 | Example: |
| 102 | <pre> |
| 103 | WtmpLog off |
| 104 | </pre> |
| 105 | </li> |
| 106 | |
| 107 | <li><b><code>User, Group</code></b><br> |
| 108 | The ability to switch the identity of the server process to those configured |
| 109 | by the <a href="../modules/mod_core.html#Userl"><code>User</code></a> and |
| 110 | <a href="../modules/mod_core.html#Group"><code>Group</code></a> directives requires, of course, root privileges. It is best to |
| 111 | configure <code>User</code> to be your username, and <code>Group</code> to |
| 112 | be the name of your primary group (which is usually the first group listed |
| 113 | by the <code>groups</code> command). |
| 114 | |
| 115 | <p> |
| 116 | Example: |
| 117 | <pre> |
| 118 | User bob |
| 119 | Group bob |
| 120 | </pre> |
| 121 | </li> |
| 122 | </ul> |
| 123 | |
| 124 | <p> |
| 125 | Note that other configuration directives will be affected by the lack of |
| 126 | root privileges: <code>DefaultRoot</code> will not work, nor will |
| 127 | <code><Anonymous></code> sections, nor <code>UserOwner</code>. |
| 128 | Basically any operation that requires root privileges will be disabled. |
| 129 | |
| 130 | <p> |
| 131 | If using the <code>SystemLog</code> directive, make sure the file to which the |
| 132 | server is to log can be written to by the configured daemon <code>User</code> |
| 133 | or <code>Group</code>. |
| 134 | |
| 135 | <p> |
| 136 | The daemon should now start successfully. Complaints about not being able |
| 137 | to switch UIDs and such will be logged, but the daemon should still function |
| 138 | properly. |
| 139 | |
| 140 | <p> |
| 141 | <hr> |
| 142 | <font size=2><b><i> |
| 143 | © Copyright 2017 The ProFTPD Project<br> |
| 144 | All Rights Reserved<br> |
| 145 | </i></b></font> |
| 146 | <hr> |
| 147 | |
| 148 | </body> |
| 149 | </html> |