Allow only root and domain group to login on Linux server

active-directoryauthentication

I have successfully installed PBIS-open to authenticate against active directory. I also used the /opt/pbis/bin/config RequireMembershipOf command to allow a certain domain group to login.

I would now like to allow root, and the group(s) specified with the /opt/pbis/bin/config RequireMembershipOf command, and deny all other local users to login. Is there any way to do this?

Best Answer

If you would like to use pam_access in redhat and centos and so on, first you need to include the module in your pam configura as follow.

authconfig --update --enablepamaccess

Now you can configure which users that can use your server.

/etc/security/access.conf:

my example rules

+ : DOMAIN\admins : ALL
+ : root : ALL
- : ALL : ALL

If you use DOMAIN\ sintax in front of the users and groups, that would say you are using winbind, for AD join, I'm using pam_ldap with sfu in the windows side, for this reason in my comments I don't use the domain.

Now you have configured Pam for the users access control, but Now you need to be sure that sshd is using pam,

grep "UsePAM" /etc/ssh/sshd_config
UsePAM yes

If the UsePAM isn't yes, you need to change this to yes and restart sshd service