Restrict Login To Members Of Specific Group(s)
(2026-11-25)
Create a custom PAM profile:
Name: Access control via /etc/security/access.conf
Default: yes
Priority: 128
Account-Type: Additional
Account:
required pam_access.so
Append the below to the bottom of /etc/security/access.conf:
+ : root : ALL
+ : (allowed_group) : ALL
+ : (sudo) : ALL
- : ALL : ALL
- it is recommended to keep root and the sudo group in this list so you don't accidentally lock yourself out
- if you have user-specific cron jobs running (whether or not the user is a system user and/or otherwise interactive) you have to make sure cron can be used, structure the file like this:
+ : root : ALL
+ : (allowed_group) : ALL
+ : (sudo) : ALL
+ : cron crond : 0
- : ALL : ALL
...or specify those user accounts specifically instead of the cron line.
Activate the profile:
sudo pam-auth-update --package
Testing:
- it is advised to keep an already-logged in session running while testing, so you don't inadvertently lock yourself and everyone else out.