我正在尝试配置我的系统以允许我使用公钥身份验证登录(ssh)到主机(Ubuntu 16.04)上的本地帐户,即使/当LDAP服务器关闭时也是如此。
这是一张云图,因此我在本地需要的用户是ubuntu
。此用户没有密码(我不想为安全设置一个密码)。此用户只允许使用公钥身份验证。
此用户拥有UID 1001
,我的所有LDAP用户都拥有UID编号> = 2000。
我一整天都在尝试(例如pam_succeed_if.so
和pam_localuser
)。
现在getent passed ubuntu
正常工作并返回本地passwd行。但ssh
拒绝如此:
Sep 6 17:27:43 ip-10-99-0-241 sshd[24895]: nss_ldap: could not connect to any LDAP server as (null) - Can't contact LDAP server
Sep 6 17:27:43 ip-10-99-0-241 sshd[24895]: nss_ldap: failed to bind to LDAP server ldaps://ldap.domain.tld: Can't contact LDAP server
Sep 6 17:27:43 ip-10-99-0-241 sshd[24895]: nss_ldap: reconnecting to LDAP server...
然后最终以Authentication failed.
失败。
/etc/nsswitch.conf
passwd: compat [success=return] ldap
group: compat [success=return] ldap
shadow: compat [success=return] ldap
/etc/pam.d/common-account
account [success=2 new_authtok_reqd=done default=ignore] pam_unix.so
# NOTE: These two won't work - fatal: Access denied for user <ldap user> by PAM account configuration [preauth]
#account sufficient pam_localuser.so
#account sufficient pam_succeed_if.so uid [le sign] 500 quiet
account [success=1 default=bad success=ok user_unknown=ignore] pam_ldap.so
account requisite pam_deny.so
account required pam_permit.so
account required pam_krb5.so minimum_uid=2000
/etc/pam.d/common-auth
auth [success=3 default=ignore] pam_krb5.so minimum_uid=2000 ignore_root
auth [success=2 default=ignore] pam_unix.so nullok_secure try_first_pass
auth [success=1 default=ignore] pam_ldap.so use_first_pass ignore_unknown_user ignore_authinfo_unavail
# NOTE: Can't login with this (changed the success above)!
#auth requisite pam_succeed_if.so uid [ge sign] 500 quiet
auth requisite pam_deny.so
auth required pam_permit.so
/etc/ldap.conf
bind_timelimit 10
pam_min_uid 2000
nss_initgroups_ignoreusers ubuntu,local
nss_reconnect_tries 2
nss_reconnect_sleeptime 1
nss_reconnect_maxsleeptime 8
nss_reconnect_maxconntries 2
(我尝试使用pre和代码块,但SOF拒绝让我发布,所以很抱歉,如果这看起来很糟糕 - 如果有管理员权限的人可以进入并修复,请做。)
答案 0 :(得分:0)
重读man page for nsswitch.conf
,给了我这个:
return
这里的关键词是这一部分:配置文件不包含initgroups行,下一个查找函数总是被称为。
如果我添加了行
initgroups: files
我现在可以登录ubuntu
用户,即使LDAP服务器已关闭!