I have join my linux to windows domain succesfully, and now everyone in the domain is able to log in to the server by using ssh.
But we only want to allow certain users from a group to log in.
Example of current two groups:
#it_admin
Domain Admin
You can do this in two ways. One is to let the SSH configuration filter, and the other is to use
pam_access
.Using SSH configuration
To
/etc/ssh/sshd_config
, add aAllowGroups
line:From the manpage:
Domain Admin
here doesn't matchDomain Admin
the group name, but two separate groupsDomain
andAdmin
. You'll have to use something likeDomain*Admin
and*it_admin
, since neither(space) nor (
#
) are usually valid characters in Linux groups. To be on the safer side, use?
instead of*
:Domain?Admin
and?it_admin
, so that only one character is allowed by the wildcard. You can also add a pattern-based DenyGroups section. See thePATTERNS
section inman ssh_config
.Using
pam_access
Add lines to
/etc/security/access.conf
of the form:There are plenty of comments in that file which document how to use it.
man pam_access
is quite bare, so most information would come from those comments.pam_access
is more powerful in that it can control non-SSH logins as well (TTYs, GUI, etc.). This particular line, for example, should deny any user who does not haveDomain
orAdmin
as a group from logging in at all (unless other lines allow them).Both approaches are pretty flexible, and I don't know the pros and cons, so no recommendations.