OpenLDAPのインストールのチュートリアル

OpenLDAPのインストールのチュートリアル

この記事オリジナル住所:https://sitoi.cn/posts/48217.html

OpenLDAPはcentos7にインストールされています

環境の準備

2台の仮想マシン

node01 IP:192.168.1.143サーバ側

node02でIP:192.168.1.146クライアント側

閉鎖されているとiptablesファイアウォールとSELinux

サービス終了

ステップ:

  1. インストールパッケージ
  2. ファイルコピーDB_CONFIG
  3. ディレクトリのパーミッションを設定します
  4. LDAP管理者パスワードを作成します。
  5. (3)の設定ファイルを変更します。
  6. 起動し、起動のslapdサービスを設定します
  7. 基本的なスキーマのインポート
  8. ファイルのインポートbase.ldif
  9. 設定migrationtools
  10. システムのユーザーとグループのご紹介
  11. サービスの再起動

インストールパッケージ

yum install openldap-servers openldap-clients migrationtools

ファイルコピーDB_CONFIG

cp /usr/share/openldap-servers/DB_CONFIG.example /var/lib/ldap/DB_CONFIG

ディレクトリのパーミッションを設定します

chown -R ldap. /var/lib/ldap/

LDAP管理者パスワードを作成します。

slappasswd

暗号文を保存するために二回入力してください

New password:
Re-enter new password:
{SSHA}AFU2R+sLzJgjUIoW1B5SxcTUdFcuncLz

(3)の設定ファイルを変更します。

vim /etc/openldap/slapd.d/cn\=config/olcDatabase\=\{0\}config.ldif
# AUTO-GENERATED FILE - DO NOT EDIT!! Use ldapmodify.
# CRC32 d30fb98e
dn: olcDatabase={0}config
objectClass: olcDatabaseConfig
olcDatabase: {0}config
olcAccess: {0}to * by dn.base="gidNumber=0+uidNumber=0,cn=peercred,cn=extern
 al,cn=auth" manage by * none
structuralObjectClass: olcDatabaseConfig
entryUUID: 73e7786c-50fa-1038-9bfb-9bfcf0927062
creatorsName: cn=config
createTimestamp: 20180920082518Z
entryCSN: 20180920082518.739228Z#000000#000#000000
modifiersName: cn=config
modifyTimestamp: 20180920082518Z
olcRootPW: {SSHA}37kYCk8iLCmIrGnRvLc7XLAuPqftFUF/        # 添加该行(密码)
vim /etc/openldap/slapd.d/cn\=config/olcDatabase\=\{2\}hdb.ldif
# AUTO-GENERATED FILE - DO NOT EDIT!! Use ldapmodify.
# CRC32 d41d7411
dn: olcDatabase={2}hdb
objectClass: olcDatabaseConfig
objectClass: olcHdbConfig
olcDatabase: {2}hdb
olcDbDirectory: /var/lib/ldap
olcSuffix: dc=sitoi,dc=cn                                       # 更改dc
olcRootDN: cn=Manager,dc=sitoi,dc=cn                            # 更改dc
olcRootPW: {SSHA}37kYCk8iLCmIrGnRvLc7XLAuPqftFUF/               # 添加该行(密码)
olcDbIndex: objectClass eq,pres
olcDbIndex: ou,cn,mail,surname,givenname eq,pres,sub
structuralObjectClass: olcHdbConfig
entryUUID: 73e77fe2-50fa-1038-9bfd-9bfcf0927062
creatorsName: cn=config
createTimestamp: 20180920082518Z
entryCSN: 20180920082518.739419Z#000000#000#000000
modifiersName: cn=config
modifyTimestamp: 20180920082518Z
olcAccess: {0}to attrs=userPassword by self write by dn.base="cn=Manager,dc=sitoi,dc=cn" write by anonymous auth by * none   # 添加该行
olcAccess: {1}to * by dn.base="cn=Manager,dc=sitoi,dc=cn" write by self write by * read                                      # 添加该行
vim /etc/openldap/slapd.d/cn\=config/olcDatabase\=\{1\}monitor.ldif
# AUTO-GENERATED FILE - DO NOT EDIT!! Use ldapmodify.
# CRC32 261d1986
dn: olcDatabase={1}monitor
objectClass: olcDatabaseConfig
olcDatabase: {1}monitor
olcAccess: {0}to * by dn.base="gidNumber=0+uidNumber=0,cn=peercred,cn=extern
 al,cn=auth" read by dn.base="cn=Manager,dc=sitoi,dc=cn" read by * none    # 修改dc信息
structuralObjectClass: olcDatabaseConfig
entryUUID: 73e77bbe-50fa-1038-9bfc-9bfcf0927062
creatorsName: cn=config
createTimestamp: 20180920082518Z
entryCSN: 20180920082518.739313Z#000000#000#000000
modifiersName: cn=config
modifyTimestamp: 20180920082518Z

起動し、起動のslapdサービスを設定します

systemctl enable slapd.service
systemctl start slapd.service

基本的なスキーマのインポート

ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/cosine.ldif
ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/nis.ldif
ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/inetorgperson.ldif

ファイルのインポートbase.ldif

vim base.ldif
dn: dc=sitoi,dc=cn
objectClass: dcObject
objectClass: organization
dc: sitoi
o : sitoi

dn: ou=People,dc=sitoi,dc=cn
objectClass: organizationalUnit
ou: People

dn: ou=Group,dc=sitoi,dc=cn
objectClass: organizationalUnit
ou: Group

インポート

ldapadd -x -D cn=Manager,dc=sitoi,dc=cn -w sitoi  -f base.ldif

設定migrationtools

vim /usr/share/migrationtools/migrate_common.ph

以下の構成を変更

# Default DNS domain
$DEFAULT_MAIL_DOMAIN = "sitoi.cn";

# Default base
$DEFAULT_BASE = "dc=sitoi,dc=cn";

システムのユーザーとグループのご紹介

/ etc / passwdと/ etc / shadow生成LDAPを使用してPLスクリプトは、/ tmpに/下に保存され、ファイル形式を読み取ることができます

/usr/share/migrationtools/migrate_base.pl > /tmp/base.ldif
/usr/share/migrationtools/migrate_passwd.pl /etc/passwd  > /tmp/passwd.ldif
/usr/share/migrationtools/migrate_group.pl /etc/group > /tmp/group.ldif

インポートLDAP

あなたは、管理者パスワードを入力する必要があります

ldapadd -x -D "cn=Manager,dc=sitoi,dc=cn" -w sitoi -f /tmp/base.ldif
ldapadd -x -D "cn=Manager,dc=sitoi,dc=cn" -w sitoi -f /tmp/group.ldif
ldapadd -x -D "cn=Manager,dc=sitoi,dc=cn" -w sitoi -f /tmp/passwd.ldif

サービスの再起動

systemctl restart slapd

クライアント側

ALL

おすすめ

転載: www.cnblogs.com/sitoi/p/11819556.html