summaryrefslogtreecommitdiffstats
path: root/usr.sbin/httpd/src/support/htpasswd.1
blob: 663de03d2377153b599d8a0efc25e5f71f253003 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
.\"	$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
.\" <http://www.apache.org/>.
.\"
.\" 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 :\& .