我有一些使用Windows Active Directory身份validation的Linux机器,工作得很好(Samba + Winbind)。
现在我想要做的只是允许某些人或某些组使用Active Directory凭据login。 目前,任何拥有有效AD帐户的人都可以login。 我想限制这只有几个小组。 这是可行的吗?
假设组可用于Linux系统,我build议编辑/etc/security/access.conf Ubuntu,RedHat发行版(及其叉),可能还有其他一些。 这不需要编辑PAM文件,并且是一个很好的标准地方。 文件中通常有例子,注释。
我目前使用/etc/ssh/sshd_config的AllowGroups指令来限制谁能够login。在该行上指定一个或多个AD组,并且这些人将是唯一能够login的人。
请记住,这只适用于你的用户只通过SSH远程访问服务器。 如果他们在当地唱歌,你需要find另一个解决scheme。
是的,有几种方法可以完成这个工作,具体取决于你想要完成的任务。
第一种方法可以通过sambaconfiguration完成。 这将只允许这些用户连接到Samba,其他用户仍然可以通过其他服务(SSH,本地术语等)login。 有了这个,你需要在smb.conf的[global]部分添加一行:
valid users = @groupA @groupB
另一种方法是修改PAM规则。 不同的分布在这里有细微的差别,但一般来说每个服务都有PAM规则以及常用规则,你可以决定什么是最好的。 您需要使用pam_require模块添加帐户限制。 我的笔记本电脑(Fedora 13)上的一个例子是将/etc/pam.d/system-auth中的帐户部分修改为:
account required pam_unix.so account required pam_require.so @groupA @groupB account sufficient pam_localuser.so account sufficient pam_succeed_if.so uid < 500 quiet account required pam_permit.so
为了简化pipe理,您可能需要在AD中创build一个新组,以便跟踪可以login到此服务器的用户。
(我在这里谈论桑巴3,现在没有关于桑巴4的经验。)
没有必要编辑这些/etc/pam.d/xxx文件。 pam_winbind.conf是你想要的文件,它通常位于/etc/security/pam_winbind.conf 。
它是pam_winbind模块的configuration文件,适用于CentOS / Redhat和Debian / Ubuntu。 您可以阅读pam_winbind.conf的手册页以供参考。
这是一个示例文件。
# # pam_winbind configuration file # # /etc/security/pam_winbind.conf # [global] # turn on debugging ;debug = no # turn on extended PAM state debugging ;debug_state = no # request a cached login if possible # (needs "winbind offline logon = yes" in smb.conf) cached_login = yes # authenticate using kerberos ;krb5_auth = no # when using kerberos, request a "FILE" krb5 credential cache type # (leave empty to just do krb5 authentication but not have a ticket # afterwards) ;krb5_ccache_type = # make successful authentication dependend on membership of one SID # (can also take a name) # require_membership_of = SID,SID,SID require_membership_of = S-1-5-21-4255311587-2195296704-2687208041-1794 # password expiry warning period in days ;warn_pwd_expire = 14 # omit pam conversations ;silent = no # create homedirectory on the fly mkhomedir = yes
我努力在RHEL 7中获得以上任何一项工作。以下是我能够工作的内容。
/etc/sssd/sssd.conf
将access_provider = ad更改为access_provider = simple + simple_allow_groups = @[email protected], @[email protected]
%[email protected] ALL=(ALL) ALL 重新启动sssd服务。
我已经实现了只让一个AD_USER或者AD_GROUP通过AD身份validationsshloginlinux的方块。
具体细节如下:(注意步骤7和8)