htpasswd.html.en revision a6eefe0439a6f06c92ae1ae6931acd21fcd9c031
f78ba66d5075af3e07e2d93aa7fa7b884836c6e8slive<?xml version="1.0" encoding="ISO-8859-1"?>
f78ba66d5075af3e07e2d93aa7fa7b884836c6e8slive<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
f78ba66d5075af3e07e2d93aa7fa7b884836c6e8slive<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
f78ba66d5075af3e07e2d93aa7fa7b884836c6e8slive XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
f78ba66d5075af3e07e2d93aa7fa7b884836c6e8slive This file is generated from xml source: DO NOT EDIT
f78ba66d5075af3e07e2d93aa7fa7b884836c6e8slive XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
5a58787efeb02a1c3f06569d019ad81fd2efa06end -->
5a58787efeb02a1c3f06569d019ad81fd2efa06end<title>htpasswd - Manage user files for basic authentication - Apache HTTP Server</title>
5a58787efeb02a1c3f06569d019ad81fd2efa06end<link href="/style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
5a58787efeb02a1c3f06569d019ad81fd2efa06end<link href="/style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
5a58787efeb02a1c3f06569d019ad81fd2efa06end<link href="/style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" />
5a58787efeb02a1c3f06569d019ad81fd2efa06end<link href="/images/favicon.ico" rel="shortcut icon" /></head>
00c2cccc28f249fb3b968ddf3e05508595290d40nd<body id="manual-page"><div id="page-header">
5a58787efeb02a1c3f06569d019ad81fd2efa06end<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>
52fff662005b1866a3ff09bb6c902800c5cc6dedjerenkrantz<p class="apache">Apache HTTP Server Version 2.1</p>
5a58787efeb02a1c3f06569d019ad81fd2efa06end<img alt="" src="/images/feather.gif" /></div>
5a58787efeb02a1c3f06569d019ad81fd2efa06end<div class="up"><a href="./"><img title="&lt;-" alt="&lt;-" src="/images/left.gif" /></a></div>
5a58787efeb02a1c3f06569d019ad81fd2efa06end<div id="path">
4b5981e276e93df97c34e4da05ca5cf8bbd937dand<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-project/">Documentation</a> &gt; <a href="../">Version 2.1</a> &gt; <a href="./">Programs</a></div><div id="page-content"><div id="preamble"><h1>htpasswd - Manage user files for basic authentication</h1>
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd<div class="toplang">
a78048ccbdb6256da15e6b0e7e95355e480c2301nd<p><span>Available Languages: </span><a href="/en/programs/htpasswd.html">&nbsp;en&nbsp;</a></p>
b05ab3ff5ab54aa22610b13d56eaba6ddfc3db60nd</div>
e23d878014f00a27b043a25e59f809c7af497e5ctakashi
e23d878014f00a27b043a25e59f809c7af497e5ctakashi <p><code>htpasswd</code> is used to create and update the flat-files used to
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd store usernames and password for basic authentication of HTTP users. If
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd <code>htpasswd</code> cannot access a file, such as not being able to write
f78ba66d5075af3e07e2d93aa7fa7b884836c6e8slive to the output file or not being able to read the file in order to update it,
f78ba66d5075af3e07e2d93aa7fa7b884836c6e8slive it returns an error status and makes no changes.</p>
5a58787efeb02a1c3f06569d019ad81fd2efa06end
5a58787efeb02a1c3f06569d019ad81fd2efa06end <p>Resources available from the Apache HTTP server can be restricted to
5a58787efeb02a1c3f06569d019ad81fd2efa06end just the users listed in the files created by <code>htpasswd</code>. This
5a58787efeb02a1c3f06569d019ad81fd2efa06end program can only manage usernames and passwords stored in a flat-file. It
f78ba66d5075af3e07e2d93aa7fa7b884836c6e8slive can encrypt and display password information for use in other types of data
f78ba66d5075af3e07e2d93aa7fa7b884836c6e8slive stores, though. To use a DBM database see <a href="dbmmanage.html">dbmmanage</a>.</p>
9bcfc3697a91b5215893a7d0206865b13fc72148nd
f78ba66d5075af3e07e2d93aa7fa7b884836c6e8slive <p><code>htpasswd</code> encrypts passwords using either a version of MD5
f78ba66d5075af3e07e2d93aa7fa7b884836c6e8slive modified for Apache, or the system's <code>crypt()</code> routine. Files
f78ba66d5075af3e07e2d93aa7fa7b884836c6e8slive managed by <code>htpasswd</code> may contain both types of passwords; some
9bcfc3697a91b5215893a7d0206865b13fc72148nd user records may have MD5-encrypted passwords while others in the same file
f78ba66d5075af3e07e2d93aa7fa7b884836c6e8slive may have passwords encrypted with <code>crypt()</code>.</p>
f78ba66d5075af3e07e2d93aa7fa7b884836c6e8slive
f78ba66d5075af3e07e2d93aa7fa7b884836c6e8slive <p>This manual page only lists the command line arguments. For details of
9bcfc3697a91b5215893a7d0206865b13fc72148nd the directives necessary to configure user authentication in
f78ba66d5075af3e07e2d93aa7fa7b884836c6e8slive <a href="httpd.html">httpd</a> see the Apache manual, which is part of the
f78ba66d5075af3e07e2d93aa7fa7b884836c6e8slive Apache distribution or can be found at <a href="http://httpd.apache.org">http://httpd.apache.org/</a>.</p>
f78ba66d5075af3e07e2d93aa7fa7b884836c6e8slive</div>
9bcfc3697a91b5215893a7d0206865b13fc72148nd<div id="quickview"><ul id="toc"><li><img alt="" src="/images/down.gif" /> <a href="#synopsis">Synopsis</a></li>
f78ba66d5075af3e07e2d93aa7fa7b884836c6e8slive<li><img alt="" src="/images/down.gif" /> <a href="#options">Options</a></li>
f78ba66d5075af3e07e2d93aa7fa7b884836c6e8slive<li><img alt="" src="/images/down.gif" /> <a href="#exit">Exit Status</a></li>
f78ba66d5075af3e07e2d93aa7fa7b884836c6e8slive<li><img alt="" src="/images/down.gif" /> <a href="#examples">Examples</a></li>
9bcfc3697a91b5215893a7d0206865b13fc72148nd<li><img alt="" src="/images/down.gif" /> <a href="#security">Security Considerations</a></li>
9ed703ab1543b3300f4b60c0405fc1a212b601c8slive<li><img alt="" src="/images/down.gif" /> <a href="#restrictions">Restrictions</a></li>
9ed703ab1543b3300f4b60c0405fc1a212b601c8slive</ul><h3>See also</h3><ul class="seealso"><li><a href="httpd.html">httpd</a></li><li><p>The scripts in support/SHA1 which come with the
9ed703ab1543b3300f4b60c0405fc1a212b601c8slivedistribution.</p></li></ul></div>
9bcfc3697a91b5215893a7d0206865b13fc72148nd<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
f78ba66d5075af3e07e2d93aa7fa7b884836c6e8slive<div class="section">
f78ba66d5075af3e07e2d93aa7fa7b884836c6e8slive<h2><a name="synopsis" id="synopsis">Synopsis</a></h2>
f78ba66d5075af3e07e2d93aa7fa7b884836c6e8slive <p><code><strong>htpasswd</strong>
f78ba66d5075af3e07e2d93aa7fa7b884836c6e8slive [ -<strong>c</strong> ]
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi [ -<strong>m</strong> ] <var>passwdfile</var> <var>username</var></code></p>
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi <p><code><strong>htpasswd</strong> -<strong>b</strong>
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi [ -<strong>c</strong> ]
9bcfc3697a91b5215893a7d0206865b13fc72148nd [ -<strong>m</strong> |
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi -<strong>d</strong> |
a8703cfb67133446eef7af1043640e71486e9ecand -<strong>p</strong> |
a8703cfb67133446eef7af1043640e71486e9ecand -<strong>s</strong> ] <var>passwdfile</var> <var>username</var>
9bcfc3697a91b5215893a7d0206865b13fc72148nd <var>password</var></code></p>
f78ba66d5075af3e07e2d93aa7fa7b884836c6e8slive
f78ba66d5075af3e07e2d93aa7fa7b884836c6e8slive <p><code><strong>htpasswd</strong> -<strong>n</strong>
f78ba66d5075af3e07e2d93aa7fa7b884836c6e8slive [ -<strong>m</strong> |
f78ba66d5075af3e07e2d93aa7fa7b884836c6e8slive -<strong>d</strong> |
8a5db6a3d29e28627bf8a6d6f7066e840da6bdf2jsl -<strong>s</strong> |
8a5db6a3d29e28627bf8a6d6f7066e840da6bdf2jsl -<strong>p</strong> ] <var>username</var></code></p>
8a5db6a3d29e28627bf8a6d6f7066e840da6bdf2jsl
8a5db6a3d29e28627bf8a6d6f7066e840da6bdf2jsl <p><code><strong>htpasswd</strong> -<strong>nb</strong>
9bcfc3697a91b5215893a7d0206865b13fc72148nd [ -<strong>m</strong> |
f78ba66d5075af3e07e2d93aa7fa7b884836c6e8slive -<strong>d</strong> |
f78ba66d5075af3e07e2d93aa7fa7b884836c6e8slive -<strong>s</strong> |
f78ba66d5075af3e07e2d93aa7fa7b884836c6e8slive -<strong>p</strong> ] <var>username</var> <var>password</var></code></p>
f78ba66d5075af3e07e2d93aa7fa7b884836c6e8slive</div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
ad099a822dc3de888a5294adf44b230bb9437f47rbowen<div class="section">
ad099a822dc3de888a5294adf44b230bb9437f47rbowen<h2><a name="options" id="options">Options</a></h2>
ad099a822dc3de888a5294adf44b230bb9437f47rbowen <dl>
ad099a822dc3de888a5294adf44b230bb9437f47rbowen <dt><code>-b</code></dt>
9bcfc3697a91b5215893a7d0206865b13fc72148nd <dd>Use batch mode; <em>i.e.</em>, get the password from the command line
f78ba66d5075af3e07e2d93aa7fa7b884836c6e8slive rather than prompting for it. This option should be used with extreme care,
f78ba66d5075af3e07e2d93aa7fa7b884836c6e8slive since <strong>the password is clearly visible</strong> on the command
f78ba66d5075af3e07e2d93aa7fa7b884836c6e8slive line.</dd>
f78ba66d5075af3e07e2d93aa7fa7b884836c6e8slive
392de67005213380d3b88f481ec1e8132935244drbowen <dt><code>-c</code></dt>
392de67005213380d3b88f481ec1e8132935244drbowen <dd>Create the <var>passwdfile</var>. If <var>passwdfile</var> already
392de67005213380d3b88f481ec1e8132935244drbowen exists, it is rewritten and truncated. This option cannot be combined with
392de67005213380d3b88f481ec1e8132935244drbowen the <code>-n</code> option.</dd>
9bcfc3697a91b5215893a7d0206865b13fc72148nd
f78ba66d5075af3e07e2d93aa7fa7b884836c6e8slive <dt><code>-n</code></dt>
f78ba66d5075af3e07e2d93aa7fa7b884836c6e8slive <dd>Display the results on standard output rather than updating a file.
f78ba66d5075af3e07e2d93aa7fa7b884836c6e8slive This is useful for generating password records acceptable to Apache for
392de67005213380d3b88f481ec1e8132935244drbowen inclusion in non-text data stores. This option changes the syntax of the
392de67005213380d3b88f481ec1e8132935244drbowen command line, since the <var>passwdfile</var> argument (usually the first
392de67005213380d3b88f481ec1e8132935244drbowen one) is omitted. It cannot be combined with the <code>-c</code> option.</dd>
392de67005213380d3b88f481ec1e8132935244drbowen
9bcfc3697a91b5215893a7d0206865b13fc72148nd <dt><code>-m</code></dt>
f78ba66d5075af3e07e2d93aa7fa7b884836c6e8slive <dd>Use MD5 encryption for passwords. On Windows, Netware and TPF, this is
f78ba66d5075af3e07e2d93aa7fa7b884836c6e8slive the default.</dd>
f78ba66d5075af3e07e2d93aa7fa7b884836c6e8slive
f78ba66d5075af3e07e2d93aa7fa7b884836c6e8slive <dt><code>-d</code></dt>
5a58787efeb02a1c3f06569d019ad81fd2efa06end <dd>Use <code>crypt()</code> encryption for passwords. The default on all
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd platforms but Windows, Netware and TPF. Though possibly supported by
a78048ccbdb6256da15e6b0e7e95355e480c2301nd <code>htpasswd</code> on all platforms, it is not supported by the
b05ab3ff5ab54aa22610b13d56eaba6ddfc3db60nd <a href="httpd.html">httpd</a> server on Windows, Netware and TPF.</dd>
e23d878014f00a27b043a25e59f809c7af497e5ctakashi
e23d878014f00a27b043a25e59f809c7af497e5ctakashi <dt><code>-s</code></dt>
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd <dd>Use SHA encryption for passwords. Facilitates migration from/to Netscape
9c1260efa52c82c2a58e5b5f20cd6902563d95f5rbowen servers using the LDAP Directory Interchange Format (ldif).</dd>
5a58787efeb02a1c3f06569d019ad81fd2efa06end
5a58787efeb02a1c3f06569d019ad81fd2efa06end <dt><code>-p</code></dt>
<dd>Use plaintext passwords. Though <code>htpasswd</code> will support
creation on all platforms, the <a href="httpd.html">httpd</a> daemon will
only accept plain text passwords on Windows, Netware and TPF.</dd>
<dt><code><var>passwdfile</var></code></dt>
<dd>Name of the file to contain the user name and password. If
<code>-c</code> is given, this file is created if it does not already exist,
or rewritten and truncated if it does exist.</dd>
<dt><code><var>username</var></code></dt>
<dd>The username to create or update in <var>passwdfile</var>. If
<var>username</var> does not exist in this file, an entry is added. If it
does exist, the password is changed.</dd>
<dt><code><var>password</var></code></dt>
<dd>The plaintext password to be encrypted and stored in the file. Only
used with the <code>-b</code> flag.</dd>
</dl>
</div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
<div class="section">
<h2><a name="exit" id="exit">Exit Status</a></h2>
<p><code>htpasswd</code> returns a zero status ("true") if the username and
password have been successfully added or updated in the
<var>passwdfile</var>. <code>htpasswd</code> returns <code>1</code> if it
encounters some problem accessing files, <code>2</code> if there was a
syntax problem with the command line, <code>3</code> if the password was
entered interactively and the verification entry didn't match,
<code>4</code> if its operation was interrupted, <code>5</code> if a value
is too long (username, filename, password, or final computed record), and
<code>6</code> if the username contains illegal characters (see the
<a href="#restrictions">Restrictions section</a>).</p>
</div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
<div class="section">
<h2><a name="examples" id="examples">Examples</a></h2>
<div class="example"><p><code>
htpasswd /usr/local/etc/apache/.htpasswd-users jsmith
</code></p></div>
<p>Adds or modifies the password for user <code>jsmith</code>. The user
is prompted for the password. If executed on a Windows system, the password
will be encrypted using the modified Apache MD5 algorithm; otherwise, the
system's <code>crypt()</code> routine will be used. If the file does not
exist, <code>htpasswd</code> will do nothing except return an error.</p>
<div class="example"><p><code>
htpasswd -c /home/doe/public_html/.htpasswd jane
</code></p></div>
<p>Creates a new file and stores a record in it for user <code>jane</code>.
The user is prompted for the password. If the file exists and cannot be
read, or cannot be written, it is not altered and <code>htpasswd</code>
will display a message and return an error status.</p>
<div class="example"><p><code>
htpasswd -mb /usr/web/.htpasswd-all jones Pwd4Steve
</code></p></div>
<p>Encrypts the password from the command line (<code>Pwd4Steve</code>)
using the MD5 algorithm, and stores it in the specified file.</p>
</div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
<div class="section">
<h2><a name="security" id="security">Security Considerations</a></h2>
<p>Web password files such as those managed by <code>htpasswd</code> should
<em>not</em> be within the Web server's URI space -- that is, they should
not be fetchable with a browser.</p>
<p>The use of the <code>-b</code> option is discouraged, since when it is
used the unencrypted password appears on the command line.</p>
</div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
<div class="section">
<h2><a name="restrictions" id="restrictions">Restrictions</a></h2>
<p>On the Windows and MPE platforms, passwords encrypted with
<code>htpasswd</code> are limited to no more than <code>255</code>
characters in length. Longer passwords will be truncated to 255
characters.</p>
<p>The MD5 algorithm used by <code>htpasswd</code> is specific to the Apache
software; passwords encrypted using it will not be usable with other Web
servers.</p>
<p>Usernames are limited to <code>255</code> bytes and may not include the
character <code>:</code>.</p>
</div></div>
<div class="bottomlang">
<p><span>Available Languages: </span><a href="/en/programs/htpasswd.html">&nbsp;en&nbsp;</a></p>
</div><div id="footer">
<p class="apache">Maintained by the <a href="http://httpd.apache.org/docs-project/">Apache HTTP Server Documentation Project</a></p>
<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>
</body></html>