Jump to content

Linux: Generate htpasswd to store username and password with htpasswd command


Leon
 Share

Recommended Posts

  • Administrators

A friend of mine asked how he could generate a .htpasswd file for use with Apache.

The solution is quite simple, just run this from a console...

 

Q. How do I use htpasswd command to store username and passwords?

 

A. htpasswd is used to create and update the flat-files used to store usernames and password for basic authentication of HTTP users. If htpasswd cannot access a file, such as not being able to write to the output file or not being able to read the file in order to update it, it returns an error status and makes no changes.

 

Create a new password fileFollowing command will creates a new file and stores a record in it for user jerry. The user is prompted for the password. If the file exists and cannot be read, or cannot be written, it is not altered and htpasswd will display a message and return an error status.

 

# htpasswd -c /home/pwww/.htpasswd jerry

 

Change or update passwordTo add or modifies the password for user tom, enter:

 

# htpasswd /home/pwww/.htpasswd-users tom

 

The user is prompted for the password.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...