====== Password protecting a directory ====== To password protect a directory, do the following: - Sign in to Virtualmin (see [[Logins]]). - Click **Webmin Modules** in the left-hand navigation, then click **Protected Web Directories**. - Click **Add protection for a new directory**. - Under //Directory path//, enter the directory you want to protect or choose one by clicking the **...** button. - For //File containing users// leave as **Choose automatically** (to create a .htpasswd file) or specify one yourself as desired. - For //File containing groups// leave as **None** (unless you know what you are doing and need user groups). - For //Password encryption//, use either **Unix crypt** or **MD5**. - Under //Authentication realm//, enter anything to 'name' the protected resource. Visitors' browsers will use that to help them understand what they are logging into. - For //Users to allow//, leave as **All users in file** (or specify as needed). - Click **Create**. You should now see a listing of your protected directories. - Under //Associated users and groups//, click **Add new user** in the right column adjacent to your newly created directory (you'll need to perform this step in order to setup a user name and password). - Enter a //Username// and //Password// for the directory and make sure //Enabled?// is set to **Yes** (If you forget your password you can always go back to this screen to change it). - Click **Create**. You should now see your list of protected directories and your newly protected directory will have a user name associated with it in the //Associated users and groups// column. You've now password protected a directory. If you want, you can go back and add more users by repeating the last three steps. The above will only protect real directories, i.e. it can't be used to protect Rails views or Textpattern sections because they are not real directories (even though they may look like it judging by the URL).