]> granicus.if.org Git - apache/blob - docs/manual/programs/htpasswd.html.en
update transformation
[apache] / docs / manual / programs / htpasswd.html.en
1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
4         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
5               This file is generated from xml source: DO NOT EDIT
6         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
7       -->
8 <title>htpasswd - Manage user files for basic authentication - Apache HTTP Server Version 2.5</title>
9 <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
10 <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
11 <link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" />
12 <script src="../style/scripts/prettify.min.js" type="text/javascript">
13 </script>
14
15 <link href="../images/favicon.ico" rel="shortcut icon" /></head>
16 <body id="manual-page"><div id="page-header">
17 <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/quickreference.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p>
18 <p class="apache">Apache HTTP Server Version 2.5</p>
19 <img alt="" src="../images/feather.gif" /></div>
20 <div class="up"><a href="./"><img title="&lt;-" alt="&lt;-" src="../images/left.gif" /></a></div>
21 <div id="path">
22 <a href="http://www.apache.org/">Apache</a> &gt; <a href="http://httpd.apache.org/">HTTP Server</a> &gt; <a href="http://httpd.apache.org/docs/">Documentation</a> &gt; <a href="../">Version 2.5</a> &gt; <a href="./">Programs</a></div><div id="page-content"><div id="preamble"><h1>htpasswd - Manage user files for basic authentication</h1>
23 <div class="toplang">
24 <p><span>Available Languages: </span><a href="../en/programs/htpasswd.html" title="English">&nbsp;en&nbsp;</a> |
25 <a href="../ko/programs/htpasswd.html" hreflang="ko" rel="alternate" title="Korean">&nbsp;ko&nbsp;</a> |
26 <a href="../tr/programs/htpasswd.html" hreflang="tr" rel="alternate" title="Türkçe">&nbsp;tr&nbsp;</a></p>
27 </div>
28
29     <p><code>htpasswd</code> is used to create and update the flat-files used to
30     store usernames and password for basic authentication of HTTP users. If
31     <code>htpasswd</code> cannot access a file, such as not being able to write
32     to the output file or not being able to read the file in order to update it,
33     it returns an error status and makes no changes.</p>
34
35     <p>Resources available from the Apache HTTP server can be restricted to
36     just the users listed in the files created by <code>htpasswd</code>. This
37     program can only manage usernames and passwords stored in a flat-file. It
38     can encrypt and display password information for use in other types of data
39     stores, though. To use a DBM database see <code class="program"><a href="../programs/dbmmanage.html">dbmmanage</a></code> or
40     <code class="program"><a href="../programs/htdbm.html">htdbm</a></code>.</p>
41
42     <p><code>htpasswd</code> encrypts passwords using either bcrypt,
43     a version of MD5 modified for Apache, SHA1, or the system's
44     <code>crypt()</code> routine. Files
45     managed by <code>htpasswd</code> may contain a mixture of different encoding
46     types of passwords; some
47     user records may have bcrypt or MD5-encrypted passwords while others in the
48     same file may have passwords encrypted with <code>crypt()</code>.</p>
49
50     <p>This manual page only lists the command line arguments. For details of
51     the directives necessary to configure user authentication in
52     <code class="program"><a href="../programs/httpd.html">httpd</a></code> see the Apache manual, which is part of the
53     Apache distribution or can be found at <a href="http://httpd.apache.org">http://httpd.apache.org/</a>.</p>
54 </div>
55 <div id="quickview"><ul id="toc"><li><img alt="" src="../images/down.gif" /> <a href="#synopsis">Synopsis</a></li>
56 <li><img alt="" src="../images/down.gif" /> <a href="#options">Options</a></li>
57 <li><img alt="" src="../images/down.gif" /> <a href="#exit">Exit Status</a></li>
58 <li><img alt="" src="../images/down.gif" /> <a href="#examples">Examples</a></li>
59 <li><img alt="" src="../images/down.gif" /> <a href="#security">Security Considerations</a></li>
60 <li><img alt="" src="../images/down.gif" /> <a href="#restrictions">Restrictions</a></li>
61 </ul><h3>See also</h3><ul class="seealso"><li><code class="program"><a href="../programs/httpd.html">httpd</a></code></li><li><code class="program"><a href="../programs/htdbm.html">htdbm</a></code></li><li>The scripts in support/SHA1 which come with the
62 distribution.</li></ul><ul class="seealso"><li><a href="#comments_section">Comments</a></li></ul></div>
63 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
64 <div class="section">
65 <h2><a name="synopsis" id="synopsis">Synopsis</a></h2>
66     <p><code><strong>htpasswd</strong>
67     [ -<strong>c</strong> ]
68     [ -<strong>i</strong> ]
69     [ -<strong>m</strong> |
70       -<strong>B</strong> |
71       -<strong>d</strong> |
72       -<strong>s</strong> |
73       -<strong>p</strong> ]
74     [ -<strong>C</strong> <var>cost</var> ]
75     [ -<strong>D</strong> ]
76     [ -<strong>v</strong> ]  <var>passwdfile</var> <var>username</var></code></p>
77
78     <p><code><strong>htpasswd</strong> -<strong>b</strong>
79     [ -<strong>c</strong> ]
80     [ -<strong>m</strong> |
81       -<strong>B</strong> |
82       -<strong>d</strong> |
83       -<strong>s</strong> |
84       -<strong>p</strong> ]
85     [ -<strong>C</strong> <var>cost</var> ]
86     [ -<strong>D</strong> ]
87     [ -<strong>v</strong> ]  <var>passwdfile</var> <var>username</var>
88     <var>password</var></code></p>
89
90     <p><code><strong>htpasswd</strong> -<strong>n</strong>
91     [ -<strong>i</strong> ]
92     [ -<strong>m</strong> |
93       -<strong>B</strong> |
94       -<strong>d</strong> |
95       -<strong>s</strong> |
96       -<strong>p</strong> ]
97     [ -<strong>C</strong> <var>cost</var> ] <var>username</var></code></p>
98
99     <p><code><strong>htpasswd</strong> -<strong>nb</strong>
100     [ -<strong>m</strong> |
101       -<strong>B</strong> |
102       -<strong>d</strong> |
103       -<strong>s</strong> |
104       -<strong>p</strong> ]
105     [ -<strong>C</strong> <var>cost</var> ] <var>username</var>
106     <var>password</var></code></p>
107 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
108 <div class="section">
109 <h2><a name="options" id="options">Options</a></h2>
110     <dl>
111     <dt><code>-b</code></dt>
112     <dd>Use batch mode; <em>i.e.</em>, get the password from the command line
113     rather than prompting for it. This option should be used with extreme care,
114     since <strong>the password is clearly visible</strong> on the command
115     line. For script use see the <code>-i</code> option.<br />
116     Available in 2.4.4 and later.</dd>
117
118     <dt><code>-i</code></dt>
119     <dd>Read the password from stdin without verification (for script usage).</dd>
120
121     <dt><code>-c</code></dt>
122     <dd>Create the <var>passwdfile</var>. If <var>passwdfile</var> already
123     exists, it is rewritten and truncated. This option cannot be combined with
124     the <code>-n</code> option.</dd>
125
126     <dt><code>-n</code></dt>
127     <dd>Display the results on standard output rather than updating a file.
128     This is useful for generating password records acceptable to Apache for
129     inclusion in non-text data stores. This option changes the syntax of the
130     command line, since the <var>passwdfile</var> argument (usually the first
131     one) is omitted. It cannot be combined with the <code>-c</code> option.</dd>
132
133     <dt><code>-m</code></dt>
134     <dd>Use MD5 encryption for passwords. This is the default (since version
135     2.2.18).</dd>
136
137     <dt><code>-B</code></dt>
138     <dd>Use bcrypt encryption for passwords. This is currently considered to
139     be very secure.</dd>
140
141     <dt><code>-C</code></dt>
142     <dd>This flag is only allowed in combination with <code>-B</code> (bcrypt
143     encryption). It sets the computing time used for the bcrypt algorithm
144     (higher is more secure but slower, default: 5, valid: 4 to 31).</dd>
145
146     <dt><code>-d</code></dt>
147     <dd>Use <code>crypt()</code> encryption for passwords. This is not
148     supported by the <code class="program"><a href="../programs/httpd.html">httpd</a></code> server on Windows and
149     Netware. This algorithm limits the password length to 8 characters.
150     This algorithm is <strong>insecure</strong> by today's standards.
151     It used to be the default algorithm until version 2.2.17.</dd>
152
153     <dt><code>-s</code></dt>
154     <dd>Use SHA encryption for passwords. Facilitates migration from/to Netscape
155     servers using the LDAP Directory Interchange Format (ldif).
156     This algorithm is <strong>insecure</strong> by today's standards.</dd>
157
158     <dt><code>-p</code></dt>
159     <dd>Use plaintext passwords. Though <code>htpasswd</code> will support
160     creation on all platforms, the <code class="program"><a href="../programs/httpd.html">httpd</a></code> daemon will
161     only accept plain text passwords on Windows and Netware.</dd>
162
163     <dt><code>-D</code></dt>
164     <dd>Delete user. If the username exists in the specified htpasswd file, it
165     will be deleted.</dd>
166
167     <dt><code>-v</code></dt>
168     <dd>Verify password. Verify that the given password matches the password
169     of the user stored in the specified htpasswd file.<br />
170     Available in 2.4.5 and later.</dd>
171
172     <dt><code><var>passwdfile</var></code></dt>
173     <dd>Name of the file to contain the user name and password. If
174     <code>-c</code> is given, this file is created if it does not already exist,
175     or rewritten and truncated if it does exist.</dd>
176
177     <dt><code><var>username</var></code></dt>
178     <dd>The username to create or update in <var>passwdfile</var>. If
179     <var>username</var> does not exist in this file, an entry is added. If it
180     does exist, the password is changed.</dd>
181
182     <dt><code><var>password</var></code></dt>
183     <dd>The plaintext password to be encrypted and stored  in the file. Only
184     used with the <code>-b</code> flag.</dd>
185     </dl>
186 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
187 <div class="section">
188 <h2><a name="exit" id="exit">Exit Status</a></h2>
189     <p><code>htpasswd</code> returns a zero status ("true") if the username and
190     password have been successfully added or updated in the
191     <var>passwdfile</var>. <code>htpasswd</code> returns <code>1</code> if it
192     encounters some problem accessing files, <code>2</code> if there was a
193     syntax problem with the command line, <code>3</code> if the password was
194     entered interactively and the verification entry didn't match,
195     <code>4</code> if its operation was interrupted, <code>5</code> if a value
196     is too long (username, filename, password, or final computed record),
197     <code>6</code> if the username contains illegal characters (see the
198     <a href="#restrictions">Restrictions section</a>), and <code>7</code>
199     if the file is not a valid password file.</p>
200 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
201 <div class="section">
202 <h2><a name="examples" id="examples">Examples</a></h2>
203     <div class="example"><p><code>
204       htpasswd /usr/local/etc/apache/.htpasswd-users jsmith
205     </code></p></div>
206
207     <p>Adds or modifies the password for user <code>jsmith</code>. The user
208     is prompted for the password. The password will be encrypted using the
209     modified Apache MD5 algorithm. If the file does not exist,
210     <code>htpasswd</code> will do nothing except return an error.</p>
211
212     <div class="example"><p><code>
213       htpasswd -c /home/doe/public_html/.htpasswd jane
214     </code></p></div>
215
216     <p>Creates a new file and stores a record in it for user <code>jane</code>.
217     The user is prompted for the password. If the file exists and cannot be
218     read, or cannot be written, it is not altered and <code>htpasswd</code>
219     will display a message and return an error status.</p>
220
221     <div class="example"><p><code>
222       htpasswd -db /usr/web/.htpasswd-all jones Pwd4Steve
223     </code></p></div>
224
225     <p>Encrypts the password from the command line (<code>Pwd4Steve</code>)
226     using the <code>crypt()</code> algorithm, and stores it in the specified
227     file.</p>
228 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
229 <div class="section">
230 <h2><a name="security" id="security">Security Considerations</a></h2>
231     <p>Web password files such as those managed by <code>htpasswd</code> should
232     <em>not</em> be within the Web server's URI space -- that is, they should
233     not be fetchable with a browser.</p>
234
235     <p>This program is not safe as a setuid executable. Do <em>not</em> make it
236     setuid.</p>
237
238     <p>The use of the <code>-b</code> option is discouraged, since when it is
239     used the unencrypted password appears on the command line.</p>
240
241     <p>When using the <code>crypt()</code> algorithm, note that only the first
242     8 characters of the password are used  to form the password. If the supplied
243     password is longer, the extra characters will be silently discarded.</p>
244
245     <p>The SHA encryption format does not use salting: for a given password,
246     there is only one encrypted representation. The <code>crypt()</code> and
247     MD5 formats permute the representation by prepending a random salt string,
248     to make dictionary attacks against the passwords more difficult.</p>
249
250     <p>The SHA and <code>crypt()</code> formats are insecure by today's
251     standards.</p>
252 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
253 <div class="section">
254 <h2><a name="restrictions" id="restrictions">Restrictions</a></h2>
255     <p>On the Windows platform, passwords encrypted with
256     <code>htpasswd</code> are limited to no more than <code>255</code>
257     characters in length. Longer passwords will be truncated to 255
258     characters.</p>
259
260     <p>The MD5 algorithm used by <code>htpasswd</code> is specific to the Apache
261     software; passwords encrypted using it will not be usable with other Web
262     servers.</p>
263
264     <p>Usernames are limited to <code>255</code> bytes and may not include the
265     character <code>:</code>.</p>
266 </div></div>
267 <div class="bottomlang">
268 <p><span>Available Languages: </span><a href="../en/programs/htpasswd.html" title="English">&nbsp;en&nbsp;</a> |
269 <a href="../ko/programs/htpasswd.html" hreflang="ko" rel="alternate" title="Korean">&nbsp;ko&nbsp;</a> |
270 <a href="../tr/programs/htpasswd.html" hreflang="tr" rel="alternate" title="Türkçe">&nbsp;tr&nbsp;</a></p>
271 </div><div class="top"><a href="#page-header"><img src="../images/up.gif" alt="top" /></a></div><div class="section"><h2><a id="comments_section" name="comments_section">Comments</a></h2><div class="warning"><strong>Notice:</strong><br />This is not a Q&amp;A section. Comments placed here should be pointed towards suggestions on improving the documentation or server, and may be removed again by our moderators if they are either implemented or considered invalid/off-topic. Questions on how to manage the Apache HTTP Server should be directed at either our IRC channel, #httpd, on Freenode, or sent to our <a href="http://httpd.apache.org/lists.html">mailing lists</a>.</div>
272 <script type="text/javascript"><!--//--><![CDATA[//><!--
273 var comments_shortname = 'httpd';
274 var comments_identifier = 'http://httpd.apache.org/docs/trunk/programs/htpasswd.html';
275 (function(w, d) {
276     if (w.location.hostname.toLowerCase() == "httpd.apache.org") {
277         d.write('<div id="comments_thread"><\/div>');
278         var s = d.createElement('script');
279         s.type = 'text/javascript';
280         s.async = true;
281         s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier;
282         (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s);
283     }
284     else {
285         d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>');
286     }
287 })(window, document);
288 //--><!]]></script></div><div id="footer">
289 <p class="apache">Copyright 2014 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
290 <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/quickreference.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!--
291 if (typeof(prettyPrint) !== 'undefined') {
292     prettyPrint();
293 }
294 //--><!]]></script>
295 </body></html>