.htpasswd Setup in ubuntu
by admin on May.30, 2010, under RHEL5, Ubuntu, Ubuntu 9.10, ubuntu 10.04, ubuntu 7.10, ubuntu 8.04, ubuntu 8.10, ubuntu 9.04
In our site we can can limit access only to parties with usernames and passwords (provided by us) by using .htaccess, a basic security function built into the HTTP protocol.
The .htaccess file must be placed in the directory you want protected.
ex)
here site is the web directory
#cd /var/www/site
#vim .htaccess
Then add the following
AuthUserFile /var/www/site/.htpasswd
AuthGroupFile /dev/null
AuthName “Private”
AuthType Basic
require valid-user
AuthGroupFile /dev/null
AuthName “Private”
AuthType Basic
require valid-user
Then save the file and exit
#sudo htpasswd -c /var/www/site/.htpasswd username
.htpasswd is where you will place the list of authorized usernames and passwords. The format is as follows:
username:password
Passwords are in an encrypted form.