設定
/var/logにログを吐くようにする。
-は削除行、+は追加行です。
vi /etc/syslog.conf -*.info;mail.none;authpriv.none;cron.none /var/log/messages +*.info;mail.none;authpriv.none;cron.none;local4.none /var/log/messages +local4.* -/var/log/slapd.log
vi /etc/logrotate.d/syslog syslog -/var/log/messages /var/log/secure /var/log/maillog /var/log/spooler /var/log/boot.log /var/log/cron { +/var/log/messages /var/log/secure /var/log/maillog /var/log/spooler /var/log/boot.log /var/log/cron /var/log/slapd.log{
syslogの再起動
service syslog restart
slapd.conf
mv /etc/openldap/slapd.conf /etc/openldap/slapd.conf.orig chgrp ldap /etc/openldap/slapd.conf chmod g+r /etc/openldap/slapd.conf vi /etc/openldap/slapd.conf (設定は後ほど) chkconfig ldap on service ldap start
以下のようにログが吐けてればよい。
CENTOS /etc/openldap# tail /var/log/slapd.log Nov 10 12:31:06 centos slapd[3763]: slapd starting
vi /etc/openldap/ldap.conf URI ldap://127.0.0.1/ BASE dc=my-company,dc=com
以下は第1回 まずは使ってみよう:そろそろLDAPにしてみないか?|gihyo.jp … 技術評論社の設定パラメータをそのまま利用しています。
vi /etc/openldap/slapd.conf include /etc/openldap/schema/core.schema include /etc/openldap/schema/cosine.schema include /etc/openldap/schema/inetorgperson.schema include /etc/openldap/schema/nis.schema pidfile /var/run/openldap/slapd.pid argsfile /var/run/openldap/slapd.args database bdb suffix "dc=example,dc=com" rootdn "cn=Manager,dc=example,dc=com" rootpw secret directory /var/lib/ldap
/etc/init.d/ldap restart もしくは service ldap restart
passwd.ldifの作成
cd ~/ vi passwd.ldif dn: dc=example,dc=com objectClass: dcObject objectClass: organization dc: example o: example dn: ou=People,dc=example,dc=com objectClass: organizationalUnit ou: People dn: uid=ldapuser,ou=People,dc=example,dc=com objectClass: account objectClass: posixAccount uid: ldapuser cn: ldapuser userPassword: ldapuser loginShell: /bin/bash uidNumber: 1000 gidNumber: 1000 homeDirectory: /home/ldapuser
passwd.ldifを追加
ldapadd -x -D "cn=Manager,dc=example,dc=com" -w secret -f passwd.ldif
以下のように出れば良い。以前はここでldap_bind: Invalid credentials (49) というエラーが出た。
ENTOS /root# ldapadd -x -D "cn=Manager,dc=example,dc=com" -w secret -f passwd.ldif adding new entry "dc=example,dc=com" adding new entry "ou=People,dc=example,dc=com" adding new entry "uid=ldapuser,ou=People,dc=example,dc=com"
LDAP認証の有効化
後はLDAP認証と使えるように設定する.
authconfigについては以下のURLを参考にした。
05_authconfigコマンドによるOSの認証設定 - あっくんの作業ログ
authconfig-tui
項目をTabで移動して「LDAP認証を使用する」と「LDAPを使用」にチェック入れる。
lqqqqqqqqqqqqqqqqqqqu 認証の設定 tqqqqqqqqqqqqqqqqqqqqk x x x ユーザー情報 認証 x x [ ] キャッシュ情報 [*] MD5 パスワードを使用 x x [ ] Hesiod を使用 [*] シャドウパスワードを使用 x x [*] LDAP を使用 [*] LDAP 認証を使用 x x [ ] NIS を使用 [ ] Kerberos 5 を使用 x x [ ] Winbind を使用 [ ] SMB 認証を使用 x x [ ] Winbind 認証を使用 x x [ ] ローカル認証は十分です x x x x lqqqqqqqqqqk lqqqqk x x x 取り消し x x 次 x x x mqqqqqqqqqqj mqqqqj x x x x x mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj
LDAPを使用するにチェック入れると以下の画面になる。
特にいぢる必要無いのでそのまま「OK」を選択。
lqqqqqqqqqqqqqqqqqqqqu LDAP 設定 tqqqqqqqqqqqqqqqqqqqqk x x x [ ] TLS を使用 x x サーバー: ldap://127.0.0.1/_______________________ x x ベース DN: dc=example,dc=com__________________________ x x x x lqqqqqqk lqqqqk x x x 戻る x x OK x x x mqqqqqqj mqqqqj x x x x x mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj
一応設定確認しておく
LANG=en_US.UTF-8 authconfig --test (略) pam_ldap is enabled LDAP+TLS is disabled LDAP server = "ldap://127.0.0.1/" LDAP base DN = "dc=example,dc=com" (略)
とかなっていればOk