---
title: "How to Add Password Protection for a Directory Using cPanel"
description: "At times, you may find it best practice to password protect a folder on your account. This can add an extra layer of protection to files you do not want the general public to have access to. Password..."
url: https://www.inmotionhosting.com/support/edu/cpanel/password-protect-directory-cpanel/
date: 2011-08-29
modified: 2022-09-12
author: "Brad Markle"
categories: ["cPanel", "Security"]
type: post
lang: en
---

# How to Add Password Protection for a Directory Using cPanel

At times, you may find it best practice to **password protect a folder** on your account. This can add an extra layer of protection to files you do not want the general public to have access to. *Password protecting a directory* can be easily accomplished using the option within cPanel. In this guide, you can learn how to **add and remove password protection on a directory, using cPanel**.

- [How Does Password Protection Work?](#how)
- [Add Password Protection](#add-password)
- [Remove Password Protection](#remove-password)

## How Does Password Protection Work?

It is important to understand how password protection on a folder works. When you choose to **password protect a directory in cPanel**, cPanel creates a rule in your *.htaccess* file. This rule specifies that the *folder is protected* and the visitor will need to provide the proper username and password to log in and view the files within it.

**IMPORTANT:** When a user attempts to access the protected directory through a browser, the site will prompt them to enter a username and password. The name that you choose for the protected directory will also display. Additionally, all the sub-directories that exist within the protected directory will be accessible, once authenticated.

![How to Password Protect Directories in cPanel](https://i.ytimg.com/vi_webp/rhQ4K7lKzF4/maxresdefault.webp)

*Don’t have time to read our full article? Watch our walk-through video.*

## Add Password Protection

1. [Log into cPanel](/support/edu/cpanel/how-to-log-into-cpanel/).
2. Go to the *Files* section and click on the **Directory Privacy** icon.![cPanel Files section displayed with Directory Privacy icon highlighted](https://www.inmotionhosting.com/support/wp-content/uploads/2011/08/pass_select-directory-privacy.png)
3. Select the directory you want to password protect and then you will see the **Set permissions for “/home/exampl3/directory/”** screen appear.![Set permissions for directory screen displaying directory listing with public_html directory highlighted as selection.](https://www.inmotionhosting.com/support/wp-content/uploads/2011/08/pass_select-directory-to-protect.png)
4. Click on the checkbox labeled “**Password protect this directory:**“.
5. Type a name for the folder you are trying to protect in the field labeled “**Enter a name for the protected directory:**“.![Security Settings displayed with checkbox and name fields highlighted and filled in.](https://www.inmotionhosting.com/support/wp-content/uploads/2011/08/pass_after-clicking-directory.png)
6. Click the **Save** button to save the name you have entered for the directory and option to password protect the directory.![Security Settings displayed with Save button highlighted.](https://www.inmotionhosting.com/support/wp-content/uploads/2011/08/pass_save-passworded-directory.png)
7. Create a user to grant access to the protected directory by typing the credentials into the **Username**, **New Password** and **Confirm Password** fields.
8. Click **Save** in order to save the credentials that you have entered.![Create User section displayed with Save button highlighted.](https://www.inmotionhosting.com/support/wp-content/uploads/2011/08/pass_create-user.png)

## Remove Password Protection

The steps to *remove password protection on a directory* are fairly quick and simple. One reason you might want to password protect a directory and then remove the protection is for testing purposes. Or, if you are finally ready to make the folder open to the public, then you can **remove the password protection** so that everyone can access the files in the directory. The instructions below are the steps for **removing the password protection**.

1. [Log into your cPanel](/support/edu/cpanel/how-to-log-into-cpanel/).
2. Scroll down to the *Files* section in your cPanel and then click the **Directory Privacy** icon.
3. Select the directory from the list of folders that you want to *remove password protection for*. The directory should appear with a lock in front of it if it is currently password protected.
4. Uncheck the box that says “**Password protect this directory**“.
5. Finally, click the **Save** button.

If you have further questions or need further assistance please feel free to [contact our Live Technical Support](/support/amp/how-to-get-great-technical-support/).
