Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do I force someone to login for a webpage?

Specifically, I have a linux server, where everyone has a login to that server. Can I make users login to the webpage with that login info?

If I can't use that apporach, what are my other options?

share|improve this question
up vote 5 down vote accepted

Assuming you're running Apache, you may want to use an htaccess file. Apache also has built in access controls that you can use.

share|improve this answer

Assuming you are using apache, then you could use the mod_auth_pam module to use the local system for authentication.

At least on Debian/Ubuntu you would need to add the www-data to the shadow group (/usr/sbin/adduser www-data shadow).

You would also need to add a section to your apache configuration like this.

<Location />
    # libapache2-mod-auth-pam is required
    AuthBasicAuthoritative Off
    AuthPAM_Enabled on
    AuthUserFile /dev/null
    AuthType Basic
    AuthName "PAM"
    Require valid-user
    Order Deny,Allow
    Deny from all
    Satisfy Any

You should also strongly consider setting up SSL so your system passwords will not be stolen by someone with a sniffer.

share|improve this answer

If you want to build it into your website, you can build in session management and protect the content that you want.

If you want to give them file access, you may want to look at samba instead.

Just to be sure, are you trying to get people to login to the server and access the server's resources (file shares, etc) by only logging into a webpage and not into the server it self?

Good luck

share|improve this answer

If you want people to be able to login using their server login credentials then take a look at

As other people have mentioned there is also mod_auth_pam but that isn't developed any more but might work for you. As ever YMMV :)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.