How to set htdigest password in apache web server

How to set htdigest password in apache web server

Through this method we can set the username and password in webserver means whenever anyone open the website he has to give username and password to see the content of website.

To know about what is the difference in htdigest and htpasswd. Kindly visit these links.
http://httpd.apache.org/docs/2.2/programs/htdigest.html
http://httpd.apache.org/docs/2.2/programs/htpasswd.html

The practical has been done in given below apache version but applicable in almost all version of apache
Apache Package Version : httpd-2.2.3-76

you have to do these settings in you apache configuration file.
Here I did this in /etc/httpd/conf/httpd.conf
If you have custom file other than this so you have to edit that configuration file only.
I wrote this settings inside </VirtualHost>

Directory “/var/www/html/website” = This is the location of your webspace directory.
AllowOverride AuthConfig = Allow use of the authorization directives (AuthDBMGroupFile, AuthDBMUserFile, AuthGroupFile, AuthName, AuthType, AuthUserFile, Require, etc.).
AuthType = Here we are using Digest type
AuthName = In htdigest command it is for realm value.
AuthDigestProvider file = The AuthDigestProvider directive sets which provider is used to authenticate the users for this location. The default file provider is implemented by the mod_authn_file module.
AuthUserFile /etc/httpd/conf.d/.htdigestpasswd = Location of file where username passwd is saved
Require valid-user = Only valid user can able to login .The user which you created through htdigest command

Now set the username and password with htdigest command.

now restart the apache service.

Note: In Red Hat and CentOS , when we do yum install httpd at the time of installation mod_auth_digest is also installed like other module bydefault install. You can check by ls -l /etc/httpd/modules |grep digest
If it is not there then you have to install the mod_auth_digest module.

sharad chhetri (395 Posts)

My name is Sharad Chhetri. I am a Linux System Engineer.I love working on Linux,Unix and Open Source Technology. I also support and advocate the Freedom of Open Source Softwares. Apart of Unix Based Operating System, I also have experience in Windows Server and Cisco Networking. If you find my post useful to you/your organization and would like to donate. I will be felt rewarded if you donate to any Open Source Project or Charity Organization.I honestly and proudly admit, some blog readers has done donation.I will also appreciate if you notify me about your donation via email at admin@sharadchhetri.com .


Leave a Reply

Your email address will not be published. Required fields are marked *


7 × = twenty eight