pam_check_host_attr无法正常工作

免责声明:我是新来的ldap,所以希望我没有做任何重大错误!

目的:集中用户凭证并限制客户端login到某些机器。

我通过使用以下内容在新鲜的Ubuntu 14.04服务器上安装了准系统openLDAP服务器。 实质上,安装LDAP并进行架构更改以启用用户的host属性:

 # Install ldap apt-get install -y slapd ldap-utils ldapscripts # Modify the schema so we can use the host attribute for users grep -P '^include.+?\.schema' /usr/share/slapd/slapd.conf > ./schema_convert.conf echo -e "include\t\t/etc/ldap/schema/ldapns.schema" >> ./schema_convert.conf # Convert the schema into LDIF mkdir -p ./ldif_output index=$(slapcat -f ./schema_convert.conf -F ./ldif_output -n 0 | grep ldapns,cn=schema | sed -re 's/^\S+\s+//') slapcat -f schema_convert.conf -F ldif_output -n0 -H \ ldap:///${index} -l cn=ldapns.ldif # Modify the file, ready for importing sed -i -r \ -e 's/^dn:.+$/dn: '${index/\{*\}/}'/' \ -e 's/^cn:.+$/cn: ldapns/' \ -e '/^(structuralObjectClass|entryUUID|creatorsName|createTimestamp|entryCSN|modifiersName|modifyTimestamp):/d' \ cn=ldapns.ldif # Add the schema to the slapd-config ldapadd -Q -Y EXTERNAL -H ldapi:/// -f cn\=ldapns.ldif 

我已经添加了几个小组和人员。 我的一个用户将host属性值设置为我的一台机器( thor )。

thorvenus我已经configuration他们对我的LDAP服务器进行身份validation – 这工作。 然后我修改了thorvenus上的/etc/ldap.conf ,这样就thor注释了:

 pam_check_host_attr yes 

我希望当我尝试loginvenus我不会被允许,因为用户只有在我的ldap服务器的host属性中设置了thor

你能提供任何见解,如何限制用户login到只有一个特定的主机?

事实certificate,我必须按照/usr/share/doc/libpam-ldap/README.Debian中的说明修改我的/etc/nsswitch文件,其中指出:

如果要使用“pam_check_host_attr”function,请确保“pam_unix.so”不通过名称服务交换机(NSS)提供有效的“帐户”,这会覆盖您的LDAPconfiguration。 在/etc/nsswitch.conf中不要使用“ldap”作为“shadow”,只需使用“shadow:files”即可。

因此,当我改变我的/etc/nsswitch文件:

 passwd: files ldap group: files ldap shadow: files ldap hosts: files dns mdns4_minimal [NOTFOUND=return] networks: files protocols: db files services: db files ethers: db files rpc: db files netgroup: nis 

至:

 passwd: files ldap group: files ldap shadow: files hosts: files dns mdns4_minimal [NOTFOUND=return] networks: files protocols: db files services: db files ethers: db files rpc: db files netgroup: nis 

并更新PAM:

 pam-auth-update 

基于主机的身份validation现在可用。