Configure protected directories in Apache Kodekloud



Solution :

Login to server

ssh [email protected]  

Add a user and set password

sudo htpasswd -c /etc/httpd/.htpasswd james


sudo systemctl restart httpd

Edit configuration

sudo vi /etc/httpd/conf/httpd.conf 

Scroll down to the <Directory> section for "/var/www/html" and change  

AllowOverride to All

Create mentioned Directory

mkdir /var/www/html/sysops 

Go to sysops directory and create .htaccess file

sudo vi .htaccess

Give this configuration

AuthType Basic
AuthName "Password Required"
Require valid-user
AuthUserFile /etc/httpd/.htpasswd

Now go to jump server and copy index file

 scp /tmp/index.html [email protected]:/tmp

Again copy from tmp folder to mentioned directory

cp /tmp/index.html /var/www/html/sysops

Check by typing this curl command

curl -u james

Share on Google Plus

About Ashadullah Shawon

I am Ashadullah Shawon. I am a Software Engineer. I studied Computer Science and Engineering (CSE) at RUET. I Like To Share Knowledge. Learn More: Click Here
    Blogger Comment
    Facebook Comment


  1. the task is to check curl -u james
    curl -u james u will get error 301 permanent move..

  2. That is right, rest of the steps work.
    curl -u james:[password]