switch to a 60 bit hash
[httpd-crcsyncproxy.git] / docs / manual / programs / htpasswd.html.en
blobb3cae555a232c917810e24fd199436e7f5b14fc6
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</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" />
12 <link href="../images/favicon.ico" rel="shortcut icon" /></head>
13 <body id="manual-page"><div id="page-header">
14 <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p>
15 <p class="apache">Apache HTTP Server Version 2.3</p>
16 <img alt="" src="../images/feather.gif" /></div>
17 <div class="up"><a href="./"><img title="&lt;-" alt="&lt;-" src="../images/left.gif" /></a></div>
18 <div id="path">
19 <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.3</a> &gt; <a href="./">Programs</a></div><div id="page-content"><div id="preamble"><h1>htpasswd - Manage user files for basic authentication</h1>
20 <div class="toplang">
21 <p><span>Available Languages: </span><a href="../en/programs/htpasswd.html" title="English">&nbsp;en&nbsp;</a> |
22 <a href="../ko/programs/htpasswd.html" hreflang="ko" rel="alternate" title="Korean">&nbsp;ko&nbsp;</a> |
23 <a href="../tr/programs/htpasswd.html" hreflang="tr" rel="alternate" title="Türkçe">&nbsp;tr&nbsp;</a></p>
24 </div>
26 <p><code>htpasswd</code> is used to create and update the flat-files used to
27 store usernames and password for basic authentication of HTTP users. If
28 <code>htpasswd</code> cannot access a file, such as not being able to write
29 to the 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.</p>
32 <p>Resources available from the Apache HTTP server can be restricted to
33 just the users listed in the files created by <code>htpasswd</code>. This
34 program can only manage usernames and passwords stored in a flat-file. It
35 can encrypt and display password information for use in other types of data
36 stores, though. To use a DBM database see <code class="program"><a href="../programs/dbmmanage.html">dbmmanage</a></code>.</p>
38 <p><code>htpasswd</code> encrypts passwords using either a version of MD5
39 modified for Apache, or the system's <code>crypt()</code> routine. Files
40 managed by <code>htpasswd</code> may contain both types of passwords; some
41 user records may have MD5-encrypted passwords while others in the same file
42 may have passwords encrypted with <code>crypt()</code>.</p>
44 <p>This manual page only lists the command line arguments. For details of
45 the directives necessary to configure user authentication in
46 <code class="program"><a href="../programs/httpd.html">httpd</a></code> see the Apache manual, which is part of the
47 Apache distribution or can be found at <a href="http://httpd.apache.org">http://httpd.apache.org/</a>.</p>
48 </div>
49 <div id="quickview"><ul id="toc"><li><img alt="" src="../images/down.gif" /> <a href="#synopsis">Synopsis</a></li>
50 <li><img alt="" src="../images/down.gif" /> <a href="#options">Options</a></li>
51 <li><img alt="" src="../images/down.gif" /> <a href="#exit">Exit Status</a></li>
52 <li><img alt="" src="../images/down.gif" /> <a href="#examples">Examples</a></li>
53 <li><img alt="" src="../images/down.gif" /> <a href="#security">Security Considerations</a></li>
54 <li><img alt="" src="../images/down.gif" /> <a href="#restrictions">Restrictions</a></li>
55 </ul><h3>See also</h3><ul class="seealso"><li><code class="program"><a href="../programs/httpd.html">httpd</a></code></li><li>The scripts in support/SHA1 which come with the
56 distribution.</li></ul></div>
57 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
58 <div class="section">
59 <h2><a name="synopsis" id="synopsis">Synopsis</a></h2>
60 <p><code><strong>htpasswd</strong>
61 [ -<strong>c</strong> ]
62 [ -<strong>m</strong> ]
63 [ -<strong>D</strong> ] <var>passwdfile</var> <var>username</var></code></p>
65 <p><code><strong>htpasswd</strong> -<strong>b</strong>
66 [ -<strong>c</strong> ]
67 [ -<strong>m</strong> |
68 -<strong>d</strong> |
69 -<strong>p</strong> |
70 -<strong>s</strong> ]
71 [ -<strong>D</strong> ] <var>passwdfile</var> <var>username</var>
72 <var>password</var></code></p>
74 <p><code><strong>htpasswd</strong> -<strong>n</strong>
75 [ -<strong>m</strong> |
76 -<strong>d</strong> |
77 -<strong>s</strong> |
78 -<strong>p</strong> ] <var>username</var></code></p>
80 <p><code><strong>htpasswd</strong> -<strong>nb</strong>
81 [ -<strong>m</strong> |
82 -<strong>d</strong> |
83 -<strong>s</strong> |
84 -<strong>p</strong> ] <var>username</var> <var>password</var></code></p>
85 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
86 <div class="section">
87 <h2><a name="options" id="options">Options</a></h2>
88 <dl>
89 <dt><code>-b</code></dt>
90 <dd>Use batch mode; <em>i.e.</em>, get the password from the command line
91 rather than prompting for it. This option should be used with extreme care,
92 since <strong>the password is clearly visible</strong> on the command
93 line.</dd>
95 <dt><code>-c</code></dt>
96 <dd>Create the <var>passwdfile</var>. If <var>passwdfile</var> already
97 exists, it is rewritten and truncated. This option cannot be combined with
98 the <code>-n</code> option.</dd>
100 <dt><code>-n</code></dt>
101 <dd>Display the results on standard output rather than updating a file.
102 This is useful for generating password records acceptable to Apache for
103 inclusion in non-text data stores. This option changes the syntax of the
104 command line, since the <var>passwdfile</var> argument (usually the first
105 one) is omitted. It cannot be combined with the <code>-c</code> option.</dd>
107 <dt><code>-m</code></dt>
108 <dd>Use MD5 encryption for passwords. On Windows, Netware and TPF, this is
109 the default.</dd>
111 <dt><code>-d</code></dt>
112 <dd>Use <code>crypt()</code> encryption for passwords. The default on all
113 platforms but Windows, Netware and TPF. Though possibly supported by
114 <code>htpasswd</code> on all platforms, it is not supported by the
115 <code class="program"><a href="../programs/httpd.html">httpd</a></code> server on Windows, Netware and TPF.</dd>
117 <dt><code>-s</code></dt>
118 <dd>Use SHA encryption for passwords. Facilitates migration from/to Netscape
119 servers using the LDAP Directory Interchange Format (ldif).</dd>
121 <dt><code>-p</code></dt>
122 <dd>Use plaintext passwords. Though <code>htpasswd</code> will support
123 creation on all platforms, the <code class="program"><a href="../programs/httpd.html">httpd</a></code> daemon will
124 only accept plain text passwords on Windows, Netware and TPF.</dd>
126 <dt><code>-D</code></dt>
127 <dd>Delete user. If the username exists in the specified htpasswd file, it
128 will be deleted.</dd>
130 <dt><code><var>passwdfile</var></code></dt>
131 <dd>Name of the file to contain the user name and password. If
132 <code>-c</code> is given, this file is created if it does not already exist,
133 or rewritten and truncated if it does exist.</dd>
135 <dt><code><var>username</var></code></dt>
136 <dd>The username to create or update in <var>passwdfile</var>. If
137 <var>username</var> does not exist in this file, an entry is added. If it
138 does exist, the password is changed.</dd>
140 <dt><code><var>password</var></code></dt>
141 <dd>The plaintext password to be encrypted and stored in the file. Only
142 used with the <code>-b</code> flag.</dd>
143 </dl>
144 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
145 <div class="section">
146 <h2><a name="exit" id="exit">Exit Status</a></h2>
147 <p><code>htpasswd</code> returns a zero status ("true") if the username and
148 password have been successfully added or updated in the
149 <var>passwdfile</var>. <code>htpasswd</code> returns <code>1</code> if it
150 encounters some problem accessing files, <code>2</code> if there was a
151 syntax problem with the command line, <code>3</code> if the password was
152 entered interactively and the verification entry didn't match,
153 <code>4</code> if its operation was interrupted, <code>5</code> if a value
154 is too long (username, filename, password, or final computed record),
155 <code>6</code> if the username contains illegal characters (see the
156 <a href="#restrictions">Restrictions section</a>), and <code>7</code>
157 if the file is not a valid password file.</p>
158 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
159 <div class="section">
160 <h2><a name="examples" id="examples">Examples</a></h2>
161 <div class="example"><p><code>
162 htpasswd /usr/local/etc/apache/.htpasswd-users jsmith
163 </code></p></div>
165 <p>Adds or modifies the password for user <code>jsmith</code>. The user
166 is prompted for the password. If executed on a Windows system, the password
167 will be encrypted using the modified Apache MD5 algorithm; otherwise, the
168 system's <code>crypt()</code> routine will be used. If the file does not
169 exist, <code>htpasswd</code> will do nothing except return an error.</p>
171 <div class="example"><p><code>
172 htpasswd -c /home/doe/public_html/.htpasswd jane
173 </code></p></div>
175 <p>Creates a new file and stores a record in it for user <code>jane</code>.
176 The user is prompted for the password. If the file exists and cannot be
177 read, or cannot be written, it is not altered and <code>htpasswd</code>
178 will display a message and return an error status.</p>
180 <div class="example"><p><code>
181 htpasswd -mb /usr/web/.htpasswd-all jones Pwd4Steve
182 </code></p></div>
184 <p>Encrypts the password from the command line (<code>Pwd4Steve</code>)
185 using the MD5 algorithm, and stores it in the specified file.</p>
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="security" id="security">Security Considerations</a></h2>
189 <p>Web password files such as those managed by <code>htpasswd</code> should
190 <em>not</em> be within the Web server's URI space -- that is, they should
191 not be fetchable with a browser.</p>
193 <p>This program is not safe as a setuid executable. Do <em>not</em> make it
194 setuid.</p>
196 <p>The use of the <code>-b</code> option is discouraged, since when it is
197 used the unencrypted password appears on the command line.</p>
199 <p>When using the <code>crypt()</code> algorithm, note that only the first
200 8 characters of the password are used to form the password. If the supplied
201 password is longer, the extra characters will be silently discarded.</p>
203 <p>The SHA encryption format does not use salting: for a given password,
204 there is only one encrypted representation. The <code>crypt()</code> and
205 MD5 formats permute the representation by prepending a random salt string,
206 to make dictionary attacks against the passwords more difficult.</p>
207 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
208 <div class="section">
209 <h2><a name="restrictions" id="restrictions">Restrictions</a></h2>
210 <p>On the Windows and MPE platforms, passwords encrypted with
211 <code>htpasswd</code> are limited to no more than <code>255</code>
212 characters in length. Longer passwords will be truncated to 255
213 characters.</p>
215 <p>The MD5 algorithm used by <code>htpasswd</code> is specific to the Apache
216 software; passwords encrypted using it will not be usable with other Web
217 servers.</p>
219 <p>Usernames are limited to <code>255</code> bytes and may not include the
220 character <code>:</code>.</p>
221 </div></div>
222 <div class="bottomlang">
223 <p><span>Available Languages: </span><a href="../en/programs/htpasswd.html" title="English">&nbsp;en&nbsp;</a> |
224 <a href="../ko/programs/htpasswd.html" hreflang="ko" rel="alternate" title="Korean">&nbsp;ko&nbsp;</a> |
225 <a href="../tr/programs/htpasswd.html" hreflang="tr" rel="alternate" title="Türkçe">&nbsp;tr&nbsp;</a></p>
226 </div><div id="footer">
227 <p class="apache">Copyright 2009 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>
228 <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div>
229 </body></html>