OpenBSD manual page server

Manual Page Search Parameters

HTPASSWD(1) General Commands Manual HTPASSWD(1)

htpasswdcreate and update user authentication files

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

htpasswd is used to create and update the flat-files used to store usernames 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:

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.
Create the passwordfile. If passwordfile already exists, it is rewritten and truncated. This option cannot be combined with the -n option.
Use DES-based crypt(3) encryption for passwords.
Use Blowfish-based crypt(3) encryption for passwords. This is the default.
Use Apache's modified MD5 algorithm for passwords. Passwords encrypted with this algorithm are transportable to any platform (Windows, Unix, BeOS, et cetera) running Apache 1.3.9 or later.
Display the results on standard output rather than updating 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 command line, since the passwdfile argument (usually the first one) is omitted. It cannot be combined with the -c option.
Use plaintext passwords. Although htpasswd supports the creation of plaintext passwords, httpd(8) will not accept plaintext passwords on OpenBSD.
Use SHA encryption for passwords. Facilitates migration from/to Netscape servers using the LDAP Directory Interchange Format (LDIF).
The plaintext password to be encrypted and stored in the file. Only used with the -b flag.
Name of the file to contain the username and password. If -c is given, this file is created if it does not already exist, or rewritten and truncated if it does exist.
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 be within the Web server's URI space — that is, although the password files be contained within “ServerRoot”, they should not be located in “DocumentRoot”.

The exit codes returned are:

operation completed successfully
problem accessing files
syntax problem with the command line
the password was entered interactively and the verification entry didn't match
the operation was interrupted
a value is too long (username, filename, password, or final computed record)
the username contains illegal characters (see the CAVEATS section, below)

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 except 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 exists 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

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

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

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

Usernames are limited to 255 bytes and may not include the character ‘:’.

September 3, 2010 OpenBSD-5.3