温馨提示×

centos怎么配置ldap登陆

小亿
143
2023-08-28 18:11:25
栏目: 编程语言

要在CentOS上配置LDAP登录,需要按照以下步骤进行操作:

  1. 安装LDAP客户端工具:在终端中输入以下命令进行安装
sudo yum install openldap-clients
  1. 配置LDAP客户端:编辑/etc/openldap/ldap.conf文件,将以下内容添加到文件末尾
BASE    dc=example,dc=com
URI     ldap://ldap.example.com

其中,dc=example,dc=com是LDAP服务器的基准DN(Distinguished Name),ldap://ldap.example.com是LDAP服务器的URI。

  1. 配置PAM(Pluggable Authentication Modules):编辑/etc/pam.d/system-auth文件,将以下内容添加到文件末尾
auth    sufficient    pam_ldap.so
account sufficient    pam_ldap.so
password    sufficient    pam_ldap.so
  1. 启用LDAP认证:编辑/etc/nsswitch.conf文件,将以下行修改为
passwd:     files ldap
shadow:     files ldap
group:      files ldap
  1. 重启系统:在终端中输入以下命令重启系统
sudo reboot
  1. 测试LDAP登录:使用LDAP用户的用户名和密码尝试登录系统,如果可以成功登录,则LDAP登录配置完成。

请注意,以上步骤中的exampleldap.example.com是示例值,你需要根据你的LDAP服务器的实际配置进行相应的修改。

0