nerdexam
Linux_Foundation

LFCS · Question #418

The system administrator wishes to use the pam_listfile.so module to restrict which users are allowed to login via SSH. Which line will configure this behaviour?

The correct answer is C. auth required pam_listfile.so item=user sense=allow file=/etc/sshd/sshd.allow onerr=fail. To restrict SSH logins to specific users via pam_listfile.so, the configuration must explicitly allow users listed in a file and ensure failure if the file is unreadable.

Submitted by renata2k· Apr 18, 2026Service Configuration

Question

The system administrator wishes to use the pam_listfile.so module to restrict which users are allowed to login via SSH. Which line will configure this behaviour?

Options

  • Aauth required pam_listfile.so item=user sense=deny file=/etc/sshd/sshd.deny onerr=succeed
  • Bauth required pam_listfile.so item=user sense=allow file=/etc/sshd/sshd.allow onerr=succeed
  • Cauth required pam_listfile.so item=user sense=allow file=/etc/sshd/sshd.allow onerr=fail
  • Dauth required pam_listfile.so item=user sense=deny file=/etc/sshd/sshd.deny onerr=fail

How the community answered

(15 responses)
  • A
    7% (1)
  • B
    13% (2)
  • C
    80% (12)

Why each option

To restrict SSH logins to specific users via `pam_listfile.so`, the configuration must explicitly allow users listed in a file and ensure failure if the file is unreadable.

Aauth required pam_listfile.so item=user sense=deny file=/etc/sshd/sshd.deny onerr=succeed

`sense=deny` would prevent listed users from logging in, which is the opposite of the desired 'restrict which users are allowed' (implying a whitelist); `onerr=succeed` is also a security risk, allowing access if the file is missing or unreadable.

Bauth required pam_listfile.so item=user sense=allow file=/etc/sshd/sshd.allow onerr=succeed

While `sense=allow` is correct, `onerr=succeed` is a security risk as it would allow all users to log in if the allow file is missing or unreadable, compromising the restriction.

Cauth required pam_listfile.so item=user sense=allow file=/etc/sshd/sshd.allow onerr=failCorrect

This line correctly uses `pam_listfile.so` to check the `user` (`item=user`), `allow` (`sense=allow`) users listed in `/etc/sshd/sshd.allow` (`file=/etc/sshd/sshd.allow`), and critically, `fail` (`onerr=fail`) if the file cannot be accessed, which prevents an insecure fallback and ensures security.

Dauth required pam_listfile.so item=user sense=deny file=/etc/sshd/sshd.deny onerr=fail

`sense=deny` would block listed users, not allow only a specified list; while `onerr=fail` is generally more secure, the `sense` parameter is incorrect for an allowlist.

Concept tested: PAM `pam_listfile.so` configuration

Source: https://manpages.debian.org/unstable/libpam-doc/pam_listfile.8.en.html

Topics

#PAM#SSH Configuration#User Authentication#Access Control

Community Discussion

No community discussion yet for this question.

Full LFCS Practice