1HTPASSWD(1)                        htpasswd                        HTPASSWD(1)
2
3
4

NAME

6       htpasswd - Manage user files for basic authentication
7
8

SYNOPSIS

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

SUMMARY

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

OPTIONS

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. Available in  2.4.4
60              and later.
61
62       -i     Read  the  password  from stdin without verification (for script
63              usage).
64
65       -c     Create the passwdfile.  If  passwdfile  already  exists,  it  is
66              rewritten and truncated. This option cannot be combined with the
67              -n option.
68
69       -n     Display the results on standard output rather  than  updating  a
70              file.  This is useful for generating password records acceptable
71              to Apache for inclusion in non-text  data  stores.  This  option
72              changes  the  syntax  of  the command line, since the passwdfile
73              argument (usually the first one) is omitted. It cannot  be  com‐
74              bined with the -c option.
75
76       -m     Use  MD5  encryption  for  passwords. This is the default (since
77              version 2.2.18).
78
79       -B     Use bcrypt encryption for passwords. This is  currently  consid‐
80              ered to be very secure.
81
82       -C     This flag is only allowed in combination with -B (bcrypt encryp‐
83              tion). It sets the computing time used for the bcrypt  algorithm
84              (higher is more secure but slower, default: 5, valid: 4 to 31).
85
86       -d     Use  crypt()  encryption for passwords. This is not supported by
87              the httpd server on Windows and Netware. This  algorithm  limits
88              the  password length to 8 characters. This algorithm is insecure
89              by today's standards. It used to be the default algorithm  until
90              version 2.2.17.
91
92       -s     Use  SHA encryption for passwords. Facilitates migration from/to
93              Netscape servers using the  LDAP  Directory  Interchange  Format
94              (ldif). This algorithm is insecure by today's standards.
95
96       -p     Use  plaintext  passwords. Though htpasswd will support creation
97              on all platforms, the httpd daemon will only accept  plain  text
98              passwords on Windows and Netware.
99
100       -D     Delete  user.  If  the username exists in the specified htpasswd
101              file, it will be deleted.
102
103       -v     Verify password. Verify that  the  given  password  matches  the
104              password  of  the  user  stored  in the specified htpasswd file.
105              Available in 2.4.5 and later.
106
107       passwdfile
108              Name of the file to contain the user name and password. If -c is
109              given,  this  file  is  created if it does not already exist, or
110              rewritten and truncated if it does exist.
111
112       username
113              The username to create or update in passwdfile. If username does
114              not exist in this file, an entry is added. If it does exist, the
115              password is changed.
116
117       password
118              The plaintext password to be encrypted and stored in  the  file.
119              Only used with the -b flag.
120
121

EXIT STATUS

123       htpasswd  returns  a  zero status ("true") if the username and password
124       have been successfully added or updated  in  the  passwdfile.  htpasswd
125       returns 1 if it encounters some problem accessing files, 2 if there was
126       a syntax problem with the command line, 3 if the password  was  entered
127       interactively  and the verification entry didn't match, 4 if its opera‐
128       tion was interrupted, 5 if a value is  too  long  (username,  filename,
129       password, or final computed record), 6 if the username contains illegal
130       characters (see the Restrictions section), and 7 if the file is  not  a
131       valid password file.
132
133

EXAMPLES

135             htpasswd /usr/local/etc/apache/.htpasswd-users jsmith
136
137
138
139       Adds or modifies the password for user jsmith. The user is prompted for
140       the password. The password will be encrypted using the modified  Apache
141       MD5  algorithm.  If  the  file does not exist, htpasswd will do nothing
142       except return an error.
143
144
145             htpasswd -c /home/doe/public_html/.htpasswd jane
146
147
148
149       Creates a new file and stores a record in it for user jane. The user is
150       prompted  for  the  password. If the file exists and cannot be read, or
151       cannot be written, it is not altered and htpasswd will display  a  mes‐
152       sage and return an error status.
153
154
155             htpasswd -db /usr/web/.htpasswd-all jones Pwd4Steve
156
157
158
159       Encrypts  the  password  from  the  command  line (Pwd4Steve) using the
160       crypt() algorithm, and stores it in the specified file.
161
162

SECURITY CONSIDERATIONS

164       Web password files such as those managed  by  htpasswd  should  not  be
165       within the Web server's URI space -- that is, they should not be fetch‐
166       able with a browser.
167
168
169       This program is not safe as a setuid executable. Do not make it setuid.
170
171
172       The use of the -b option is discouraged, since  when  it  is  used  the
173       unencrypted password appears on the command line.
174
175
176       When using the crypt() algorithm, note that only the first 8 characters
177       of the password are used to form the password. If the supplied password
178       is longer, the extra characters will be silently discarded.
179
180
181       The  SHA  encryption format does not use salting: for a given password,
182       there is only one encrypted representation. The crypt() and MD5 formats
183       permute  the representation by prepending a random salt string, to make
184       dictionary attacks against the passwords more difficult.
185
186
187       The SHA and crypt() formats are insecure by today's standards.
188
189

RESTRICTIONS

191       On the Windows platform, passwords encrypted with htpasswd are  limited
192       to  no  more  than  255  characters in length. Longer passwords will be
193       truncated to 255 characters.
194
195
196       The MD5 algorithm used by htpasswd is specific to the Apache  software;
197       passwords encrypted using it will not be usable with other Web servers.
198
199
200       Usernames are limited to 255 bytes and may not include the character :.
201
202
203
204
205Apache HTTP Server                2018-07-06                       HTPASSWD(1)
Impressum