Friday, January 11, 2013

htpasswd to protect a web pages

Lets say you have a have a smokeping services and you wish to protect it with a password. then you can use htpasswd to protect it.

First you need to cd to that folder
# cd  /opt/smokeping

then create a new htpasswd
and add user 'admin'
# htpasswd  -c /opt/smokeping/.htpasswd admin

If you have an existing htpasswd file, then you can just update it using
# htpasswd  /opt/smokeping/.htpasswd admin

after done, you need to enable this in the apache config
you need to add:

<Directory "/var/www/html/smokeping">

     AuthUserFile /opt/smokeping/.htpasswd
     AuthType Basic
     AuthName "Smokeping Admin Pages"
     Require valid-user


Then reload the Apache services

No comments:

Post a Comment