Forum Moderators: phranque

Message Too Old, No Replies

.htaccess user authentication not working...

         

spdracer22

3:11 am on Jul 10, 2005 (gmt 0)

10+ Year Member



I'm not sure what's going on, but I can't protect any folders with .htaccess files.

Here's my file:

AuthUserFile /etc/passwd
AuthType Basic
AuthName "/usr/local/apache2/htdocs/phpMyAdmin"
require user_name_here

I was thinking it was a problem with mod_access or mod_auth not being loaded, but when I tried to load the m in httpd.conf, I get errors:

module access_module is built-in and can't be loaded
module auth_module is built-in and can't be loaded

Also, I'm running Apache 2.0.54.

Any help is greatly appreciated. Thanks.

-spd.

marcs

3:32 am on Jul 10, 2005 (gmt 0)

10+ Year Member



I don't think using /etc/passwd will work.

If you do need to use that user/pass data, then create a new password file which has :

username:password

To automatically convert the /etc/passwd file :

awk -F ":" '{print $1 ":" $2}' /etc/shadow > newfile

the newfile will have the content you need. You'll need to do this as root as other users shouldn't be able to
read /etc/shadow

Note that this may not work is passwords are MD5 encrypted in /etc/shadow. Should work fine if they are DES encrypted.

Also, doing this probably isn't a good idea to begin with, if you have to do it anyway, you may want to edit the newfile to remove user root and others you don't need/want in there.

spdracer22

3:51 am on Jul 10, 2005 (gmt 0)

10+ Year Member



I also tried using Webmin to password protect the directory. It created .htaccess and password files for me, and I still don't get an authorization box asking for a username/password. I have tried using multiple browsers (Opera,Firefox,IE), clearing the caches, etc. Nothing is working. I just go immediately into the directory.

-spd.

marcs

4:43 am on Jul 10, 2005 (gmt 0)

10+ Year Member



You're missing some lines in your .htaccess file (if you posted the complete one).

Try say :

AuthUserFile /path/to/newfile
AuthGroupFile /dev/null
AuthName "Your Text Here"
AuthType Basic
<Limit GET POST>
require valid-user
</Limit>

spdracer22

5:05 am on Jul 10, 2005 (gmt 0)

10+ Year Member



Ok, I got it working. I added this to my httpd.conf:

<Directory "my_directory">
Options Indexes Includes FollowSymLinks
AllowOverride None
AuthName "Login"
AuthType Basic
AuthUserFile /my/password/file
require valid-user
</Directory>

I had you use your suggestion above to convert the passwd file for it to work right.

I restarted apache and it works great. Thanks for the help!

-spd.