Would you like to learn how to configure the PAM authentication on the Apache server? In this tutorial, we are going to show you how to configure the Apache service to authenticate users using the Plugable Authentication module also known as PAM on a computer running Ubuntu Linux.
• Ubuntu 20
• Ubuntu 19
• Ubuntu 18
• Apache 2.4.41
Copyright © 2018-2021 by Techexpert.tips.
All rights reserved. No part of this publication may be reproduced, distributed, or transmitted in any form or by any means without the prior written permission of the publisher.
Equipment list
The following section presents the list of equipment used to create this tutorial.
As an Amazon Associate, I earn from qualifying purchases.
Apache – Related Tutorial:
On this page, we offer quick access to a list of tutorials related to Apache.
Apache – PAM authentication
Install the Apache server and the PAM module.
Enable the Apache2 PAM authentication module.
In our example, we are going to request authentication to users trying to access a directory named Test.
Create a directory named TEST and give the user named www-data permission over this directory.
Configure the Apache server to request the PAM authentication to users trying to access this directory.
Edit the Apache configuration file.
Here is the file, before our configuration.
Here is the file, after our configuration.
The Apache server was configured to request password authentication to access the directory named TEST.
The Apache service was configured to authenticate user accounts using the PAM authentication module.
Create the PAM configuration file.
Here is the file content.
In our example, we are going to authenticate the Apache service access using the Linux accounts.
Enable the Apache service to read the SHADOW file.
Restart the Apache service.
Congratulations! You successfully configured the Apache authentication.
Apache – PAM authentication Test
Create a Linux account to be used in the authentication test.
In our example, we created a Linux account named ADMIN.
The password configured was 123qwe.
Open your browser and enter the IP address of your Apache web server.
In our example, the following URL was entered in the Browser:
• http://192.168.15.11
The Apache default page will be displayed.
Open your browser and enter the IP address of your web server plus /test.
In our example, the following URL was entered in the Browser:
• http://192.168.15.11/test
On the login screen, Enter a local username and its password.
• Username: admin
• Password: 123qwe
After a successful login, you will be authorized to access the directory named TEST.
Congratulations! You have configured the PAM authentication on an Apache server.