环境
系统:CentOS 6.8
ldap server端
- 安装migrationtools工具
yum install migrationtools -y
- 添加uid>10000用户
#!/bin/bash
for i in name1、name2·········nameN
do
for j in `seq -w 10000 10050`
do
useradd -d /home/$i $i -u $j
done
done
- 修改migrate_common.ph文件
# Default DNS domain
$DEFAULT_MAIL_DOMAIN = "zijian.com";
# Default base
$DEFAULT_BASE = "dc=zijian,dc=com";
- 将用户和用户组转换成LDIF文件
# tail -n 51 /etc/passwd > system
# /usr/share/migrationtools/migrate_passwd.pl system people.ldif
# tail -n 10 /etc/group > group
# /usr/share/migrationtools/migrate_group.pl group group.ldif
-
注:生成ldif文件在导入openldap时会出现属性确实或冲突,报错很明显,根据报错进行相应调整;
-
导入openldap
# ldapadd -x -W -D "cn=manager,dc=zijian,dc=com" -f people.ldif
Enter LDAP Password: 输入管理员密码
ldap client端
- 安装软件包
yum install openldap-clients nss-pam-ldapd -y
- 修改nslcd.conf配置文件
# vim /etc/nslcd.conf
uri ldap://192.168.2.2/
base dc=zijian,dc=com
ssl no
tls_cacertdir /etc/openldap/certs
- 修改pam_ldap.conf配置文件
# vim /etc/pam_ldap.conf
uri ldap://192.168.2.2/
ssl no
tls_cacertdir /etc/openldap/certs
bind_policy soft
- 修改system-auth认证文件
# vim /etc/pam.d/system-auth
auth sufficient pam_ldap.so use_first_pass
account [default=bad success=ok user_unknown=ignore] pam_ldap.so
password sufficient pam_ldap.so use_authtok
session optional pam_ldap.so
session optional pam_mkhomedir.so skel=/etc/skel/ umask=0077
- 修改nsswitch.conf配置文件
# vim /etc/nsswitch.conf
passwd: files ldap
shadow: files ldap
group: files ldap
- 修改authconfig认证文件
# vim /etc/sysconfig/authconfig
USELDAP=yes
USELDAPAUTH=yes
USELOCAUTHORIZE=yes
USESHADOW=yes
- 启动nslcd
# /etc/init.d/nslcd restart
# chkconfig nslcd on
网友评论