Skip to content

TechDirectArchive

Hands-on IT, Cloud, Security, Veeam & DevOps

  • Home
  • About
  • Advertise With US
  • Reviews
  • Contact
  • Toggle search form

How to Configure Advanced PAM in Linux

Posted on 22/12/202117/08/2026 Raphael Gab-Momoh By Raphael Gab-Momoh No Comments on How to Configure Advanced PAM in Linux
  1. Home
  2. Linux
  3. How to Configure Advanced PAM in Linux
feature_image

The Pluggable Authentication Module (PAM) adds a layer of security to administrative tools and commands. It includes dynamically loadable libraries that dictate how different applications verify and authenticate users. Explore this article to learn how to configure advanced PAM in Linux. In this article, we shall learn how to Configure Advanced PAM in Linux. Please see Unable to bind to LDAP or AD in Pleasant Password Server, and What’s New? Install Windows Server 2025 and enable RDP.

You can find other related guides here: Delivering System Utilization Report on a Linux based OS, and how to enable LDAP over SSL with a third-party Certificate such as DigiCert.

Understanding Advanced PAM

You have used advanced PAM if you are logged on to a Linux system without realizing, SSH also uses PAM. It is also used to make user authentication standard. The config files can be located in /etc/pam.d/login

auth [ user Unkown=ignore success=ok ignore=ignore default=bad] pam_securetty.so

The highlight text is a syntax of a pam rule, the rule type is auth. What the rule does is to make sure pam_securetty.so ensures that the root user is logging in.

And if it is, it makes sure that the user is logged in from a secured terminal, which is /etc/securetty.

So, everyone that is trying to login as root and not from a secured terminal will have their access denied . A user can only login from a secured terminal defined in /etc/securetty. Configuration files are named according to the programs using them in /etc/pam.d/

TYPES OF PAM RULES:
Authentication Management (Auth) this validates a user's identity
Account Management and this will allow or deny based on access policy
Password management, manages password change policies
Session management, applies settings for user sessions

TYPES OF PAM  CONTROL FLAGS:

Required if the first rule passes PAM proceeds to the next rule of the same type, if it fails PAM still proceeds but the result returns a failure
Requisite If this passes, PAM does not check any more rules 
Sufficient If this rule passes, no other rule of the same type gets processed
Optional Whether it passes or fails, PAM continues to the next
Include Includes all rule of the same type from designated configuration files

Demo

#cd /etc/pam.d
#ls

Configuring Advanced PAM in Linux

When we get into this config directory, we will realize that there are lots of files there, normal and some symbolic links, the symbolic links all reference parent, for example passwd-auth is a symbolic link to passwd as shown in the screenshot below.

If we cat for samba in the screenshot below. We will see that all the rule types mentioned above are accounted for.

pamdjpg
/etc/pam.d files
cat samba
how to configure PAM in Linux-ruletype-1
rule types
control-flags
control flags

We should notice the rule types are in red and the control flags are in blue. If we further cat into any of the files in the required flag. We can see that the files are further separated into the required rule types; auth, account, password, and session.

how to configure PAM in Linux-auth-1
cat password-auth

Understand Control Flags

As we can see, each of the flag is strictly adhered to, The rules are processed in order as the control flags imply.

Looking at the screenshot carefully, we can see that it is required that the environment is set up first and next it is required to set a delay on failure.

The next two steps showed that the process was successful, next it is sufficient to not require any other form of restriction.

Again, it is sufficient that if the first password passes, we can login without any issues. The last one determines what happens to the error generated in the log file when a failure finally happens.

If we cat sshd we will see that it is also separated into sections s and there quite a few number of include lines, to see what those do, we have to cat to see what’s in, lets cat into postlogin for example

how to configure PAM in Linux-include
cat sshd
does-nothing
no password-auth

Modify PAM Configuration

The postlogin server example does not do anything because we do not have an auth rule type to include, if we look at the screenshot above carefully, account and password do include password-auth. So, let’s cat into password-auth

how to configure PAM in Linux password-auth

So, if we cat into account or password rule type as shown above. We get these results shown

how to configure PAM in Linux-accountpassword
account & password

As we can see, we do have things in account and password rule type that need to be pulled in and processed.

Ideally, the tool to use to update these files is called authconfig-tui so if you are going to amend these files, the best practice for manipulating things with an n-cursor interface is to use the tool.

 #authconfig-tui
how to configure PAM in Linux-authconfig
authconfig-tui

We can scroll through and configure any of the parameters using this tool instead of manually changing anything.

To select an item, you need to hit the space bar on your keyboard. So, assuming we have ldap installed on the system and we select ldap, we just hit space to select ldap and click on next.

how to configure PAM in Linux-ldap
settings without ldap configured

We tried to set up ldap and it returned the message in the screenshot. So let’s set up ldap to configure advanced PAM.

how to configure PAM in Linux-dcng
ldap settings

It had blank values, so we use ldap.example.com as the server and base DN as dc=ng, dc=local, to see if what we did succeeded in adding ldap to the files. Lets run the command

#grep ldap *
how to configure PAM in Linux-pamldap
pam_ldap
From the image above, we see that pam_ldap has been added to the files.

We need to make a change to the default login definitions and change UID to 500

#vim /etc/login.defs
uid
uid_min

Update

