Password protecting directories


Applies to: Grid
  • Difficulty: Easy
  • Time Needed: 20
  • Tools Required: AccountCenter access or SSH, FTP client
Applies to: Wordpress
  • Difficulty: Easy
  • Time Needed: 5
  • Tools Required: AccountCenter access or WP Admin access
Applies to: All DV
  • Difficulty: Easy
  • Time Needed: 10
  • Tools Required: Plesk administrator access or SSH, FTP client

Overview

You can restrict access to a web folder on your (mt) server.

Requirements

 The only requirement is access to your WordPress dashboard.
 
This article is provided as a courtesy. Installing, configuring, and troubleshooting third-party applications is outside the scope of support provided by (mt) Media Temple. Please take a moment to review the Statement of Support.

Before you start, you will need to have the directory you wish to password protect. If you have not, you will need to create it via FTP or using the File Manager in your Grid Control Panel.

Before you start, you'll need to have handy your FTP user login credentials for your subscripton.

READ ME FIRST

This article is provided as a courtesy. Installing, configuring, and troubleshooting third-party applications is outside the scope of support provided by (mt) Media Temple. Please take a moment to review the Statement of Support.

READ ME FIRST

This article is provided as a courtesy. Installing, configuring, and troubleshooting third-party applications is outside the scope of support provided by (mt) Media Temple. Please take a moment to review the Statement of Support.

Instructions

The WordPress dashboard makes it very easy to restrict access to particular pages.

1. Start by logging into the WordPress dashboard. You can do this via the Media Temple account center by selecting WP ADMIN, or by navigating to yourdomain.com/wp-admin. After logging in, select Pages from the menu on the left. 

2. hover over the page that you would like to protect and select Quick Edit

 

3. Locate the password field and type in a password for the page. Alternatively, check the private box to prevent anyone but admins from viewing a particular page. 

Password Protect Directory via the AccountCenter

Create your Web Users

  1. Log into your AccountCenter.
  2. Click on Password Protect Folders.

    acGRIDmainmenu_filemanagement_password_folders

  3. Click on the ADD A NEW WEB USER button.

    acGRIDmainmenu_filemanagement_password_webuser

  4. Create a username and password.

    This user only applies to your password-protected folders. You may also assign a user to a group, if one has already been created.

    acGRIDmainmenu_filemanagement_password_wu_edit

  5. Click SAVE and continue onto create a Web User Group and Protected Folders.

Create your Web User Groups

  1. Click on ADD A NEW WEB GROUP.

    acGRIDmainmenu_filemanagement_password_add_wgroup

  2. Choose your group name and add users to your new group.

    acGRIDmainmenu_filemanagement_password_groups

    • Group Name: Name for this web group.
    • Add Users To Group: The web users that belong to this group.
  3. Click Save and continue on to create Protected Folders.

Create your Protected Folders

  1. Click on PROTECT A NEW FOLDER.

    acGRIDmainmenu_filemanagement_pass_folders_new

  2. Choose your settings.

    acGRIDmainmenu_filemanagement_password_folderz

    acGRIDmainmenu_filemanagement_password_descript

    acGRIDmainmenu_filemanagement_password_choose

    • Folder: Choose the path you wish to protect.
    • Description: The description displayed to users when prompted for authentication, such as "VIP Client Restricted Area."
    • Group Access: Select the Group(s) that can access this folder.
    • User Access: Select the User(s) that can access this folder.
  1. Log into the Plesk Control Panel for your domain.

    TIP:

    These screenshots are from a DV 4.0 running Plesk 11 and are also applicable to the DV running Plesk 11.5 (though some cosmetic differences may persist). If you are on a DV 4.0 and are running Plesk 10.x, please see this article for upgrade information: How do I upgrade Plesk?

  2. From the Home page, click on Websites & Domains.

  3. Click on Show Advanced Options.
  4. Select Password-protected Directories.

  5. Click on [Manage] for the domain for which you'd like to create the password protected directory.
  6. Click on the Add Protected Directory icon.

  7. Complete the form. In our example, we create a protected directory called restricted, entitled Restricted Access.

  8. You will be returned to the previous page with a confirmation message.

  9. Next, we'll add a user to access the protected directory. Click on the directory you created previously.

  10. Click on the Add New User icon.

  11. Complete the form. Be sure to use a strong password. Click the OK button to save your user.

    DV4 ppd-05.jpg

  12. You should receive a confirmation that your user was created.

  13. Next, we'll create a simple html document in the /restricted folder and test the password protection.

    Filename: index.html

    <html>
    <body>
    <h1>Login Successful</h1>
    <p>This directory has been password protected.</p>
    </body>
    </html>
    

    Connect via FTP and upload this file to the /restricted directory. Alternatively, you can use the Domain File Manager in your Plesk Control Panel. For instructions on how to use this tool, please see this article.

    Point your browser to the password protected directory. In this example, we go to http://dv-example.com/restricted/ and are presented with a login box.

    DV4 ppd-07.jpg

    Enter the username and password for a successful login.

    DV4 ppd-08.jpg

Password Protect a Directory via SSH

This details how to use SSH to password protect web directories for your server. To proceed with these instructions, you will need SSH and FTP access to your server.

  • Connect to the Grid via SSH. If you need help with this step, please refer to our article: Connecting via SSH to your server.
  • Navigate to the html directory for the domain you'd like to protect. The command will look something like:
    cd /home/00000/domains/example.com/html/
  • Connect to your DV via SSH. If you need help with this step, please refer to our article: Connecting via SSH to your server.
  • Navigate to the directory for the domain you'd like to protect. The command will look something like:
    cd /var/www/vhosts/example.com

1. Use the htpasswd command to create a username and password that will be used to log into the directory you would like to protect. This username and password will be requested via a pop-up dialog box when users enter the protected directory. The command you'll need to use will look like this:
htpasswd -c .htpasswd janesmith

2. Follow the prompts and enter the password for this new user twice.

3. Create a .htaccess file with the following contents:

AuthUserFile /home/00000/domains/example.com/html/.htpasswd
AuthGroupFile /dev/null
AuthName "Authentication Pop Up"
AuthType Basic
<LIMIT POST GET>
require valid-user janesmith
</LIMIT> 

AuthUserFile /var/www/vhosts/example.com/.htpasswd
AuthGroupFile /dev/null
AuthName "Authentication Pop Up"
AuthType Basic
<LIMIT POST GET>
require valid-user janesmith
</LIMIT>