logo


Home Linux Howtos (Exercises) HTTP apache password protected directory with Digest
HTTP apache password protected directory with Digest

HTTP apache password protected directory with Digest

Digest authentication uses a more secure method that is much less sus-
ceptible to credential theft, spoofing, and replay attacks.
The essential ingredient is that no username or password traverses the network in plain-
text.

Preparing a realm to use Basic authentication consists of simply storing the username/
password pair and telling the server where to find them. The password may or may not
be encrypted. The same credentials may be applied to any realm on the server, or even
copied to a completely different server and used there.

Setting up Digest authentication is a little more involved. For one thing, the credentials
are not transportable to other realms; when you generate them, you specify the realm
to which they apply.

[root@station246 ~]# vim /etc/httpd/conf/httpd.conf

# password protected httpd directory eith digest protocal
<Directory /var/www/html/data2>
AuthName "RESTRICTED" # <-----------cosider this as realm
AuthType digest
AuthDigestFile /etc/httpd/conf/.htdigest
Require valid-user
</Directory>

[root@station246 ~]# mkdir /var/www/html/data2

[root@station246 ~]# cd /var/www/html/data2

[root@station246 data2]# echo "This is digest password protected directory index" >> index.html

[root@station246 data2]# ls
index.html
[root@station246 data2]#

[root@station246 ~]# /etc/init.d/httpd restart
Stopping httpd:

[  OK  ]
Starting httpd:                                            [  OK  ]
[root@station246 ~]#

[root@station246 data2]# htdigest -c /etc/httpd/conf/.htdigest RESTRICTED nilesh1
Adding password for nilesh1 in realm RESTRICTED.
New password:
Re-type new password:

[root@station246 data2]# cat /etc/httpd/conf/.htdigest
nilesh1:RESTRICTED:95a23178b144044ef7264eb3891d07ab

[root@station246 data2]# htdigest /etc/httpd/conf/.htdigest RESTRICTED nilesh
Adding user nilesh in realm RESTRICTED
New password:
Re-type new password:

[root@station246 data2]# cat /etc/httpd/conf/.htdigest
nilesh1:RESTRICTED:95a23178b144044ef7264eb3891d07ab
nilesh:RESTRICTED:da855fd0a25d51405a04a69ef23a8a32
[root@station246 data2]#

Now try to access the same directory with firefox browser.

Check password protection is working ok.

Please also check the following command for log files.

[root@station246 data2]# tail -f /var/log/httpd/access_log
192.168.0.254 - - [23/Apr/2011:16:21:55 +0530] "GET /data2 HTTP/1.1" 401 480 "-" "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.12) Gecko/20101027 Red Hat/3.6.12-1.el6_0 Firefox/3.6.12"
192.168.0.254 - nilesh [23/Apr/2011:16:22:02 +0530] "GET /data2 HTTP/1.1" 301 314 "-" "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.12) Gecko/20101027 Red Hat/3.6.12-1.el6_0 Firefox/3.6.12"
192.168.0.254 - nilesh [23/Apr/2011:16:22:02 +0530] "GET /data2/ HTTP/1.1" 200 50 "-" "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.12) Gecko/20101027 Red Hat/3.6.12-1.el6_0 Firefox/3.6.12"

Ref  1. Apache Cookbook 2. Apache: The Definitive Guide 3. apache manual and documents help

By Nilesh J. Vaghela udated on Sat Apr 3 16:24:45 IST 2011
 

Exam Schedule

RHCE Exam For Feb-2011

RHCE Exam :- 24-02-2011

RH423 Exam :- 25-02-2011

RHCVA Exam :- 25-02-2011



Latest Update





Do the Register for RHCE Exam and get a fantastic scheme from Red Hat.

RHCE Full Time Batch is already started and RHCSS (RH423) Batch will start soon.

Last RHCE exam result at Electromech: November 27
Name RESULT
Mr. Jigar RHCE
Mr. Sujit RHCE
Mr. Prtyay RHCE
Mr. Pritesh RHCE
Mr. Hardik RHCE
Mr. Gaurav RHCE
Mr. Milan RHCE
Mr. Sachin RHCE
Ms. Shrusti RHCE
Mr. Paras RHCE
Mr. Dhruvin RHCE
Mr. Sneh RHCE
Mr. Jigar RHCE
Mr. Nishant RHCE
Mr. Dinesh RHCE
Mr. Manthan RHCE
Mr. Vinay RHCE
Mr. Pradip RHCE
Mr. Kausal RHCE
Mr. Gopan RHCT
Mr. Jagdish RHCT



Powered by Electromech Corporation.