#author("2018-08-21T21:11:13+09:00","","") [[CentOS7]] *OpenLDAPサーバーのインストール [#zbf32b3a] 各サーバー間でユーザーのアカウント情報を共有できるように LDAP サーバーを構築。 **OpenLDAP をインストールします。 [#be2e6da4] |BGCOLOR(black):COLOR(white):|c |[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| **OpenLDAP の管理者パスワードを設定します。 [#jebb5812] |BGCOLOR(black):COLOR(white):|c |[root@localhost ~]# slappasswd &color(lightpink){←管理者パスワード生成};| |New password: &br; Re-enter new password: &br; {SSHA}xxxxxxxxxxxxxxxxxxxxxxxx| |[root@localhost ~]# vi chrootpw.ldif| |&color(lightpink){# olcRootPW に生成した管理者パスワードを指定する}; &br; dn: olcDatabase={0}config,cn=config &br; changetype: modify &br; add: olcRootPW &br; olcRootPW: {SSHA}xxxxxxxxxxxxxxxxxxxxxxxx| |[root@localhost ~]# ldapadd -Y EXTERNAL -H ldapi:/// -f chrootpw.ldif| |SASL/EXTERNAL authentication started &br; SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth &br; SASL SSF: 0 &br; modifying entry "olcDatabase={0}config,cn=config"| **基本的なスキーマを読み込んでおきます。 [#sc1a538a] |BGCOLOR(black):COLOR(white):|c |ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/cosine.ldif| |SASL/EXTERNAL authentication started &br; SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth &br; SASL SSF: 0 &br; 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 &br; SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth &br; SASL SSF: 0 &br; 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 &br; SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth &br; SASL SSF: 0 &br; adding new entry "cn=inetorgperson,cn=schema,cn=config"| **自身のドメイン名を設定します。 [#j20bd3d6] |BGCOLOR(black):COLOR(white):|c |&color(lightpink){# ディレクトリマネージャーのパスワード生成};| |[root@localhost ~]# slappasswd| |New password: &br; Re-enter new password: &br; {SSHA}xxxxxxxxxxxxxxxxxxxxxxxx| |[root@localhost ~]# vi chdomain.ldif| |&color(lightpink){# dc=***,dc=*** は自身のドメイン名に置き換え &br; # (以下はドメイン名「srv.world」の場合の例) &br; # olcRootPW に生成したディレクトリマネージャーのパスワードを指定する};| |dn: olcDatabase={1}monitor,cn=config &br; changetype: modify &br; replace: olcAccess &br; olcAccess: {0}to * by dn.base="gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth" &br; read by dn.base="cn=Manager,dc=srv,dc=world" read by * none &br; &br; dn: olcDatabase={2}hdb,cn=config &br; changetype: modify &br; replace: olcSuffix &br; olcSuffix: dc=srv,dc=world &br; &br; dn: olcDatabase={2}hdb,cn=config &br; changetype: modify &br; replace: olcRootDN &br; olcRootDN: cn=Manager,dc=srv,dc=world &br; &br; dn: olcDatabase={2}hdb,cn=config &br; changetype: modify &br; add: olcRootPW &br; olcRootPW: {SSHA}xxxxxxxxxxxxxxxxxxxxxxxx &br; &br; dn: olcDatabase={2}hdb,cn=config &br; changetype: modify &br; add: olcAccess &br; olcAccess: {0}to attrs=userPassword,shadowLastChange by &br; dn="cn=Manager,dc=srv,dc=world" write by anonymous auth by self write by * none &br; olcAccess: {1}to dn.base="" by * read &br; 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 &br; SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth &br; SASL SSF: 0 &br; modifying entry "olcDatabase={1}monitor,cn=config" &br; &br; modifying entry "olcDatabase={2}hdb,cn=config" &br; &br; modifying entry "olcDatabase={2}hdb,cn=config" &br; &br; modifying entry "olcDatabase={2}hdb,cn=config"| |[root@localhost ~]# vi basedomain.ldif| |&color(lightpink){# dc=***,dc=*** は自身のドメイン名に置き換え &br; # (以下はドメイン名「srv.world」の場合の例) &br; # 「dc: Srv」の箇所は自身のドメイン名の先頭部分に置き換え}; &br; dn: dc=srv,dc=world &br; objectClass: top &br; objectClass: dcObject &br; objectclass: organization &br; o: Server World &br; dc: Srv &br; &br; dn: cn=Manager,dc=srv,dc=world &br; objectClass: organizationalRole &br; cn: Manager &br; description: Directory Manager &br; &br; dn: ou=People,dc=srv,dc=world &br; objectClass: organizationalUnit &br; ou: People &br; &br; dn: ou=Group,dc=srv,dc=world &br; objectClass: organizationalUnit &br; ou: Group| |[root@localhost ~]# ldapadd -x -D cn=Manager,dc=srv,dc=world -W -f basedomain.ldif | |Enter LDAP Password: &color(lightpink){# ディレクトリマネージャーのパスワード}; &br; adding new entry "dc=srv,dc=world" &br; &br; adding new entry "cn=Manager,dc=srv,dc=world" &br; &br; adding new entry "ou=People,dc=srv,dc=world" &br; &br; adding new entry "ou=Group,dc=srv,dc=world"| **Firewalld を有効にしている場合は、LDAPサービスの許可が必要です。なお、LDAP は 389/TCP を使用します。 [#ua1b4a43] |BGCOLOR(black):COLOR(white):|c |[root@localhost ~]# firewall-cmd --add-service=ldap --permanent| |success| |[root@localhost ~]# firewall-cmd --reload| |success|