New user's registration have been closed due to high spamming and low trafic on this forum. Please contact forum admins directly if you need an account. Thanks !

How to: Enable password protection - .htaccess

A collection of tips on howto tweak your Bubba.
Post Reply
Magnus
Posts: 51
Joined: 02 Jan 2007, 03:52
Location: Sweden
Contact:

How to: Enable password protection - .htaccess

Post by Magnus »

A guide how to enable password protection in your web catalogs on your Bubba Two.

Using ssh, log on to Bubba (as your regular user). Type

Code: Select all

su

to become root. The root password is

Code: Select all

excito
Edit your sites-file:

Code: Select all

 nano /etc/apache2/sites-enabled/bubba
You will find the part (observe <Directory /home/web/>) in two places:

Code: Select all

        <Directory /home/web/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>


Edit it in both places to:

Code: Select all

        <Directory /home/web/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>


Now you need to restart the webserver.

Code: Select all

 
 /etc/init.d/apache2 restart


Create a .htaccess file in the web catalog you want to password protect:

Code: Select all

nano /home/web/protectedfiles/.htaccess
(Where protectedfiles is the catalog you will protect in this example.)

A "standard" .htaccessfile could look something like:

Code: Select all

AuthType Basic
AuthName "Password Required"
AuthUserFile /etc/.passwords/.htpasswd
Require user user1
(Where user1 is the username you log in with in this example.)

Save your .htaccessfile.

To password protect more catalogs simply create and place one .htaccessfile in every catalog you need to protect. Remember to change the user1 to whatever user you desire.

Create a catalog to place your password file in:

Code: Select all

 
mkdir /etc/.passwords


To create the file containing the passwords for the users, type:

Code: Select all

 
htpasswd -c /etc/.passwords/.htpasswd user1

You now have to enter a password for the user "user1".

To add more users in the .passwords file, leave out the -c parameter:

Code: Select all

 
htpasswd /etc/.passwords/.htpasswd user2

You now have to enter a password for the user "user2".

Open a web browser and brows to your protected catalog: www.yourbubba.com/protectedfiles
You should have to enter user name "user1" and your selected password.

That all! Any problems let me know.
Magnus, Excito developer
www.excito.com
support@excito.com
squadra
Posts: 96
Joined: 19 Sep 2008, 09:02

Post by squadra »

when you update your bubba using the admin this config below is used everytime, instead of the changed one to authconfig or all. This is not a nice feature :-)

<Directory /home/web/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
Magnus
Posts: 51
Joined: 02 Jan 2007, 03:52
Location: Sweden
Contact:

Post by Magnus »

The reason for the update not taking notice of the edited /etc/apache2/sites-enabled/bubba file is because it was not intended for the user to edit from the beginning. The problem is now added to our todo, thanks for noticing!
/Magnus
Magnus, Excito developer
www.excito.com
support@excito.com
sam
Posts: 7
Joined: 14 Feb 2009, 09:28

linking access with the linux user account

Post by sam »

Thanks for this HowTo - it was very easy to get going.

But what I'd really like is to link the access to the linux user account. I was looking at some posts mentioning the mod-auth-pam module, but I couldn't get this working.
Is such a thing possible?

Alternatively, is there some web interface package that would let me manage users from a web page? (not necessarily bubba linux users, but still link user name/pw with the .htaccess)

Cheers,
Sam
Post Reply