Photo by Markus Spiske from Pexels

How To Lock A Directory On Your Dedicated Server?

The directory privacy feature of WHM and cPanel of your dedicated server, VPS, or hosting allows you to secure any web directory from unauthorized access on the web.

You can lock a directory with a username and password so that anyone who attempts to open it must go through its login process. You can secure specific directories on your server. This feature simply modifies htaccess and htpasswd configurations to restrict access to those files on your websites.

To use the feature, simply login to the cPanel of your server and select a directory to manage:

  1. To select a directory, simply click the desired directory’s name
  2. To view and select subdirectories, simply click the parent directory’s name and select the desired subdirectory
  3. To configure the security settings for a directory or subdirectory, simply click the Edit option present under the Actions column
  4. To password protect the selected directory, select the password protect this directory checkbox
  5. Enter a display label for the directory in the enter a name for the protected directory text box
  6. Click the Save button and a confirmation message will appear
  7. Click Go Back to return to the directory’s configuration page

Note,

  • In step number four, to remove the password protection from a directory, simply deselect the Password protect this directory checkbox and save your changes
  • In step number five, This name only functions as a label for the directory. So do not confuse it with the directory’s main name

Next,

Once you have locked your directory by completing the above-given steps, you will need to create a user that can have access to that directory.

To create a user for a directory, your directory must have correct permissions. In case you cannot create a user, then change the directory’s permissions to 0700 using the file manager interface.

To create an authorized user:

  1. On the same page, enter the desired username in the Username text box
  2. Enter and confirm the new password in the appropriate text boxes
  3. Click Save and a confirmation message will appear
  4. Now click Go Back to return to the directory’s configuration page

Remember,

A protected directory’s subdirectories inherit their parent directory’s password protection. The lock icon indicates that Directory Privacy configurations already exist for that specific directory.

It does not protect the directories that users access via FTP, SFTP, Web Disk, and other similar services, or if any user accesses the files locally on the server. This is because when a user accesses secure directories on a server via these specified services, he already goes through the login process so the system doesn’t prompt him for another login.

In case you want to secure your directories and files locally on the server then use the file and folder permission option.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.