1HTPASSWD(1) htpasswd HTPASSWD(1)
2
3
4
6 htpasswd - Manage user files for basic authentication
7
8
10 htpasswd [ -c ] [ -i ] [ -m | -B | -d | -s | -p ] [ -C cost ] [ -D ] [
11 -v ] passwdfile username
12
13
14 htpasswd -b [ -c ] [ -m | -B | -d | -s | -p ] [ -C cost ] [ -D ] [ -v ]
15 passwdfile username password
16
17
18 htpasswd -n [ -i ] [ -m | -B | -d | -s | -p ] [ -C cost ] username
19
20
21 htpasswd -nb [ -m | -B | -d | -s | -p ] [ -C cost ] username password
22
23
24
26 htpasswd is used to create and update the flat-files used to store
27 usernames and password for basic authentication of HTTP users. If
28 htpasswd cannot access a file, such as not being able to write to the
29 output file or not being able to read the file in order to update it,
30 it returns an error status and makes no changes.
31
32
33 Resources available from the Apache HTTP server can be restricted to
34 just the users listed in the files created by htpasswd. This program
35 can only manage usernames and passwords stored in a flat-file. It can
36 encrypt and display password information for use in other types of data
37 stores, though. To use a DBM database see dbmmanage or htdbm.
38
39
40 htpasswd encrypts passwords using either bcrypt, a version of MD5 modi‐
41 fied for Apache, SHA1, or the system's crypt() routine. Files managed
42 by htpasswd may contain a mixture of different encoding types of pass‐
43 words; some user records may have bcrypt or MD5-encrypted passwords
44 while others in the same file may have passwords encrypted with
45 crypt().
46
47
48 This manual page only lists the command line arguments. For details of
49 the directives necessary to configure user authentication in httpd see
50 the Apache manual, which is part of the Apache distribution or can be
51 found at http://httpd.apache.org/.
52
53
54
56 -b Use batch mode; i.e., get the password from the command line
57 rather than prompting for it. This option should be used with
58 extreme care, since the password is clearly visible on the com‐
59 mand line. For script use see the -i option.
60
61 -i Read the password from stdin without verification (for script
62 usage).
63
64 -c Create the passwdfile. If passwdfile already exists, it is
65 rewritten and truncated. This option cannot be combined with the
66 -n option.
67
68 -n Display the results on standard output rather than updating a
69 file. This is useful for generating password records acceptable
70 to Apache for inclusion in non-text data stores. This option
71 changes the syntax of the command line, since the passwdfile
72 argument (usually the first one) is omitted. It cannot be com‐
73 bined with the -c option.
74
75 -m Use MD5 encryption for passwords. This is the default (since
76 version 2.2.18).
77
78 -B Use bcrypt encryption for passwords. This is currently consid‐
79 ered to be very secure.
80
81 -C This flag is only allowed in combination with -B (bcrypt encryp‐
82 tion). It sets the computing time used for the bcrypt algorithm
83 (higher is more secure but slower, default: 5, valid: 4 to 31).
84
85 -d Use crypt() encryption for passwords. This is not supported by
86 the httpd server on Windows and Netware. This algorithm limits
87 the password length to 8 characters. This algorithm is insecure
88 by today's standards. It used to be the default algorithm until
89 version 2.2.17.
90
91 -s Use SHA encryption for passwords. Facilitates migration from/to
92 Netscape servers using the LDAP Directory Interchange Format
93 (ldif). This algorithm is insecure by today's standards.
94
95 -p Use plaintext passwords. Though htpasswd will support creation
96 on all platforms, the httpd daemon will only accept plain text
97 passwords on Windows and Netware.
98
99 -D Delete user. If the username exists in the specified htpasswd
100 file, it will be deleted.
101
102 -v Verify password. Verify that the given password matches the
103 password of the user stored in the specified htpasswd file.
104
105 passwdfile
106 Name of the file to contain the user name and password. If -c is
107 given, this file is created if it does not already exist, or
108 rewritten and truncated if it does exist.
109
110 username
111 The username to create or update in passwdfile. If username does
112 not exist in this file, an entry is added. If it does exist, the
113 password is changed.
114
115 password
116 The plaintext password to be encrypted and stored in the file.
117 Only used with the -b flag.
118
119
121 htpasswd returns a zero status ("true") if the username and password
122 have been successfully added or updated in the passwdfile. htpasswd
123 returns 1 if it encounters some problem accessing files, 2 if there was
124 a syntax problem with the command line, 3 if the password was entered
125 interactively and the verification entry didn't match, 4 if its opera‐
126 tion was interrupted, 5 if a value is too long (username, filename,
127 password, or final computed record), 6 if the username contains illegal
128 characters (see the Restrictions section), and 7 if the file is not a
129 valid password file.
130
131
133 htpasswd /usr/local/etc/apache/.htpasswd-users jsmith
134
135
136
137 Adds or modifies the password for user jsmith. The user is prompted for
138 the password. The password will be encrypted using the modified Apache
139 MD5 algorithm. If the file does not exist, htpasswd will do nothing
140 except return an error.
141
142
143 htpasswd -c /home/doe/public_html/.htpasswd jane
144
145
146
147 Creates a new file and stores a record in it for user jane. The user is
148 prompted for the password. If the file exists and cannot be read, or
149 cannot be written, it is not altered and htpasswd will display a mes‐
150 sage and return an error status.
151
152
153 htpasswd -db /usr/web/.htpasswd-all jones Pwd4Steve
154
155
156
157 Encrypts the password from the command line (Pwd4Steve) using the
158 crypt() algorithm, and stores it in the specified file.
159
160
162 Web password files such as those managed by htpasswd should not be
163 within the Web server's URI space -- that is, they should not be fetch‐
164 able with a browser.
165
166
167 This program is not safe as a setuid executable. Do not make it setuid.
168
169
170 The use of the -b option is discouraged, since when it is used the
171 unencrypted password appears on the command line.
172
173
174 When using the crypt() algorithm, note that only the first 8 characters
175 of the password are used to form the password. If the supplied password
176 is longer, the extra characters will be silently discarded.
177
178
179 The SHA encryption format does not use salting: for a given password,
180 there is only one encrypted representation. The crypt() and MD5 formats
181 permute the representation by prepending a random salt string, to make
182 dictionary attacks against the passwords more difficult.
183
184
185 The SHA and crypt() formats are insecure by today's standards.
186
187
189 On the Windows platform, passwords encrypted with htpasswd are limited
190 to no more than 255 characters in length. Longer passwords will be
191 truncated to 255 characters.
192
193
194 The MD5 algorithm used by htpasswd is specific to the Apache software;
195 passwords encrypted using it will not be usable with other Web servers.
196
197
198 Usernames are limited to 255 bytes and may not include the character :.
199
200
201
202
203Apache HTTP Server 2013-07-06 HTPASSWD(1)