Interview Prep/Linux/Users, groups and access control

How would you make sure a user can only log in during business hours from the office network?

IntermediateScenarioUsers, groups and access control
Answer

Situation read → PAM access controls by time and origin.

What I'd do →

  1. Time: add account required pam_time.so to /etc/pam.d/sshd, and in /etc/security/time.conf:
sshd;*;alice;Wk0900-1800
  1. Origin: add account required pam_access.so and in /etc/security/access.conf:
+ : alice : 10.20.0.0/16
- : alice : ALL
  1. Back it up with Match User alice + AllowUsers [email protected].* in sshd for defence in depth.

Why → PAM account modules decide whether an authenticated user may log in.

Interview tip → Always test PAM changes with a second root session open.

All Linux questions Roadmap: Linux

More on Users, groups and access control