Posted By

beneberle on 08/05/10


Tagged

htaccess


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

czterystaczwarty
kubaitis
antti


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


 / Published in: Apache
 

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

Method 1

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.

Method 2

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.

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

Method 3

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.

  1. // method 1
  2. // create a file and a user
  3. htpasswd -bc /somepath/outside/of/root/.htpass user1 password1
  4.  
  5. // method 2
  6. // create a file and a user, password entered after prompt
  7. htpasswd -c /somepath/outside/of/root/.htpass user1
  8.  
  9. // method 3
  10. // create/update a user/password, password entered after prompt
  11. htpasswd /somepath/outside/of/root/.htpass user1

Report this snippet  

You need to login to post a comment.