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