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
Step2: Update the below contents to that file and save it
Here we need to replace "username" with the user of that domain
Step3: Open the password file "/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.