| 1 | <!DOCTYPE html> |
| 2 | <html> |
| 3 | <head> |
| 4 | <title>ftpasswd: tool for ProFTPD's AuthUserFile, AuthGroupFile, UserPassword </title> |
| 5 | </head> |
| 6 | |
| 7 | <body bgcolor=white> |
| 8 | |
| 9 | <hr> |
| 10 | <center> |
| 11 | <h2><b><code>ftpasswd</code>: tool for ProFTPD's <code>AuthUserFile</code>, <code>AuthGroupFile</code>, <code>UserPassword</code></b></h2> |
| 12 | </center> |
| 13 | <hr> |
| 14 | |
| 15 | <p> |
| 16 | This program is used to create and manage files, correctly formatted, suitable |
| 17 | for use with ProFTPD's <a href="../modules/mod_auth_file.html#AuthUserFile"><code>AuthUserFile</code></a> and <a href="../modules/mod_auth_file.html#AuthGroupFile"><code>AuthGroupFile</code></a> configuration directives. It can also |
| 18 | generate password hashes for ProFTPD's <a href="../modules/mod_auth.html#UserPassword"><code>UserPassword</code></a> directive. |
| 19 | |
| 20 | <p> |
| 21 | The most current version of <code>ftpasswd</code> is distributed with the |
| 22 | ProFTPD source code, under the <code>contrib/</code> directory. |
| 23 | |
| 24 | <h2>Author</h2> |
| 25 | <p> |
| 26 | Please contact TJ Saunders <tj <i>at</i> castaglia.org> with any |
| 27 | questions, concerns, or suggestions regarding this program. |
| 28 | |
| 29 | <p> |
| 30 | <hr><br> |
| 31 | <h2><a name="Usage">Usage</a></h2> |
| 32 | The following describes the common usage of the <code>ftpasswd</code> tool. |
| 33 | The options supported are described in more detail |
| 34 | <a href="#Options">later</a>. |
| 35 | |
| 36 | <p> |
| 37 | This script is intended to replace the <code>genuser.pl</code> script that |
| 38 | is currently distributed with <code>proftpd</code>. That script can |
| 39 | generate DES-hashed passwords, suitable for use with the <a href="../modules/mod_auth.html#UserPassword"><code>UserPassword</code></a> configuration directive, |
| 40 | but it is not quite right for <code>AuthUserFile</code>s. Another common |
| 41 | mistake is to use the <code>htpasswd</code> program from Apache to create files |
| 42 | for <code>proftpd</code>. Apache and ProFTPD both have the same |
| 43 | <code>AuthUserFile</code> and <code>AuthGroupFile</code> directives; the format |
| 44 | of the files used by each server is different. |
| 45 | |
| 46 | <p> |
| 47 | <b>Creating Files</b><br> |
| 48 | The <code>ftpasswd</code> program can create and update files for both |
| 49 | <code>AuthUserFile</code> and <code>AuthGroupFile</code>. When it is used |
| 50 | for the first time, the program will create the necessary file. If that |
| 51 | file already exists, <code>ftpasswd</code> will update it with the new |
| 52 | information. |
| 53 | |
| 54 | <p> |
| 55 | <code>ftpasswd</code> must first know what type of file to create. Use either |
| 56 | the <code>--passwd</code> option (for handling <code>AuthUserFile</code>s), or |
| 57 | the <code>--group</code> option (for handling <code>AuthGroupFile</code>s); |
| 58 | this is required. |
| 59 | |
| 60 | <p> |
| 61 | When creating an <code>AuthUserFile</code>, the following options are also |
| 62 | required: <code>--name</code>, <code>--uid</code>, <code>--home</code>, and |
| 63 | <code>--shell</code>. This information is required by <code>proftpd</code> to |
| 64 | authenticate a user. The optional parameters for an <code>AuthUserFile</code> |
| 65 | include <code>--gid</code> (defaults to the given <code>--uid</code> argument |
| 66 | when not provided) and <code>--gecos</code> (not used by <code>proftpd</code> |
| 67 | at all). For example: |
| 68 | <pre> |
| 69 | $ ftpasswd --passwd --name=bob --uid=1001 --home=/home/bob --shell=/bin/false |
| 70 | </pre> |
| 71 | creates an account for user <code>bob</code>. To create a file with a name or |
| 72 | location other than the default (which, for <code>--passwd</code> mode is |
| 73 | <code>ftpd.passwd</code>), use the <code>--file</code> option. For example, to create the alternate password file in <code>/usr/local/etc/ftpd/passwd</code>: |
| 74 | <pre> |
| 75 | $ ftpasswd --passwd --file=/usr/local/etc/ftpd/passwd --name=bob --uid=1001 --home=/home/bob \ |
| 76 | --shell=/bin/false |
| 77 | </pre> |
| 78 | |
| 79 | <p> |
| 80 | For <code>AuthGroupFile</code>s, use <code>--group</code>: |
| 81 | <pre> |
| 82 | $ ftpasswd --group --name=<i>group-name</i> --gid=<i>group-id</i> --member=<i>user-member1</i> \ |
| 83 | --member=<i>user-member2</i> ... --member=<i>user-memberN</i> |
| 84 | </pre> |
| 85 | |
| 86 | <p> |
| 87 | The most common change to these files is made to <code>AuthUserFile</code>s, to |
| 88 | change a user's password. The <code>--change-password</code> option was |
| 89 | provided just for this scenario: |
| 90 | <pre> |
| 91 | $ ftpasswd --passwd --name=<i>user</i> --change-password |
| 92 | </pre> |
| 93 | |
| 94 | <p> |
| 95 | <b>Creating Hashes</b><br> |
| 96 | A less common need is to generate a password hash for some user, to be used |
| 97 | in a <code>UserPassword</code> directive in the <code>proftpd.conf</code>. |
| 98 | One could generate a file using <code>--passwd</code> and then extract the |
| 99 | password hash from the file. Easier, though, is to use <code>ftpasswd</code>'s |
| 100 | <code>--hash</code> option: |
| 101 | <pre> |
| 102 | $ ftpasswd --hash |
| 103 | </pre> |
| 104 | The password will either be prompted for, or it can be given on standard in |
| 105 | using <code>--stdin</code>. |
| 106 | |
| 107 | <p> |
| 108 | <b>Automated Use</b><br> |
| 109 | The <code>ftpasswd</code> provides a useful command-line interface to |
| 110 | interacting with the authentication files. Many sites would like to be able |
| 111 | to remotely manipulate these files, just as <code>ftpasswd</code> does, only |
| 112 | using a web-based mechanism, perhaps even providing a page to users to change |
| 113 | their passwords, instead of requiring use of a shell. Wrapping a shell |
| 114 | or Perl script around <code>ftpasswd</code> is the logical solution. |
| 115 | |
| 116 | <p> |
| 117 | To aid such automated wrapper scripts, <code>ftpasswd</code> has two features: |
| 118 | its return value, and a specific option. The program returns 0 if the |
| 119 | requested change was successful, and 1 if there was an error (no such |
| 120 | user/group, password matched system password and the |
| 121 | <code>--not-system-password</code> option was used, etc.). The specific |
| 122 | option is <code>--stdin</code>: this allows scripts to provide a password to |
| 123 | <code>ftpasswd</code> without prompting for a password. For example: |
| 124 | <pre> |
| 125 | $ echo <i>passwd-variable</i> | ftpasswd <i>opts</i> --stdin |
| 126 | </pre> |
| 127 | Note that the <code>--stdin</code> option does <b>not</b> allow passwords to |
| 128 | be passed to the script on the command line, but on <code>stdin</code>. This |
| 129 | is done as a security measure: the standard Unix <code>ps</code> command can |
| 130 | be used to show all the processes running on a system <i>including their |
| 131 | command line parameters</i>. This means that any user could use |
| 132 | <code>ps</code> to watch passwords given to <code>ftpasswd</code>, if those |
| 133 | passwords were to be passed on the command line. Some operating systems |
| 134 | (<i>e.g.</i> FreeBSD) allow the sysadmin to prevent users from seeing all |
| 135 | processes in this manner; consult your operating system documentation for |
| 136 | more information. |
| 137 | |
| 138 | <p> |
| 139 | There are other issues that arise when using <code>AuthUserFile</code>s. |
| 140 | This <a href="../howto/AuthFiles.html">document</a> discusses these issues in |
| 141 | greater detail. |
| 142 | |
| 143 | <p> |
| 144 | <hr><br> |
| 145 | <h2><a name="Options">Options</a></h2> |
| 146 | The following is the output from running <code>ftpasswd --help</code>: |
| 147 | <pre> |
| 148 | usage: ftpasswd [--help] [--hash|--group|--passwd] |
| 149 | |
| 150 | REQUIRED: --passwd, --group, or --hash. These specify whether ftpasswd is to |
| 151 | operate on a passwd(5) format file, on a group(5) format file, or simply |
| 152 | to generate a password hash, respectively. |
| 153 | |
| 154 | If used with --passwd, ftpasswd creates a file in the passwd(5) format, |
| 155 | suitable for use with proftpd's AuthUserFile configuration directive. |
| 156 | You will be prompted for the password to use of the user, which will be |
| 157 | encrypted, and written out as the encrypted string. New entries are |
| 158 | appended to the file by default. |
| 159 | |
| 160 | By default, using --passwd will write output to "./ftpd.passwd". |
| 161 | |
| 162 | Error exit values: |
| 163 | |
| 164 | To make it easier for wrapper scripts to interact with ftpasswd, ftpasswd |
| 165 | will exit with the following error values for the reasons described: |
| 166 | |
| 167 | 1 no such user |
| 168 | 2 password matches current password |
| 169 | 4 password matches system password |
| 170 | 8 relative path given for home directory |
| 171 | |
| 172 | Options: |
| 173 | |
| 174 | --file Write output to specified file, rather than "./ftpd.passwd" |
| 175 | |
| 176 | -F If the file to be used already exists, delete it and write a |
| 177 | --force new one. By default, new entries will be appended to the file. |
| 178 | |
| 179 | --gecos Descriptive string for the given user (usually the user's |
| 180 | full name). |
| 181 | |
| 182 | --gid Primary group ID for this user (optional, will default to |
| 183 | given --uid value if absent) |
| 184 | |
| 185 | -h Displays this message |
| 186 | --help |
| 187 | |
| 188 | --home Home directory for the user (required) |
| 189 | |
| 190 | --des Use the DES algorithm for encrypting passwords. The default |
| 191 | is the MD5 algorithm. |
| 192 | |
| 193 | --md5 Use the MD5 algorithm for encrypting passwords. This is the |
| 194 | default. |
| 195 | |
| 196 | --name Name of the user account (required). If the name does not |
| 197 | exist in the specified output-file, an entry will be created |
| 198 | for her. Otherwise, the given fields will be updated. |
| 199 | |
| 200 | --shell Shell for the user (required). Recommended: /bin/false |
| 201 | |
| 202 | --uid Numerical user ID (required) |
| 203 | |
| 204 | --change-password |
| 205 | |
| 206 | Update only the password field for a user. This option |
| 207 | requires that the --name and --passwd options be used, but no |
| 208 | others. This also double-checks the given password against |
| 209 | the user's current password in the existing passwd file, and |
| 210 | requests that a new password be given if the entered password |
| 211 | is the same as the current password. |
| 212 | |
| 213 | --delete-user |
| 214 | |
| 215 | Remove the entry for the given user name from the file. |
| 216 | |
| 217 | -l Lock the password of the named account. This option disables a |
| 218 | --lock password by changing it to a value which matches no possible |
| 219 | encrypted value (it adds a '!' at the beginning of the |
| 220 | password). |
| 221 | |
| 222 | --not-previous-password |
| 223 | |
| 224 | Double-checks the given password against the previous password |
| 225 | for the user, and requests that a new password be given if |
| 226 | the entered password is the same as the previous password. |
| 227 | |
| 228 | --not-system-password |
| 229 | |
| 230 | Double-checks the given password against the system password |
| 231 | for the user, and requests that a new password be given if |
| 232 | the entered password is the same as the system password. This |
| 233 | helps to enforce different passwords for different types of |
| 234 | access. |
| 235 | |
| 236 | --sha256 Use the SHA-256 algorithm for encrypting passwords. |
| 237 | |
| 238 | --sha512 Use the SHA-512 algorithm for encrypting passwords. |
| 239 | |
| 240 | --stdin |
| 241 | Read the password directly from standard in rather than |
| 242 | prompting for it. This is useful for writing scripts that |
| 243 | automate use of ftpasswd. |
| 244 | |
| 245 | -u Unlock the password of the named account. This option |
| 246 | --unlock re-enables a password by changing the password back to its |
| 247 | previous value (to the value before using the -l option). |
| 248 | |
| 249 | --use-cracklib |
| 250 | Causes ftpasswd to use Alec Muffet's cracklib routines in |
| 251 | order to determine and prevent the use of bad or weak |
| 252 | passwords. The optional path to this option specifies |
| 253 | the path to the dictionary files to use -- default path |
| 254 | is "/usr/lib/cracklib_dict". This requires the Perl |
| 255 | Crypt::Cracklib module to be installed on your system. |
| 256 | |
| 257 | --version |
| 258 | Displays the version of ftpasswd. |
| 259 | |
| 260 | If used with --group, ftpasswd creates a file in the group(5) format, |
| 261 | suitable for use with proftpd's AuthGroupFile configuration directive. |
| 262 | |
| 263 | By default, using --group will write output to "./ftpd.group". |
| 264 | |
| 265 | Options: |
| 266 | |
| 267 | --delete-group |
| 268 | |
| 269 | Remove the entry for the given group name from the file. |
| 270 | |
| 271 | --enable-group-passwd |
| 272 | |
| 273 | Prompt for a group password. This is disabled by default, |
| 274 | as group passwords are not usually a good idea at all. |
| 275 | |
| 276 | --file Write output to specified file, rather than "./ftpd.group" |
| 277 | |
| 278 | -F If the file be used already exists, delete it and write a new |
| 279 | --force one. By default, new entries will be appended to the file. |
| 280 | |
| 281 | --gid Numerical group ID (required) |
| 282 | |
| 283 | -h |
| 284 | --help Displays this message |
| 285 | |
| 286 | -m |
| 287 | --member User to be a member of the group. This argument may be used |
| 288 | multiple times to specify the full list of users to be members |
| 289 | of this group. |
| 290 | |
| 291 | --des Use the DES algorithm for encrypting passwords. The default |
| 292 | is the MD5 algorithm. |
| 293 | |
| 294 | --md5 Use the MD5 algorithm for encrypting passwords. This is the |
| 295 | default. |
| 296 | |
| 297 | --name Name of the group (required). If the name does not exist in |
| 298 | the specified output-file, an entry will be created for them. |
| 299 | Otherwise, the given fields will be updated. |
| 300 | |
| 301 | --sha256 Use the SHA-256 algorithm for encrypting passwords. |
| 302 | |
| 303 | --sha512 Use the SHA-512 algorithm for encrypting passwords. |
| 304 | |
| 305 | --stdin |
| 306 | Read the password directly from standard in rather than |
| 307 | prompting for it. This is useful for writing scripts that |
| 308 | automate use of ftpasswd. |
| 309 | |
| 310 | --use-cracklib |
| 311 | Causes ftpasswd to use Alec Muffet's cracklib routines in |
| 312 | order to determine and prevent the use of bad or weak |
| 313 | passwords. The optional path to this option specifies |
| 314 | the path to the dictionary files to use -- default path |
| 315 | is "/usr/lib/cracklib_dict". This requires the Perl |
| 316 | Crypt::Cracklib module to be installed on your system. |
| 317 | |
| 318 | --version |
| 319 | Displays the version of ftpasswd. |
| 320 | |
| 321 | If used with --hash, ftpasswd generates a hash of a password, as would |
| 322 | appear in an AuthUserFile. The hash is written to standard out. |
| 323 | This hash is suitable for use with proftpd's UserPassword directive. |
| 324 | |
| 325 | Options: |
| 326 | |
| 327 | --des Use the DES algorithm for encrypting passwords. The default |
| 328 | is the MD5 algorithm. |
| 329 | |
| 330 | --md5 Use the MD5 algorithm for encrypting passwords. This is the |
| 331 | default. |
| 332 | |
| 333 | --sha256 Use the SHA-256 algorithm for encrypting passwords. |
| 334 | |
| 335 | --sha512 Use the SHA-512 algorithm for encrypting passwords. |
| 336 | |
| 337 | --stdin |
| 338 | Read the password directly from standard in rather than |
| 339 | prompting for it. This is useful for writing scripts that |
| 340 | automate use of ftpasswd. |
| 341 | |
| 342 | --use-cracklib |
| 343 | Causes ftpasswd to use Alec Muffet's cracklib routines in |
| 344 | order to determine and prevent the use of bad or weak |
| 345 | passwords. The optional path to this option specifies |
| 346 | the path to the dictionary files to use -- default path |
| 347 | is "/usr/lib/cracklib_dict". This requires the Perl |
| 348 | Crypt::Cracklib module to be installed on your system. |
| 349 | </pre> |
| 350 | |
| 351 | <p> |
| 352 | <br><hr> |
| 353 | <font size=2><b><i> |
| 354 | © Copyright 2000-2016 TJ Saunders<br> |
| 355 | All Rights Reserved<br> |
| 356 | </i></b></font> |
| 357 | <hr><br> |
| 358 | |
| 359 | </body> |
| 360 | </html> |