How to Password Protect Directories in cPanel

Share this:

Sometimes you may wish to restrict access to a particular directory on your website to keep files private or share them only with a select group of users. The password protection feature in cPanel allows you to do this for any number of directories. The tool can be used for:

  • Creating members-only areas
  • Preventing the public from accessing sections that are in development

When you set a password for a directory, it protects the main folder and all subfolders and files contained within. Anyone who wishes to view these files must enter the associated username and password to gain access.

Choosing a Directory

To assign a password to a directory within your site, log in to the cPanel dashboard and scroll down to the Security section. Choose “Password Protect Directories.” This option may also be labeled “Directory Password.”

635713600284508715

A popup dialog for Directory Selection appears, asking you which directory you want to go to. Choose Web Root to access the public_html folder, where all public files for your website are stored.

635713600658102792

Check the “Show hidden files” box to display all files and file types while you’re working.

635713601077454158

Click on the “Go” button to navigate to your chosen directory. This brings to you the “Password Protect Directories” screen where you’ll see all folders available in that directory. Click on a folder’s name or the accompanying icon to select it.

635713601586209222

Name Your Directory

The screen will change to show options for Security Settings. To protect your chosen directory, give it a label in the “Name the protected directory” box. Note that this won’t change the name of the folder; rather, it’s the title that will display when users log in to view restricted files.

635713603606849308

Check the “Password protect this directory” box and click Save.

635713608533387669

Set Up a User

Once you protect a directory, you need to create a username and password to be able to access it. For example, if you’re making a members-only section on your site, you might choose “members” as a username. The password you create needs to have a strength of at least 20 to be accepted. cPanel rates passwords on a scale of 1 to 100 and usually requires passwords to be at least five characters long.

635713606256197328

Combine letters, numbers and punctuation marks to create a stronger password. If you have difficulty coming up with something that’s secure enough, click the “Password Generator” button to have cPanel create a password for you.

635713606689966798

These passwords are randomly generated and use the right balance of characters to get a rating of 100, ensuring that your files are as safe as possible.

635713607044997996

Click on “Add/modify Authhorized User” to set up the user account. If you need to change the password in the future, return to this area and input the same username along with the updated password.

Removing Password Protection

There may come a time when you want to remove password protection from a directory. You might decide to unveil a brand new section of your website or make your members-only area available to all visitors.

To make files public again, repeat the steps to access the password protection screen for your chosen directory. Uncheck the “Password protect this directory” box and click Save to grant unrestricted access to that folder and its files.

With the password protection function in cPanel, you can set up usernames and passwords for as many directories as you choose as well as change passwords and remove restrictions as necessary. This simple tool gives you control over file access to create a more secure website environment.

Comments

comments