BerkeleyDB安装:
0 1 2 3 4 5 6 7 8 9 |
$ yum install gcc gcc-c++ gcc-objc gcc-objc++ libobjc openssl openssl-devel libtool-ltdl-devel openldap-devel #$ yum install libacl-devel libblkid-devel gnutls-devel readline-devel python-devel autoconf gcc-c++ gcc glibc-devel glibc-headers kernel-headers libgomp libstdc++-devel openssl-devel e2fsprogs-devel keyutils-libs-devel krb5-devel libselinux-devel libsepol-devel libtool-ltdl-devel $ wget http://download.oracle.com/berkeley-db/db-5.1.29.tar.gz $ tar zxf db-5.1.29.tar.gz $ cd db-5.1.29/build_unix/ $ ../dist/configure $ make && make install $ echo "/usr/local/BerkeleyDB.5.1/lib/" >> /etc/ld.so.conf $ ldconfig $ ldconfig -v |
openLDAP安装:
0 1 2 3 4 5 6 7 |
$ wget ftp://ftp.openldap.org/pub/OpenLDAP/openldap-release/openldap-2.4.48.tgz $ tar zxf openldap-2.4.48.tgz $ cd openldap-2.4.48 $ env CPPFLAGS="-I/usr/local/BerkeleyDB.5.1/include" LDFLAGS="-L/usr/local/BerkeleyDB.5.1/lib -D_GNU_SOURCE" ./configure --prefix=/opt/openldap-2.4.48 --enable-overlays=mod --enable-modules --enable-bdb --enable-mdb --with-tls --enable-crypt --enable-accesslog --enable-auditlog --enable-collect --enable-memberof --enable-syncprov $ make depend && make && make install $ for i in `ls -l /usr/local/openldap/bin/ | awk '{print $9}' | grep -v ^$`;do ln -s /usr/local/openldap/bin/$i /usr/local/bin/$i;done $ for i in `ls -l /usr/local/openldap/sbin/ | awk '{print $9}' | grep -v ^$`;do ln -s /usr/local/openldap/sbin/$i /usr/local/sbin/$i;done $ ln -s /usr/local/openldap/include/* /usr/local/include/ |
配置文件:
openldap配置文件:SourceByrd's Weblog-https://note.t4x.org/project/openldap-master-configure/
M1:
0123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 # egrep -v "#|^$" /usr/local/openldap/etc/openldap/slapd.confinclude /usr/local/openldap/etc/openldap/schema/corba.schemainclude /usr/local/openldap/etc/openldap/schema/core.schemainclude /usr/local/openldap/etc/openldap/schema/cosine.schemainclude /usr/local/openldap/etc/openldap/schema/duaconf.schemainclude /usr/local/openldap/etc/openldap/schema/dyngroup.schemainclude /usr/local/openldap/etc/openldap/schema/inetorgperson.schemainclude /usr/local/openldap/etc/openldap/schema/java.schemainclude /usr/local/openldap/etc/openldap/schema/misc.schemainclude /usr/local/openldap/etc/openldap/schema/nis.schemainclude /usr/local/openldap/etc/openldap/schema/openldap.schemainclude /usr/local/openldap/etc/openldap/schema/ppolicy.schemainclude /usr/local/openldap/etc/openldap/schema/collective.schemapidfile /opt/openldap-2.4.48/var/run/slapd.pidargsfile /opt/openldap-2.4.48/var/run/slapd.argsserverID 1modulepath /opt/openldap-2.4.48/libexec/openldapmoduleload ppolicy.laaccess to *by self writeby anonymous authby * readdatabase mdbmaxsize 1073741824suffix "dc=ldap,dc=t4x,dc=org"checkpoint 2048 10rootdn "cn=admin,dc=ldap,dc=t4x,dc=org"directory /opt/openldap-2.4.48/var/openldap-datasyncrepl rid=001provider=ldap://192.168.227.34binddn="cn=admin,dc=ldap,dc=t4x,dc=org"bindmethod=simplecredentials=adminsearchbase="dc=ldap,dc=t4x,dc=org"schemachecking=offtype=refreshAndPersistretry="60 +"TLSCACertificatePath /usr/local/openldap/ssl/TLSCertificateFile "\"OpenLDAP Server\""TLSCACertificateFile /usr/local/openldap/ssl/cacert.pemTLSCertificateFile /usr/local/openldap/ssl/ldapcert.pemTLSCertificateKeyFile /usr/local/openldap/ssl/ldapkey.pemTlsVerifyClient neverindex objectClass eq,presindex ou,cn,mail,surname,givenname eq,pres,subindex uidNumber,gidNumber,loginShell eq,presindex uid,memberUid eq,pres,subindex nisMapName,nisMapEntry eq,pres,subloglevel 296rootpw {SSHA}iMgn+YhiZm1O9QB6BBZuOS+ko/Gb/262mirrormode TRUEoverlay syncprovsyncprov-nopresent TRUEsyncprov-reloadhint TRUEsyncprov-checkpoint 100 2overlay ppolicypassword-hash {SSHA}ppolicy_default cn=security,ou=Policies,dc=ldap,dc=t4x,dc=orgppolicy_hash_cleartextppolicy_use_lockout
M2:
SourceByrd's Weblog-https://note.t4x.org/project/openldap-master-configure/
0123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 # egrep -v "#|^$" /usr/local/openldap/etc/openldap/slapd.confinclude /usr/local/openldap/etc/openldap/schema/corba.schemainclude /usr/local/openldap/etc/openldap/schema/core.schemainclude /usr/local/openldap/etc/openldap/schema/cosine.schemainclude /usr/local/openldap/etc/openldap/schema/duaconf.schemainclude /usr/local/openldap/etc/openldap/schema/dyngroup.schemainclude /usr/local/openldap/etc/openldap/schema/inetorgperson.schemainclude /usr/local/openldap/etc/openldap/schema/java.schemainclude /usr/local/openldap/etc/openldap/schema/misc.schemainclude /usr/local/openldap/etc/openldap/schema/nis.schemainclude /usr/local/openldap/etc/openldap/schema/openldap.schemainclude /usr/local/openldap/etc/openldap/schema/ppolicy.schemainclude /usr/local/openldap/etc/openldap/schema/collective.schemapidfile /opt/openldap-2.4.48/var/run/slapd.pidargsfile /opt/openldap-2.4.48/var/run/slapd.argsserverID 2modulepath /opt/openldap-2.4.48/libexec/openldapmoduleload ppolicy.laaccess to *by self writeby anonymous authby * readdatabase mdbmaxsize 1073741824suffix "dc=ldap,dc=t4x,dc=org"checkpoint 2048 10rootdn "cn=admin,dc=ldap,dc=t4x,dc=org"directory /opt/openldap-2.4.48/var/openldap-datasyncrepl rid=001provider=ldap://192.168.227.33binddn="cn=admin,dc=ldap,dc=t4x,dc=org"bindmethod=simplecredentials=adminsearchbase="dc=ldap,dc=t4x,dc=org"schemachecking=offtype=refreshAndPersistretry="60 +"TLSCACertificatePath /usr/local/openldap/ssl/TLSCertificateFile "\"OpenLDAP Server\""TLSCACertificateFile /usr/local/openldap/ssl/cacert.pemTLSCertificateFile /usr/local/openldap/ssl/ldapcert.pemTLSCertificateKeyFile /usr/local/openldap/ssl/ldapkey.pemTlsVerifyClient neverindex objectClass eq,presindex ou,cn,mail,surname,givenname eq,pres,subindex uidNumber,gidNumber,loginShell eq,presindex uid,memberUid eq,pres,subindex nisMapName,nisMapEntry eq,pres,subloglevel 296mirrormode TRUEoverlay syncprovsyncprov-nopresent TRUEsyncprov-reloadhint TRUEsyncprov-checkpoint 100 2rootpw {SSHA}KYesbO2q8mGAfXfTSjGgaOEI+j5bdfRaoverlay ppolicypassword-hash {SSHA}ppolicy_default cn=security,ou=Policies,dc=ldap,dc=t4x,dc=orgppolicy_hash_cleartextppolicy_use_lockoutadmin导入:
012345678910 $ ldapadd -x -D "cn=admin,dc=ldap,dc=t4x,dc=org" -W -f admin.ldif$ cat /usr/local/openldap/etc/openldap/admin.ldifdn: dc=ldap,dc=t4x,dc=orgobjectclass: dcObjectobjectclass: organizationo: T4X.Incdc: ldapdn: cn=admin,dc=ldap,dc=t4x,dc=orgobjectclass: organizationalRolecn: admin
OU people导入:
01234 $ ldapadd -x -D "cn=Manage,dc=ldap,dc=t4x,dc=org" -W -f people.ldif$ cat /usr/local/openldap/etc/openldap/people.lidfdn: ou=People,dc=ldap,dc=t4x,dc=orgobjectClass: organizationalUnitou: People
普通用户导入:
SourceByrd's Weblog-https://note.t4x.org/project/openldap-master-configure/
01234567891011 # cat /usr/local/openldap/etc/openldap/byrd.lidfdn: uid=zane,ou=People,dc=ldap,dc=t4x,dc=orgobjectClass: posixAccountobjectClass: inetOrgPersonobjectClass: organizationalPersonobjectClass: personhomeDirectory: /home/byrdloginShell: /bin/byrdcn: byrdsn: byrddescription: CTOuserPassword:: e1NTSEF9RnNaUHFGQVJmUTRlZEtNS2FKQUxGKy9KaUZqT2dvSW0=
安装pqchecker:
0 1 2 3 4 |
$ git clone https://bitbucket.org/ameddeb/pqchecker.git $ cd pqchecker/ $ sh ./adjustdate.bash $ ./configure LDAPSRC=/byrd/tools/openldap-2.4.48 JAVAHOME=/opt/jdk1.8.0_191 libdir=/usr/local/openldap/libexec/openldap/ PARAMDIR=/etc/openldap/pqchecker $ make && make install |
安全模块导入:SourceByrd's Weblog-https://note.t4x.org/project/openldap-master-configure/
OU polices
0123 $ cat /usr/local/openldap/etc/openldap/policies.lidfdn: ou=Policies,dc=ldap,dc=t4x,dc=orgobjectClass: organizationalUnitou: Policies
默认密码规则:
01234567891011121314151617181920 $ cat /usr/local/openldap/etc/openldap/security1.ldifdn: cn=security,ou=Policies,dc=ldap,dc=t4x,dc=orgcn: securityobjectClass: topobjectClass: deviceobjectClass: pwdPolicyobjectClass: pwdPolicyCheckerpwdAllowUserChange: TRUEpwdAttribute: userPasswordpwdMaxAge: 7776000pwdInHistory: 5pwdCheckQuality: 2pwdMinLength: 8pwdExpireWarning: 604800pwdGraceAuthNLimit: 10pwdFailureCountInterval: 30pwdMustChange: TRUEpwdSafeModify: FALSEpwdLockout: TRUEpwdLockoutDuration: 300pwdMaxFailure: 5
复杂性规则:pqchecker.so
SourceByrd's Weblog-https://note.t4x.org/project/openldap-master-configure/
01234 $ cat /usr/local/openldap/etc/openldap/mode.lidfdn: cn=security,ou=Policies,dc=ldap,dc=t4x,dc=orgchangeType: modifyadd: pwdCheckModulepwdCheckModule: pqchecker.so
常规操作:SourceByrd's Weblog-https://note.t4x.org/project/openldap-master-configure/
导出所有配置文件:
0123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 $ ldapsearch -LLL -w admin -x -H ldap://ldap.t4x.org -D "cn=admin,dc=ldap,dc=t4x,dc=org" -b "dc=ldap,dc=t4x,dc=org" >/tmp/all.ldif$ cat /tmp/all.ldifdn: dc=ldap,dc=t4x,dc=orgobjectClass: dcObjectobjectClass: organizationo: T4X.Incdc: ldapdn: ou=People,dc=ldap,dc=t4x,dc=orgobjectClass: organizationalUnitou: Peopledn: cn=admin,dc=ldap,dc=t4x,dc=orgobjectClass: organizationalRolecn: admincn: admindn: ou=Policies,dc=ldap,dc=t4x,dc=orgobjectClass: organizationalUnitou: Policiesdn: uid=byrd,ou=People,dc=ldap,dc=t4x,dc=orgobjectClass: posixAccountobjectClass: topobjectClass: inetOrgPersongidNumber: 0givenName: byrdsn: byrddisplayName: byrduid: byrdhomeDirectory: /home/byrdloginShell: /bin/bashcn: byrduidNumber: 41872dn: uid=t4x,ou=People,dc=ldap,dc=t4x,dc=orgobjectClass: posixAccountobjectClass: topobjectClass: inetOrgPersongidNumber: 0givenName: t4xsn: t4xdisplayName: t4xuid: t4xhomeDirectory: /home/t4xloginShell: /bin/bashcn: t4xuidNumber: 15557dn: cn=security,ou=Policies,dc=ldap,dc=t4x,dc=orgcn:: c2VjdXJpdHkgobjectClass: topobjectClass: deviceobjectClass: pwdPolicyobjectClass: pwdPolicyCheckerpwdAllowUserChange: TRUEpwdAttribute: userPasswordpwdMaxAge: 7776000pwdInHistory: 5pwdCheckQuality: 2pwdMinLength: 8pwdExpireWarning: 604800pwdGraceAuthNLimit: 10pwdFailureCountInterval: 30pwdMustChange: TRUEpwdSafeModify: FALSEpwdLockout: TRUEpwdLockoutDuration: 300pwdMaxFailure: 5pwdCheckModule: pqchecker.so
导出用户信息:
01234567891011121314 ldapsearch -LLL -w admin -x -H ldap://ldap.t4x.org -D "cn=admin,dc=ldap,dc=t4x,dc=org" -b "dc=ldap,dc=t4x,dc=org" "(uid=*)" > /tmp/user.ldif$ cat /tmp/user.ldifdn: uid=byrd,ou=People,dc=ldap,dc=t4x,dc=orgobjectClass: posixAccountobjectClass: topobjectClass: inetOrgPersongidNumber: 0givenName: byrdsn: byrddisplayName: byrduid: byrdhomeDirectory: /home/byrdloginShell: /bin/bashcn: byrduidNumber: 41872
验证密码策略:
SourceByrd's Weblog-https://note.t4x.org/project/openldap-master-configure/
012345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 $ ldappasswd -H ldap://ldap.t4x.org -x -D "uid=byrd,ou=People,dc=ldap,dc=t4x,dc=org" -W -A -SOld password: 123456Re-enter old password: 123456New password: w34Q$fqwe4Re-enter new password: w34Q$fqwe4Enter LDAP Password: 123456Sep 23 10:24:59 ldap-m1 pqchecker[1089]: Checking password quality for uid=byrd,ou=People,dc=ldap,dc=t4x,dc=org.Sep 23 10:24:59 ldap-m1 pqchecker[1089]: The quality parameters used: 0|01010101Sep 23 10:24:59 ldap-m1 pqchecker[1089]: Password accepted.Sep 23 10:24:59 ldap-m1 slapd[1089]: conn=1010 op=1 RESULT oid= err=0 text=[root@ldap-m1 openldap]# ldappasswd -H ldap://ldap.t4x.org -x -D "uid=byrd,ou=People,dc=ldap,dc=t4x,dc=org" -W -A -SOld password: w34Q$fqwe4Re-enter old password: w34Q$fqwe4New password: qwertyuiRe-enter new password: qwertyuiEnter LDAP Password: w34Q$fqwe4Result: Constraint violation (19)Sep 23 10:26:37 ldap-m1 pqchecker[1089]: Checking password quality for uid=byrd,ou=People,dc=ldap,dc=t4x,dc=org.Sep 23 10:26:37 ldap-m1 pqchecker[1089]: The quality parameters used: 0|01010101Sep 23 10:26:37 ldap-m1 pqchecker[1089]: Password rejected.$ ldappasswd -H ldap://ldap.t4x.org -x -D "uid=byrd,ou=People,dc=ldap,dc=t4x,dc=org" -W -A -SOld password: w34Q$fqwe4Re-enter old password: w34Q$fqwe4New password: w34Q$fqRe-enter new password: w34Q$fqEnter LDAP Password: w34Q$fqwe4Result: Constraint violation (19)Additional info: Password fails quality checking policySep 23 10:26:37 ldap-m1 pqchecker[1089]: Checking password quality for uid=byrd,ou=People,dc=ldap,dc=t4x,dc=org.Sep 23 10:26:37 ldap-m1 pqchecker[1089]: The quality parameters used: 0|01010101Sep 23 10:26:37 ldap-m1 pqchecker[1089]: Password rejected.Sep 23 10:26:37 ldap-m1 slapd[1089]: check_password_quality: module error: (pqchecker.so) The password does not pass quality check..[1]Sep 23 10:26:37 ldap-m1 slapd[1089]: conn=1011 op=1 RESULT oid= err=19 text=# ldappasswd -H ldap://ldap.t4x.org -x -D "uid=byrd,ou=People,dc=ldap,dc=dz,dc=org" -W -A -SOld password: w34Q$fqwe4Re-enter old password: w34Q$fqwe4New password: w34Q$fqwe4Re-enter new password: w34Q$fqwe4Enter LDAP Password: w34Q$fqwe4Result: Constraint violation (19)Additional info: Password is in history of old passwords<pre>$ ldapsearch -x -w admin -D "uid=byrd,ou=People,dc=ldap,dc=t4x,dc=org" -b "uid=byrd,ou=People,dc=ldap,dc=t4x,dc=org"
备注:*.lidf后面均需要空一行、冒号后面空一格、结尾不空格
帮助文档:
1:http://www.meddeb.net/pqchecker
2:http://www.openldap.org/doc/admin24/quickstart.html
3:https://ltb-project.org/documentation/self-service-passwordSourceByrd's Weblog-https://note.t4x.org/project/openldap-master-configure/
SourceByrd's Weblog-https://note.t4x.org/project/openldap-master-configure/
申明:除非注明Byrd's Blog内容均为原创,未经许可禁止转载!详情请阅读版权申明!