yum install -y openldap openldap-servers openldap-clients pam_ldap nss-pam-ldapd vsftpd
slappasswd #记录备用 {SSHA}70WfjeJVZhmGy0wfSUKcOGsKPgLR7/ae
cp /usr/share/openldap-servers/slapd.conf.obsolete /etc/openldap/slapd.conf
vi /etc/openldap/slapd.conf
修改suffix "dc=dsideal,dc=com"rootdn "cn=admin,dc=dsideal,dc=com"rootpw {SSHA}O8cf4DWh2Lg4hbGDya6d2bj0apPWJLoA#测试配置文件
slaptest -u -f /etc/openldap/slapd.conf提示:config file testing succeededrm -rf /etc/openldap/slapd.d/
cp /usr/share/openldap-servers/DB_CONFIG.example /var/lib/ldap/DB_CONFIGchown ldap.ldap /var/lib/ldap/DB_CONFIG#启动
/etc/init.d/slapd startauthconfig-tui
vi /etc/openldap/ldap.conf
#增加URI ldap://127.0.0.1BASE dc=dsideal,dc=commkdir /usr/local/ldapuser
vi /usr/local/base.ldif
dn:dc=dsideal,dc=com
dc:dsidealobjectClass:topobjectClass:domaindn:ou=ftpPeople,dc=dsideal,dc=com
ou:ftpPeopleobjectClass:topobjectClass:organizationalUnitdn:ou=ftpGroup,dc=dsideal,dc=com
ou:ftpGroupobjectClass:topobjectClass:organizationalUnit#执行
ldapadd -x -D "cn=admin,dc=dsideal,dc=com" -w dsideal -f /usr/local/base.ldifvi /usr/local/ftpgroup.ldif
dn:cn=ldapftp,ou=ftpGroup,dc=dsideal,dc=com
objectClass:posixGroupobjectClass:topcn:ldapftpgidNumber:1500#执行
ldapadd -x -D "cn=admin,dc=dsideal,dc=com" -w dsideal -f /usr/local/ftpgroup.ldifvi /usr/local/ftpuser.ldif
dn:uid=ftpuser1,ou=ftpPeople,dc=dsideal,dc=com
uid:ftpuser1cn:ftpuser1objectClass:accountobjectClass:posixAccountobjectClass:topobjectClass:shadowAccountuserPassword:123456shadowLastChange:13048shadowMax:99999shadowWarning:7loginShell:/sbin/nologinuidNumber:1500gidNumber:1500homeDirectory:/usr/local/ldapusergecos:ldapuser#执行
ldapadd -x -D "cn=admin,dc=dsideal,dc=com" -w dsideal -f /usr/local/ftpuser.ldif #执行ldapsearch -x -D "cn=admin,dc=dsideal,dc=com" -w dsidealldapsearch -x -D "cn=admin,dc=dsideal,dc=com" -w dsideal -b "uid=ftpuser1,ou=ftpPeople,dc=dsideal,dc=com"#检查LDAP用户
getent passwd ftpuser1
vi /etc/pam.d/vsftpd
增加2行#把这行放在第一个auth项
auth sufficient pam_ldap.so#把这行放在第一个account项account sufficient pam_ldap.so vi /etc/vsftpd/vsftpd.conf#修改如下配置
anonymous_enable=NO #不允许匿名用户访问anon_upload_enable=YES anon_mkdir_write_enable=YES #开启这项和上一项才能上传文件和文件夹chroot_local_user=YES#增加下面一行local_root=/usr/local/ldapuser/etc/init.d/vsftpd restart