.\" $OpenBSD: htpasswd.1,v 1.17 2010/09/03 11:22:36 jmc Exp $ .\" .\" ==================================================================== .\" The Apache Software License, Version 1.1 .\" .\" Copyright (c) 2000-2003 The Apache Software Foundation. All rights .\" reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in .\" the documentation and/or other materials provided with the .\" distribution. .\" .\" 3. The end-user documentation included with the redistribution, .\" if any, must include the following acknowledgment: .\" "This product includes software developed by the .\" Apache Software Foundation (http://www.apache.org/)." .\" Alternately, this acknowledgment may appear in the software itself, .\" if and wherever such third-party acknowledgments normally appear. .\" .\" 4. The names "Apache" and "Apache Software Foundation" must .\" not be used to endorse or promote products derived from this .\" software without prior written permission. For written .\" permission, please contact apache@apache.org. .\" .\" 5. Products derived from this software may not be called "Apache", .\" nor may "Apache" appear in their name, without prior written .\" permission of the Apache Software Foundation. .\" .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED .\" WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE .\" DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR .\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF .\" USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND .\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, .\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT .\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" ==================================================================== .\" .\" This software consists of voluntary contributions made by many .\" individuals on behalf of the Apache Software Foundation. For more .\" information on the Apache Software Foundation, please see .\" . .\" .\" Portions of this software are based upon public domain software .\" originally written at the National Center for Supercomputing Applications, .\" University of Illinois, Urbana-Champaign. .\" .Dd $Mdocdate: September 3 2010 $ .Dt HTPASSWD 1 .Os .Sh NAME .Nm htpasswd .Nd create and update user authentication files .Sh SYNOPSIS .Nm .Op Fl c .Oo .Fl d | l | m | p | s .Oc .Ar passwordfile .Ar username .Nm .Fl b .Op Fl c .Oo .Fl d | l | m | p | s .Oc .Ar passwordfile .Ar username .Ar password .Nm .Fl n .Oo .Fl d | l | m | p | s .Oc .Ar username .Nm .Fl bn .Oo .Fl d | l | m | p | s .Oc .Ar username .Ar password .Sh DESCRIPTION .Nm is used to create and update the flat-files used to store usernames and password for basic authentication of HTTP users. If .Nm 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. .Pp Resources available from the .Xr httpd 8 Apache web server can be restricted to just the users listed in the files created by .Nm . 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 .Xr dbmmanage 1 . .Pp .Nm encrypts passwords using either a version of MD5 modified for Apache, the system's .Xr crypt 3 routine (the default), or SHA encryption. Files managed by .Nm 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 .Xr crypt 3 . .Pp This manual page only lists the command line arguments. For details of the directives necessary to configure user authentication in .Xr httpd 8 , see the Apache manual, which can be found in .Pa /usr/share/doc/html/httpd/ . .Pp The options are as follows: .Bl -tag -width "passwordfileXX" .It Fl b Use batch mode i.e. get the password from the command line rather than prompting for it. .Bf -symbolic This option should not be used, since the password is clearly visible on the command line. .Ef .It Fl c Create the .Ar passwordfile . If .Ar passwordfile already exists, it is rewritten and truncated. This option cannot be combined with the .Fl n option. .It Fl d Use DES-based .Xr crypt 3 encryption for passwords. .It Fl l Use Blowfish-based .Xr crypt 3 encryption for passwords. This is the default. .It Fl m 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. .It Fl n 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 .Ar passwdfile argument (usually the first one) is omitted. It cannot be combined with the .Fl c option. .It Fl p Use plaintext passwords. Although .Nm supports the creation of plaintext passwords, .Xr httpd 8 will not accept plaintext passwords on .Ox . .It Fl s Use SHA encryption for passwords. Facilitates migration from/to Netscape servers using the LDAP Directory Interchange Format (LDIF). .It Ar password The plaintext password to be encrypted and stored in the file. Only used with the .Fl b flag. .It Ar passwordfile Name of the file to contain the username and password. If .Fl c is given, this file is created if it does not already exist, or rewritten and truncated if it does exist. .It Ar username The .Ar username to create or update in .Ar passwordfile . If .Ar username does not exist in this file, an entry is added. If it does exist, the password is changed. .El .Pp Web password files such as those managed by .Nm should .Em not be within the Web server's URI space \(em that is, although the password files .Em must be contained within .Dq ServerRoot , they should not be located in .Dq DocumentRoot . .Sh EXIT STATUS The exit codes returned are: .Pp .Bl -tag -width "XXX" -offset indent -compact .It 0 operation completed successfully .It 1 problem accessing files .It 2 syntax problem with the command line .It 3 the password was entered interactively and the verification entry didn't match .It 4 the operation was interrupted .It 5 a value is too long (username, filename, password, or final computed record) .It 6 the username contains illegal characters (see the .Sx CAVEATS section, below) .El .Sh EXAMPLES Add or modify the password for user .Dq jsmith . The user is prompted for the password. If the file does not exist, .Nm will do nothing except return an error: .Pp .Dl # htpasswd /var/www/conf/.htpasswd-users jsmith .Pp Create a new file and store a record in it for user .Dq 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 .Nm will display a message and return an error status: .Pp .Dl # htpasswd -cm /var/www/conf/.htpasswd jane .Sh SEE ALSO .Xr dbmmanage 1 , .Xr htdigest 1 , .Xr crypt 3 , .Xr httpd 8 .Pp The scripts in .Pa support/SHA1/ which come with the distribution. .Sh CAVEATS The MD5 algorithm used by .Nm is specific to Apache software: passwords encrypted using it will not be usable with other Web servers. .Pp Usernames are limited to 255 bytes and may not include the character .Sq :\& .