How to configure htaccess authentication via commandline in Cpanel
As we already know Cpanel provides graphical inter-phase to enable htaccess authentication. But we can configure htaccess authentication via commandline also.
This tutorial explains the detailed steps to set htaccess authentication via commandline.
Step1: Open the file with name ".htaccess" in the root directory of domain
#vi .htaccess
Step2: Update the below contents to that file and save it
AuthUserFile /home/username/public_html/.htpasswd
AuthGroupFile /dev/null
AuthName "EnterPassword"
AuthType Basic
require valid-user
Here we need to replace "username" with the user of that domain
Step3: Open the password file "/home/username/public_html/.htpasswd"
#vi /home/username/public_html/.htpasswd
Don't forget to replace "username" with the user of that domain
Step4: Update the htaccess username and encrypted password to this file.
That's all.....