cPanel Directory Privacy
Table of content
In this article, we'll show you how to protect a directory in cPanel.
This feature allows you to protect specific directories in your cPanel account.
If you enable this feature, the system prompts users to log in when they attempt to open a file in the protected folder.
Access to Directory Privacy interface
To activate Directory Privacy feature go to cPanel > Files and click Directory Privacy link:
Then navigate to the directory by clicking on the folder icon:
Clicking on the directory name will open Directory Privacy screen.
Enter a name for the protected directory and click Save:
To remove password protection from a directory, deselect the
Password protect this directory checkbox and click Save.
Create an authorized user
To create an authorized user for the selected directory, enter the desired username in the Username text box and enter and confirm the new password in the appropriate text boxes (use the password generator to create a strong password):
You can create as many users as you wish and they all will be added in the Authorized Users table below the form:
Now enter the domain that is configured to access the protected folder - the site will prompt to enter a username and password.
If you enter the correct credentials you will access the resource - the web page in our example:
Note: A protected directory's sub-directories inherit their parent directory's password protection. For example, if you want to access
hostpulse-addon.com/subdir/file.html the authentication will also be required.
If you can not provide the correct access credentials the server will return an error:
To remove authenticated user select it in the Authorized Users table and click the Delete User button:
A confirmation message will be displayed:
If you open the protected directory you will notice that cPanel has added a
.htaccess file, containing this code:
AuthType Basic AuthName "privacy-protection" AuthUserFile "/home/cpaneluser/.htpasswds/public_html/hostpulse-addon.com/passwd" require valid-user
And if you open the file
passwd you will see a list with the authenticated users and their encrypted passwords:
If you open Directory Privacy screen the padlock icon indicates that Directory Privacy configurations already exist for that directory:
Directory Privacy feature enables you to improve the security level of your hosted resources.
In the article, we show how you can protect the root directory of a site in cPanel with a password and how the content of the site can only be accessed when entering correct access data ...