Monday, September 15, 2008

Creating or Updating an htpasswd File

Don't laugh.

I do this maybe twice a year.

To create a new htpasswd file:
  1. Using the command line / terminal, go to the directory you want to protect then type:
    user$ htpasswd -c .htpasswd YourUsername
  2. Type the password twice
The tool you're using is htpasswd. The -c switch is the instruction to create a new file. The file name will be .htpasswd. Note that in most systems, a file that starts with a . is hidden by default.

To update an existing htpasswd file with a new password for an existing user:
  1. Using the command line / terminal, go to the directory you where the .htpasswd file exists then type:
    user$ htpasswd .htpasswd YourUsername
  2. Type the password twice
The difference here is the lack of the -c switch, which means the existing file will be updated.

No comments: