How do I restrict system logins using PAM?

Updated -

There is a PAM module called pam_listfile.so that can restrict/allow logins to a specific list of users or groups. To allow login to only the root user and another user called bob, add this line at the top of /etc/pam.d/system-auth:

auth required /lib/security/pam_listfile.so onerr=fail item=user sense=allow file=/etc/allowedus...

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content