Toggle navigation 619-955-6995 Contact Us

About Us

Portfolio

Services

Websites

Drupal Development

WordPress

eCommerce

Commercial Photography

Logo Design

Print Design

Resources

Client Handbook

WordPress Developer Resources

Drupal Developer Resources

Blog

Contact

619-955-6995

About Us

Portfolio

Services

Websites

Drupal Development

WordPress

eCommerce

Commercial Photography

Logo Design

Print Design

Resources

Client Handbook

WordPress Developer Resources

Drupal Developer Resources

Blog

Contact

Generate htaccess password (htpasswd) from the command line

06/14/13 Shoebox

When a website is in development, it’s a good idea to password protect the root directory from public access:

It prevents unauthorized users from accessing the site

It prevents it from being indexed in search engines

It prevents other bots (spammers) from attacking your development site

There are plenty of online tools to generate the htpasswd file, but if you like to work from the command line, here’s a really easy way to do it.

If you’re on a Linux server with Apache, you can use the htpasswd command.

If you don’t current have an .htpasswd, use the “-c” option to create the file with the first user. It will prompt you for a password and encrypt it for you.

htpasswd -c /var/www/domain.com/public_html/.htpasswd user1

If you already have the .htpasswd file and would like to append a new user, repeat the command with the “-c”

htpasswd /var/www/domain.com/public_html/.htpasswd user2

.htpasswd is the standard file name that contains the authentication credentials, but you can actually call it whatever you want as long as you reference it in the .htaccess file:

AuthName "Restricted Area"
AuthType Basic
AuthUserFile /var/www/domain.com/htdocs/.mycustompasswordfile
AuthGroupFile /dev/null
require valid-user

The AuthUserFile location doesn’t need to be in the same folder as your virtualhost. It can be anywhere on your server as long as you use the full path to it. You may want a shared AuthUserFile if you have multiple websites on the same server and want to administer the logins from one file.

3 Responses to “Generate htaccess password (htpasswd) from the command line”

generate password
June 17, 2013
I just could not leave your website before suggesting that I really enjoyed the standard info an individual supply on your visitors? Is gonna be back regularly to check out new posts

Julie
December 24, 2013
Great post. I was checking continuously this weblolg and I am inspired!
Very useful info specifically the last phase 🙂 I take care of
such info a lot. I used to be seeking this certain info for a very lengthy
time. Thank you and good luck.

mallaow
February 24, 2014
Hello !
Thanks for the post,
Anyway a slightly annoying problem here : when i type the command, i’ve an answer saying that that command does not exist.
What can i do ? ?
thanks for .. any help !!

Comments are closed.

Categories

Case Studies

Design

Downloads

Drupal Development Resources

Job Guide

Lamplighter

News

Projects

Shoebox

Web 101

Wordpress Development Resources

Our Location

9810 Scripps Lake Dr, Suite F
San Diego, CA 92131
Get Directions

© 2018 Gaslamp Media | Privacy Policy