Next thing to do to configure advanced PAM in Linux is to make the change reflect in all the files. So use the code below

#authconfig --updateall
authconfig-1

By default, PAM authentication is set to succeed if UID is greater than 1000 but we have set it to 500, so if we do a grep 500 * , we will see that everything has been changed to 500.

500
PAM _succeed if uid >=500

Install PAM Modules

There are lots of modules preconfigured in the system that we can add to PAM and we can find these in

# ll /usr/lib64/security/pam*
pam-tall
pre-configured modules

One of such module that is usually used very often is PAM_tally. And we can check this from the man pages as well. we can get more information about tally2 module

#man pam_tally2
pam-tally2
man_tally2

Man pam tally2 gives an interesting example. with the code line highlighted in the screenshot

#vim /etc/pam.d/login
# pam_tally2.s0 deny=4 even deny root unlock time = 2000

The line of the second code we copied from the tally2 man page will lock the account after 4 failed login attempt and it will even lock root, after 20 minutes it will unlock the account.

If we paste the code in the auth stack of vim/etc/pam.d/login, pam_tally2 will be called anytime we fail to login

Summary

By now, you should have a clear understanding of how to configure advanced PAM in Linux.

Bear in mind that Pam uses control flags and rules to implement security of how users are authenticated. It is not advisable to configure it manually.

We use authconfig-tui to configure LDAP and other necessary settings. We can add a popular module called pam_tally2 to our auth stack to checkmate how our system should act when a user fails to login.

Thank you for reading this post. Kindly share it with others.

  • Share on X (Opens in new window) X
  • Share on Reddit (Opens in new window) Reddit
  • Share on LinkedIn (Opens in new window) LinkedIn
  • Share on Facebook (Opens in new window) Facebook
  • Share on Pinterest (Opens in new window) Pinterest
  • Share on Tumblr (Opens in new window) Tumblr
  • Share on Telegram (Opens in new window) Telegram
  • Share on WhatsApp (Opens in new window) WhatsApp
  • Share on Mastodon (Opens in new window) Mastodon
  • Share on Bluesky (Opens in new window) Bluesky
Linux Tags:LDAP

Post navigation

Previous Post: Stuck at Start PXE over IPv4: PXE-E18 Server response timeout
Next Post: How to Install LAMP Stack on Ubuntu 18.04

Related Posts

  • integrate VHR with VBR
    How to deploy and integrate VHR with VBR Backup
  • Slide1 1
    Create Multiple Users with Passwords in Ubuntu Linux Linux
  • SystemUtilization
    Delivering System Utilization Report on a Linux based OS Linux
  • cryptsetup
    How to encrypt a partition with Cryptsetup Linux
  • lampstack feature lamp stack ubuntu
    How to Install LAMP Stack on Ubuntu 18.04 Linux
  • SSL on WAMPServer
    Setup VirtualHost with SSL on WAMP Server Linux

More Related Articles

Security enhanced linux How to setup SELinux on a Linux server Linux
selinux in production How to locate directory file context and restore it with SELinux Linux
Screenshot 2022 02 25 at 02.06.20 How to install SAMBA file shares for Servers and Clients Linux
image 129 How to deploy Ansible AWX on centos 8 Linux
PersonalHow to Create Symbolic Links in Linux All You Need to Know About Symbolic Links in Linux Linux
Edge Install Microsoft Edge Browser on Ubuntu Linux Linux

Leave a Reply Cancel reply

You must be logged in to post a comment.

Microsoft MVP

vexpert-badge-stars-5

Virtual Background

VEEAMLEGEND

Categories

Top 30 Sysadmin blog

veeaam100

Veeam Vanguard

  • Screenshot 2020 12 30 at 01.03.14
    Device cannot use a Trusted Platform Module: Allow BitLocker without a compatible TPM Windows
  • S3 Bucket Public Access 1
    How to grant public access to S3 Bucket using Policy AWS/Azure/OpenShift
  • images 8
    Microsoft Direct Access: Now Always On VPN Windows Server
  • Azure upgrade adconnect 1 e1782081079535
    Upgrading Azure AD Connect to Microsoft Entra Connect Sync AWS/Azure/OpenShift
  • Enable or disable SA acocunt
    How to enable an SA account that has been disabled Oracle/MSSQL/MySQL
  • downloadzoom recording
    How to download a shared ZOOM recording JIRA|Confluence|Apps
  • Database Collation
    Change SQL Database Collation: ePO events DB and SQL server should match with ePO core collation Oracle/MSSQL/MySQL
  • MachineAccountQuota
    Change the number of MachineAccountQuota a user can add to AD Windows Server

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 1,746 other subscribers
  • RSS - Posts
  • RSS - Comments
  • About
  • Authors
  • Write for us
  • Contact
  • Advertise with us
  • General Terms and Conditions
  • Privacy policy
  • Feedly
  • Telegram
  • Youtube
  • Facebook
  • Instagram
  • LinkedIn
  • Tumblr
  • Pinterest
  • Twitter
  • mastodon
  • Bsky

Tags

Active Directory Azure Bitlocker Microsoft Windows PowerShell WDS Windows 10 Windows 11 Windows Deployment Services Windows Server 2016

Copyright © 2026 TechDirectArchive

Loading Comments...

You must be logged in to post a comment.