There are times where you may require your webpages to be password protected.
To achieve this within Apache the usernames and passwords are stored within a flat file called htpasswd. This is then referenced within your Apache configuration.
Within your .htaccess file configure the following.
AuthType Basic AuthName "restricted area" AuthUserFile /var/www/html/website/.htpasswd require valid-user
Next we create the htpasswd file and create a user named support.
[[email protected] /]# cd /var/www/html/website/ [[email protected] website]# htpasswd -c .htpasswd support New password: Re-type new password: Adding password for user support
Create additional User
An additional user is then created named bob.
[[email protected] website]# htpasswd .htpasswd bob New password: Re-type new password: Adding password for user bob
Finally Apache is restarted and you can then log into your webpage and confirm password authentication is working.
systemctl restart httpd
- How to Configure a BIND Server on Ubuntu - March 15, 2018
- What is a BGP Confederation? - March 6, 2018
- Cisco – What is BGP ORF (Outbound Route Filtering)? - March 5, 2018
Want to become an IT Security expert?
Here is our hand-picked selection of the best courses you can find online:
Internet Security Deep Dive course
Complete Cyber Security Course – Hackers Exposed
CompTIA Security+ (SY0-601) Certification Complete course
and our recommended certification practice exams:
AlphaPrep Practice Tests - Free Trial