Return to Snippet

Revision: 29960
at August 5, 2010 15:10 by beneberle


Initial Code
// method 1
// create a file and a user
htpasswd -bc /somepath/outside/of/root/.htpass user1 password1

// method 2
// create a file and a user, password entered after prompt
htpasswd -c /somepath/outside/of/root/.htpass user1

// method 3
// create/update a user/password, password entered after prompt
htpasswd /somepath/outside/of/root/.htpass user1

Initial URL
http://snipplr.com/view/38522/htaccess-basic-authentication/

Initial Description
<p>Method 1</p>

<p>The -c directive creates a file .htpass in the directory somepath/outside/of/root/ containing a username user1. The -b directive means you must supply the password password1 at the command line when running the command - not recommended.</p>

<p>Method 2</p>

<p>The -c directive will create a file .htpass in the directory /somepath/outside/of/root/ containing a username user1. When run, the command will prompt you to enter the password, which will be obscured - recommended.</p>

<p>The -c directive will create the file, but also overwrite an existing file of the same name, so be careful. </p>

<p>Method 3</p>

<p>To add or edit a user/pass to an existing .htpass file, leave -b and -c out. You’ll be prompted for the new password.</p>

Initial Title
.htpasswd Basic Authentication - Create User/Pass with Encrypted Password

Initial Tags
htaccess

Initial Language
Apache