各サーバー間でユーザーのアカウント情報を共有できるように LDAP サーバーを構築。
[root@localhost ~]# yum -y install openldap-servers openldap-clients |
[root@localhost ~]# cp /usr/share/openldap-servers/DB_CONFIG.example /var/lib/ldap/DB_CONFIG |
[root@localhost ~]# chown ldap. /var/lib/ldap/DB_CONFIG |
[root@localhost ~]# systemctl start slapd |
[root@localhost ~]# systemctl enable slapd |
[root@localhost ~]# slappasswd ←管理者パスワード生成 |
New password: Re-enter new password: {SSHA}xxxxxxxxxxxxxxxxxxxxxxxx |
[root@localhost ~]# vi chrootpw.ldif |
# olcRootPW に生成した管理者パスワードを指定する dn: olcDatabase={0}config,cn=config changetype: modify add: olcRootPW olcRootPW: {SSHA}xxxxxxxxxxxxxxxxxxxxxxxx |
[root@localhost ~]# ldapadd -Y EXTERNAL -H ldapi:/// -f chrootpw.ldif |
SASL/EXTERNAL authentication started SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth SASL SSF: 0 modifying entry "olcDatabase={0}config,cn=config" |
ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/cosine.ldif |
SASL/EXTERNAL authentication started SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth SASL SSF: 0 adding new entry "cn=cosine,cn=schema,cn=config" |
[root@localhost ~]# ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/nis.ldif |
SASL/EXTERNAL authentication started SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth SASL SSF: 0 adding new entry "cn=nis,cn=schema,cn=config" |
[root@localhost ~]# ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/inetorgperson.ldif |
SASL/EXTERNAL authentication started SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth SASL SSF: 0 adding new entry "cn=inetorgperson,cn=schema,cn=config" |
# ディレクトリマネージャーのパスワード生成 |
[root@localhost ~]# slappasswd |
New password: Re-enter new password: {SSHA}xxxxxxxxxxxxxxxxxxxxxxxx |
[root@localhost ~]# vi chdomain.ldif |
# dc=***,dc=*** は自身のドメイン名に置き換え # (以下はドメイン名「srv.world」の場合の例) # olcRootPW に生成したディレクトリマネージャーのパスワードを指定する |
dn: olcDatabase={1}monitor,cn=config changetype: modify replace: olcAccess olcAccess: {0}to * by dn.base="gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth" read by dn.base="cn=Manager,dc=srv,dc=world" read by * none dn: olcDatabase={2}hdb,cn=config changetype: modify replace: olcSuffix olcSuffix: dc=srv,dc=world dn: olcDatabase={2}hdb,cn=config changetype: modify replace: olcRootDN olcRootDN: cn=Manager,dc=srv,dc=world dn: olcDatabase={2}hdb,cn=config changetype: modify add: olcRootPW olcRootPW: {SSHA}xxxxxxxxxxxxxxxxxxxxxxxx dn: olcDatabase={2}hdb,cn=config changetype: modify add: olcAccess olcAccess: {0}to attrs=userPassword,shadowLastChange by dn="cn=Manager,dc=srv,dc=world" write by anonymous auth by self write by * none olcAccess: {1}to dn.base="" by * read olcAccess: {2}to * by dn="cn=Manager,dc=srv,dc=world" write by * read |
[root@localhost ~]# ldapmodify -Y EXTERNAL -H ldapi:/// -f chdomain.ldif |
SASL/EXTERNAL authentication started SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth SASL SSF: 0 modifying entry "olcDatabase={1}monitor,cn=config" modifying entry "olcDatabase={2}hdb,cn=config" modifying entry "olcDatabase={2}hdb,cn=config" modifying entry "olcDatabase={2}hdb,cn=config" |
[root@localhost ~]# vi basedomain.ldif |
# dc=***,dc=*** は自身のドメイン名に置き換え # (以下はドメイン名「srv.world」の場合の例) # 「dc: Srv」の箇所は自身のドメイン名の先頭部分に置き換え dn: dc=srv,dc=world objectClass: top objectClass: dcObject objectclass: organization o: Server World dc: Srv dn: cn=Manager,dc=srv,dc=world objectClass: organizationalRole cn: Manager description: Directory Manager dn: ou=People,dc=srv,dc=world objectClass: organizationalUnit ou: People dn: ou=Group,dc=srv,dc=world objectClass: organizationalUnit ou: Group |
[root@localhost ~]# ldapadd -x -D cn=Manager,dc=srv,dc=world -W -f basedomain.ldif |
Enter LDAP Password: # ディレクトリマネージャーのパスワード adding new entry "dc=srv,dc=world" adding new entry "cn=Manager,dc=srv,dc=world" adding new entry "ou=People,dc=srv,dc=world" adding new entry "ou=Group,dc=srv,dc=world" |
[root@localhost ~]# firewall-cmd --add-service=ldap --permanent |
success |
[root@localhost ~]# firewall-cmd --reload |
success |