Edit the Apache .htpasswd authentication file

Warning: Be careful with the switches because it's easy to overwrite existing configuration.

To edit an Apache authentication file - referred to in these examples as [filename] - use the htpasswd or htpasswd2 command. You will be prompted to enter a password if you do not supply one. The [filename] is normally .htpasswd, depending on configuration, but it can vary according to the application that is using Apache authentication. For example, see the page about adding/removing Subversion (svn) users.

Add a user:

htpasswd [filename] [username]


htpasswd2 [filename] [username]

Adding the -c switch will create the .htaccess file:

htpasswd2 -c [filename] [username]

You can specify the password instead of being prompted for it:

htpasswd2 -cb [filename] [username] [password]

Delete user:

htpasswd2 -d [filename] [username] [password]

Edit user:

htpasswd2 -s [filename] [username] [password]

Last modified: 20/10/2010 Tags: (none)

This website is a personal resource. Nothing here is guaranteed correct or complete, so use at your own risk and try not to delete the Internet. -Stephan

Site Info

Privacy policy

Go to top