Help with PAM changes

I need to add 4 lines of syntax into /etc/pam.d/{password-auth,system-auth}:

Disregard the extra backicks, they are for emphasis only.

`auth        required              preauth   silent    audit  deny=5  even_deny_root   fail_interval=900     unlock_time=900`

`auth         sufficient       try_first_pass`

`auth       [default=die]   authfail  audit   deny=5   even_deny_root   fail_interval=900   unlock_time=900`

`account     required`

My question is related to the relative positioning of these lines of syntax.

I see them in different files I reference located in different places. How do I know what order to place them, in relation to all of the other lines of syntax already present?

I know this is a very sensitive technology and obviously for security purposes.

Any guidance in an authorative manner would be greatly appreciated.

1 Like

I have learned with no input from anyone, that you have to keep all auth separate from account separated from password separated from session lines.

What I am concerned about still is the order of precedence of the control which could be one of {required, requisite, sufficient, optional, include and substack} for a given type. Is there any precedence? How do I know where/how to add new lines into an existing stack?

Red Hat documents PAM in: 10.2. About PAM Configuration Files Red Hat Enterprise Linux 7 | Red Hat Customer Portal
Some other details are in man pam.d. Yes, there is some precedence in controls.

The system’s tool to configure authentication is authselect. See man authselect

Ansible has module pamd for managing files in /etc/pam.d/. I presume the other configuration management tools do too.

Thanks jlehtone,
nice to see you over on this site too!

I understand based on my reading of the pam.conf man page, that the line consists of:

service    type     control      module-path   module-arguments

In reality the service has a file named after it within /etc/pam.d like the following services: ssh, sssd, su, sudo, atd, crond, gdm, login, and so on. No questions here.

So when you review a file named after ssh, for example, the syntax is then the remaining fields from left to right:

type     control      module-path   module-arguments

The type field is one of auth, account, password, and session, and they are always added, removed, modified, in the same part of the stack. No questions here.

It is once we get down to the last three fields on the line of syntax:

control      module-path   module-arguments

Once you, I, we, get down to these last 3 fields is there an order of precedence that I need to understand that would alter the behavior of PAM-enabled services? **It is the last 3 fields that I am concerned about. **

Would using the tool authselect teach me how such things would be forced into proper place?

The Red Hat document writes:

If a module’s control flag uses the sufficient or requisite value, then the order in which the modules are listed is important to the authentication process.

In other words, the modules are evaluated in order. The flags differ on whether all modules have to be evaluated.

Frankly, I’m still clueless about the authselect.

Thank you sir. Seeing you write that you are clueless about authselect leaves me feeling a little better. :wink: