在 Anolis OS 8 上配置 LDAP 账户登录(使用 nslcd),以下是 完整步骤:
nslcd
sudo dnf install -y openldap-clients nss-pam-ldapd authselect
/etc/nslcd.conf
sudo vim /etc/nslcd.conf
填入以下内容(根据你的 LDAP 服务器调整):
# LDAP 服务器地址 uri ldap://your_ldap_server
# 基础 DN(根据你的 LDAP 结构修改) base dc=example,dc=com
# 如果 LDAP 服务器需要绑定账户查询 binddn cn=admin,dc=example,dc=com bindpw your_admin_password
# 禁用 TLS(如果不使用加密) ssl no
tls_cacertdir /etc/openldap/cacerts # 用户和组映射
设置文件权限:
sudo chmod 600 /etc/nslcd.conf
sudo chown nslcd:nslcd /etc/nslcd.conf
/etc/nsswitch.conf
sudo vim /etc/nsswitch.conf
sudo vim /etc/pam.d/system-auth
添加:
auth sufficient pam_ldap.so
account sufficient pam_ldap.so
password sufficient pam_ldap.so
session optional pam_mkhomedir.so umask=0022
sudo systemctl start nslcd
sudo systemctl enable nslcd