Questions tagged [.htpasswd]

.htpasswd is a flat-file used to store usernames and password for basic authentication of Apache HTTP Server.

.htpasswd is a flat-file used to store usernames and passwords for basic authentication on Apache HTTP Servers. The name of the file is given in the .htaccess configuration, and can be anything, but ".htpasswd" is the canonical name. The file name starts with a dot, because most Unix-like operating systems consider any file that begins with dot to be hidden.

This file is often maintained with the shell command htpasswd which can add, delete, and update users, and will properly encode the passwords for use (so they are easily checked, but cannot be reversed back to the original password).

The file consists of rows. Each row corresponds to a username and hashed password pair, separated with the colon. For example:

user:password

The hashed password is typically "UNIX crypt" style, encrypted in either MD5 or SHA1 as common alternatives.

Additional users can be added by using the htpasswd shell command or by appending new lines to the file. For example:

user1:password1
user2:password2

Resources available on the Apache HTTP server can be restricted to users listed in the files created by htpasswd.

See also

526 questions
120
votes
2 answers

Adding a user on .htpasswd

I am using .htpasswd to password protect certain directory on my server. However, I noticed that everytime I do this sudo htpasswd -c /etc/apache2/.htpasswd newuser my current contents of .htpasswd will be overwritten. Every directory of my site has…
fishcracker
  • 2,401
  • 5
  • 23
  • 28
113
votes
9 answers

How to use a RELATIVE path with AuthUserFile in htaccess?

I have a .htaccess that uses basic authentication. It seems the path to the .htpasswd file isn't relative to the htaccess file, but instead to the server config. So even though I have the .htaccess and .htpasswd files in the same directory, this…
DssTrainer
  • 1,439
  • 3
  • 12
  • 15
38
votes
2 answers

Verify user and password against a file created by htpasswd

Is there a way, from the command line, to check a user and password against a file created by htpasswd, the tool provided by Apache?
Pablo Fernandez
  • 279,434
  • 135
  • 377
  • 622
33
votes
4 answers

How to logout when using .htaccess (and .htpasswd) authentication?

Possible Duplicate: HTTP authentication logout via PHP Hi I have a some functionality on my website protected using .htaccess and .htpasswd. When users attempt to access this, they get prompt to enter details. They enter their details and get in…
TigerTiger
  • 10,590
  • 15
  • 57
  • 72
33
votes
4 answers

How to automate generation of htpasswd from command line without typing password?

I am trying to automate creating a password from the command line. I have tried the below but it still keeps asking for the password. echo "test101" | htpasswd -c ~/temp/password admin How to generate automate htpasswd from command line without…
Tampa
  • 75,446
  • 119
  • 278
  • 425
30
votes
10 answers

htaccess doesn't work - always wrong password

I am trying to password protect a directory, and have two files in the directory which should password protected it: .htaccess .htpasswd HTACCESS: ###Contents of .htaccess: AuthUserFile /var/www/html/path/to/my/directory/.htpasswd AuthName…
testing
  • 19,681
  • 50
  • 236
  • 417
22
votes
3 answers

Programmatically building htpasswd

Is there a programmatic way to build htpasswd files, without depending on OS specific functions (i.e. exec(), passthru())?
UnkwnTech
  • 88,102
  • 65
  • 184
  • 229
22
votes
4 answers

nginx and auth_basic

I am trying to get basic authentication working with nginx in Ubuntu Jaunty. In nginx.conf, I added these two lines under the server context: server { ... auth_basic "Restricted Access"; auth_basic_user_file /etc/nginx/.htpasswd; …
KP.
  • 1,247
  • 1
  • 9
  • 12
21
votes
2 answers

Different output, same username and password

I was wondering why even for the same username and the same password, htpasswd outputs a new hash everytime? I tried finding an answer to this question, but couldn't.
user225312
  • 126,773
  • 69
  • 172
  • 181
19
votes
2 answers

Add a comment on .htpasswd

I was wondering if it is possible to write a comment on the .htpasswd file. Why ? Because sometimes, we have to "disable" some users, just for a couple of days. I checked on StackOverflow and other websites, and it seems pretty confusing : Not…
4wk_
  • 2,458
  • 3
  • 34
  • 46
19
votes
5 answers

.htpasswd and .htaccess - internal server error

I want to password protect my website, but as soon as I add in the .htpasswd and .htaccess files I get a server error: Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your…
Leanne Beesley
  • 191
  • 1
  • 1
  • 3
18
votes
1 answer

Exclude folder from htpasswd

I need to password protect a website with a username/password but need to keep the "/assets" folder accessible as files like images/css are being embedded on other sites. I have this for the protection: Order Allow,Deny AuthType Basic AuthName…
Shealan
  • 1,316
  • 3
  • 20
  • 32
15
votes
1 answer

Proper .htpasswd usage

Assuming a small (pages < 5) site, what is the proper usage of .htaccess and .htpassword? I recently watched a tutorial from Nettuts+ where this sample code was given: .htaccess AuthName "Login title" AuthType Basic AuthUserFile…
Whymarrh
  • 13,139
  • 14
  • 57
  • 108
13
votes
1 answer

Using apache config and htaccess to dynamically set config vars for dev and production

Short Summary I need to be able to set an environment variable in the Apache site config that defines if the site is dev, beta or production. The htaccess file in the web root will define config variables for the website (database credentials,…
Cory Baumer
  • 397
  • 3
  • 16
13
votes
3 answers

How to make Basic Auth exclude a rewritten URL

I have a Basic Authentication setup on a development server. It is setup inside my httpd.conf file for the VirtualHost of the website. I've had to set up it to exclude certain directories, which has caused no problems and all works fine. The issue…
Josh
  • 1,794
  • 3
  • 17
  • 31
1
2 3
35 36