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
0
votes
1 answer

How do I get Apache .htpasswd to work in this case?

I have a website running on an AWS EC2 Amazon Linux 2 AMI with Apache and PHP/Laravel. It's a test site though and I want to password-protect the site via .htpasswd. Even after following several tutorials, I can't seem to get it working. It's worth…
HartleySan
  • 7,404
  • 14
  • 66
  • 119
0
votes
1 answer

why htpasswd from apache2-utils output redirect failed

while I'm trying to redirect htpasswd's out and input to a pipe file, the prompt messages always print without redirection. I tried manny method, all failed. anyone help? mkfifo pipe htpasswd -m aaa test &> pipe htpasswd -m aaa test 2>&1…
Auther
  • 1
  • 3
0
votes
1 answer

Is there a way to require a login when accessing a website run on Google Cloud?

I'm currently making a website using a VM instance on Google Cloud. I've tried to password-protect my website using .htaccess and .htpass so that people cannot access it until I have completed it, but I will still be able to see it (because I have…
LB57
  • 5
  • 1
0
votes
0 answers

One Time Login with htpasswd

I have a page I'd like to password protect: www.example.com/password-protected-page I'll email my users their unique login details but I'd like theme to be only used once. So the very first login attempt will go through but when they try to login…
Mark
  • 3
  • 2
0
votes
1 answer

Generating htpasswd entry using R

Is there a way to generate a htpasswd entry using R, ie, without using the htpasswd utility itself? According to the Apache docs, htpasswd encrypts passwords using either bcrypt, a version of MD5 modified for Apache, SHA1, or the system's crypt()…
Hong Ooi
  • 56,353
  • 13
  • 134
  • 187
0
votes
1 answer

cURL with both Basic and Bearer authentication headers

I'm using PHP cURL to test an API which sits on a dev site that is protected by Apache HTPASSWD. $jwt = // a standard JWT token $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, 'https://dev.mysite.com/api'); curl_setopt($curl,…
Tom
  • 30,090
  • 27
  • 90
  • 124
0
votes
1 answer

Protecting /index.html with .htaccess file

I would like to use a .htaccess and a .htpasswd file to protect access to a website. The following code successfully brings up the auth dialog when visiting mysite.com. But when visiting mysite.com/index.html the auth dialog does not appear and the…
Ben
  • 15,938
  • 19
  • 92
  • 138
0
votes
1 answer

How to give the AuthUserFile access only for specific page?

I have one page on my root folder called export.php. Now I don't want to give access to this page to all the users. What I am trying to achieve, If any user tries to access export.php page then one alert will display and it will ask for the username…
Naren Verma
  • 2,205
  • 5
  • 38
  • 95
0
votes
0 answers

Laravel/React .HTACCESS and .HTPASSWD not working

I want to secure by basic http authentication my dev site in Laravel with .htaccess and .htpasswd. First, I created my .htpasswd user and password (https://shop.alterlinks.com/htpasswd/htpasswd.php MD5). Then, my htaccess file with some basic…
0
votes
0 answers

htaccess file not stopping files from being listed

I'm creating a website. The username/password to open the MySQL database is stored in a text file. I'm preventing that text file from being displayed by putting a htaccess file and htpasswd file in the same folder as the text file, which is where…
Ken
  • 139
  • 12
0
votes
1 answer

Passwordprotecting a Single PHP file with Apache2 or PHP independantly from anything else

Dear folks, Inside folder images I would like to password protect a single php file render.php I already have in that folder my .htaccess as well as my .htpasswd files however they dont work .htaccess in folder /images // does not work ??
Sam
  • 15,254
  • 25
  • 90
  • 145
0
votes
1 answer

Protect directory with htaccess/htpasswd error from root htaccess file?

I have an htaccess file in my root directory to add rules such as force www on website, etc. I want to protect a directory on my site such as example.com/private/ and example.com/private/p/ I here is where my htaccess files…
Anthony4
  • 92
  • 6
0
votes
1 answer

401 Error Document Within Protected Directory

I have an error document (symlink actually) in a protected directory. I want to use my custom error page but the 401 error isn't working due to it being a private directory. How can I solve this? Here's my .htaccess right now ErrorDocument 401…
user10570916
0
votes
1 answer

Clash between .htpasswd and Website Authentication

I have some of my Drupal website contents exposed through a Json rest service. To access them I perform an http request with the Basic Auth protocol (i.e., adding the Authorization header). My problem is that this website must be published in a…
donnadulcinea
  • 1,854
  • 2
  • 25
  • 37
0
votes
2 answers

How to create .htpasswd file for nginx using chef

I am new to chef and I am trying to generate a .htpasswd file to store user hash, I went through some links but this is not helping. I need ngnix to secure Kibana and I want to generate a password for users using openssl. I have created a template…
sayali.k
  • 39
  • 9