ANOLIS8安装配置ldap账号登录

在 ​​Anolis OS 8​​ 上配置 ​​LDAP 账户登录(使用 nslcd)​​,以下是 ​​完整步骤​​:


​​1. 安装必要的软件包​​

 
sudo dnf install -y openldap-clients nss-pam-ldapd authselect
 
 authconfig --enableldap --enableldapauth --ldapserver=ldap://your_ldap_server --ldapbasedn="dc=example,dc=com" --enablemkhomedir --update

​​2. 配置 /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
 
 

​​3. 配置 /etc/nsswitch.conf​​

 
sudo vim /etc/nsswitch.conf
passwd: files ldap
shadow: files ldap
group: files ldap
 

​​配置 PAM​​和SSHD

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
 
/etc/pam.d/sshd文件需添加
auth sufficient pam_ldap.so

​​启动服务​​

 
sudo systemctl start nslcd
sudo systemctl enable nslcd
 
 
posted @ 2025-09-12 10:50  aaahwh  阅读(8)  评论(0)    收藏  举报