Introduction
Password protecting Web directories : Linux
Summary
To password protect a directory:
1. In a text editor, create a file named .htaccess. 2. Insert the following lines into the file, making the appropriate replacements.
AuthUserFile /home/[domainname]/.htpasswd AuthGroupFile /dev/null AuthName ByPassword AuthType Basic require user [username]
3. Save the file as plain text & then upload it via FTP in ASCII mode to the following location:
/www/[domainname]/[directoryname]/
4. Log onto the server via SSH. 5. At the command prompt, issue the following command:
htpasswd -c /home/[domainname]/.htpasswd [username] This creates a file named .htpasswd in your home directory.
6. When you are prompted for a password, enter the password to associate with this user. 7. To grant access to another user, add the following line to the .htaccess file:
require user [username2]
8. Save & upload the file as you did in step 3. 9. Log onto the server via SSH & issue the following command:
htpasswd /home/[domainname]/.htpasswd [username2]
Note: For security purposes, you should store the .htpasswd file in your home directory.
|
No responses found. Be the first to respond and make money from revenue sharing program.
|