HTPASSWD(1)                OpenBSD Reference Manual                HTPASSWD(1)

NAME
     htpasswd - create and update user authentication files

SYNOPSIS
     htpasswd [-c] [-d | -l | -m | -p | -s] passwordfile username
     htpasswd -b [-c] [-d | -l | -m | -p | -s] passwordfile username password
     htpasswd -n [-d | -l | -m | -p | -s] username
     htpasswd -bn [-d | -l | -m | -p | -s] username password

DESCRIPTION
     htpasswd is used to create and update the flat-files used to store user-
     names and password for basic authentication of HTTP users.  If htpasswd
     cannot access a file, such as not being able to write to the output file
     or not being able to read the file in order to update it, it returns an
     error status and makes no changes.

     Resources available from the httpd(8) Apache web server can be restricted
     to just the users listed in the files created by htpasswd.  This program
     can only manage usernames and passwords stored in a flat-file.  It can
     encrypt and display password information for use in other types of data
     stores, though.  To use a DBM database see dbmmanage(1).

     htpasswd encrypts passwords using either a version of MD5 modified for
     Apache, the system's crypt(3) routine (the default), or SHA encryption.
     Files managed by htpasswd may contain all types of passwords e.g. some
     user records may have MD5-encrypted passwords while others in the same
     file have passwords encrypted with crypt(3).

     This manual page only lists the command line arguments.  For details of
     the directives necessary to configure user authentication in httpd(8),
     see the Apache manual, which can be found in /usr/share/doc/html/httpd/.

     The options are as follows:

     -b              Use batch mode i.e. get the password from the command
                     line rather than prompting for it.  This option should
                     not be used, since the password is clearly visible on the
                     command line.

     -c              Create the passwordfile.  If passwordfile already exists,
                     it is rewritten and truncated.  This option cannot be
                     combined with the -n option.

     -d              Use DES-based crypt(3) encryption for passwords.

     -l              Use Blowfish-based crypt(3) encryption for passwords.
                     This is the default.

     -m              Use Apache's modified MD5 algorithm for passwords.  Pass-
                     words encrypted with this algorithm are transportable to
                     any platform (Windows, Unix, BeOS, et cetera) running
                     Apache 1.3.9 or later.

     -n              Display the results on standard output rather than updat-
                     ing a file.  This is useful for generating password
                     records acceptable to Apache for inclusion in non-text
                     data stores.  This option changes the syntax of the com-
                     mand line, since the passwdfile argument (usually the
                     first one) is omitted.  It cannot be combined with the -c
                     option.

     -p              Use plaintext passwords.  Although htpasswd supports the
                     creation of plaintext passwords, httpd(8) will not accept
                     plaintext passwords on OpenBSD.

     -s              Use SHA encryption for passwords.  Facilitates migration
                     from/to Netscape servers using the LDAP Directory Inter-
                     change Format (LDIF).

     password        The plaintext password to be encrypted and stored in the
                     file.  Only used with the -b flag.

     passwordfile    Name of the file to contain the username and password.
                     If -c is given, this file is created if it does not al-
                     ready exist, or rewritten and truncated if it does exist.

     username        The username to create or update in passwordfile.  If
                     username does not exist in this file, an entry is added.
                     If it does exist, the password is changed.

     Web password files such as those managed by htpasswd should not be within
     the Web server's URI space -- that is, although the password files must
     be contained within ``ServerRoot'', they should not be located in
     ``DocumentRoot''.

     The htpasswd utility exits 0 on success, and >0 if an error occurs.  The
     exit codes returned are:

           0    operation completed successfully
           1    problem accessing files
           2    syntax problem with the command line
           3    the password was entered interactively and the verification
                entry didn't match
           4    the operation was interrupted
           5    a value is too long (username, filename, password, or final
                computed record)
           6    the username contains illegal characters (see the CAVEATS sec-
                tion, below)

EXAMPLES
     Add or modify the password for user ``jsmith''.  The user is prompted for
     the password.  If the file does not exist, htpasswd will do nothing ex-
     cept return an error:

           # htpasswd /var/www/conf/.htpasswd-users jsmith

     Create a new file and store a record in it for user ``jane'', using the
     MD5 algorithm.  The user is prompted for the password.  If the file ex-
     ists and cannot be read, or cannot be written, it is not altered and
     htpasswd will display a message and return an error status:

           # htpasswd -cm /var/www/conf/.htpasswd jane

SEE ALSO
     dbmmanage(1), htdigest(1), crypt(3), httpd(8)

     The scripts in support/SHA1/ which come with the distribution.

CAVEATS
     The MD5 algorithm used by htpasswd is specific to Apache software: pass-
     words encrypted using it will not be usable with other Web servers.

     Usernames are limited to 255 bytes and may not include the character `:'.

OpenBSD 4.7                      June 7, 2008                                2
