CentOS/RHEL 7 无密码 SSH登录 不适用于 LDAP 服务器上的本地用户
www. On IT Road .com

根本原因

发生此问题是因为在使用 LDAP 作为其主要身份验证方法的系统上没有为本地用户设置权限。
在安全日志文件中将看到以下错误:

Jan 31 04:05:43 hcusalpbidmbi1s sshd[25861]: pam_access(sshd:account): access denied for user `infbiftp' from `dm-bii-dev-01.am.health.ge.com'
Jan 31 04:05:43 hcusalpbidmbi1s sshd[25861]: pam_sss(sshd:account): Access denied for user infbiftp: 10 (User not known to the underlying authentication module) >>>>
Jan 31 04:05:43 hcusalpbidmbi1s sshd[25861]: fatal: Access denied for user infbiftp by PAM account configuration [preauth] >>>>

解决方案

  1. 编辑 /etc/sshd/sshd_conf 并添加以下行:
# vi /etc/sshd/sshd_conf
AllowUsers username

替换为正确的用户名,然后保存文件。

  1. 编辑 /etc/pam.d/sshd 文件并添加以下行:
# vi /etc/pam.d/sshd
account sufficient pam_localuser.so

保存文件。

  1. 重启sshd服务和sssd服务。
# systemctl sshd restart
# systemctl sssd restart

问题

在 CentOS/RHEL 7 服务器上,本地用户的无密码 SSH 不起作用。
该服务器使用 LDAP,所有 LDAP 用户访问都正常工作。
如果我们在 /etc/security/access.conf 中添加本地用户,则连接没有问题。
但是,根据客户的内部安全策略,在 /etc/security/access.conf 文件中添加用户名可能不是可接受的解决方法。

日期:2020-09-17 00:14:08 来源:oir作者:oir