|
1: 2011-01-07 (金) 00:45:40 maruo |
| + | *インストール [#fd07a6cc] |
| + | # emerge openldap |
| + | にて、インストール完了します。USEフラグにldapを追加して |
| + | # emerge --newuse world |
| + | でも良いかもです。 |
| | | |
| + | *設定 [#vad6c564] |
| + | [[Gentoo Wiki Archives - OpenLDAP>http://www.gentoo-wiki.info/OpenLDAP]]を見ながらやったので、ほとんどココで間に合いますが、日本語訳版があると自分にも便利なので、書き下してみます。 |
| + | **SSLの設定 [#z242a42c] |
| + | SSLのトランスポートレイヤ用に、サーバ証明書と秘密鍵を作成いたします。 |
| + | # openssl req -config /etc/ssl/openssl.cnf -new -x509 -nodes \ |
| + | -out /etc/openldap/ssl/ldap.pem -keyout /etc/openldap/ssl/ldap-key.pem -days 999999 |
| + | この際、CommonNameは、サーバのFQDNにしておかないと弾かれますので、注意してくださいね!! |
| + | **slapd.conf設定 [#b79af1fa] |
| + | まずメンテナーさんのアカウント/パスワードを決めておきます。メンテナーさんアカウントManager/パスワードsecretとします。んで、以下のコマンドで暗号化しておきます。 |
| + | # slappasswd |
| + | New password: secret |
| + | Re-enter new password: secret |
| + | {SSHA}LbcQRqSCgamVLsRD9PJvJvIeGmhTnlKX |
| + | この文字列を後で使用します。 |
| + | |
| + | 続いて、/etc/openldap/slapd.confがLDAPサーバの設定ファイルです。こんな感じで設定します。 |
| + | # Include the needed data schemes below core.schema |
| + | include /etc/openldap/schema/core.schema |
| + | include /etc/openldap/schema/cosine.schema |
| + | include /etc/openldap/schema/inetorgperson.schema |
| + | include /etc/openldap/schema/nis.schema |
| + | |
| + | Uncomment modulepath and hdb module |
| + | # Load dynamic backend modules: |
| + | modulepath /usr/lib/openldap/openldap |
| + | # moduleload back_shell.so |
| + | # moduleload back_relay.so |
| + | # moduleload back_perl.so |
| + | # moduleload back_passwd.so |
| + | # moduleload back_null.so |
| + | # moduleload back_monitor.so |
| + | # moduleload back_meta.so |
| + | # moduleload back_dnssrv.so |
| + | |
| + | # Uncomment sample access restrictions (Note: maintain indentation!) |
| + | access to * |
| + | by self write |
| + | by users read |
| + | by anonymous auth |
| + | |
| + | # BDB Database definition |
| + | |
| + | database hdb |
| + | suffix "dc=example,dc=com" |
| + | checkpoint 32 30 # <kbyte> <min> |
| + | rootdn "cn=Manager,dc=example,dc=com" |
| + | rootpw {SSHA}LbcQRqSCgamVLsRD9PJvJvIeGmhTnlKX |
| + | directory /var/lib/openldap-data |
| + | index objectClass eq |
| + | |
| + | TLSCertificateFile /etc/openldap/ssl/ldap.pem |
| + | TLSCertificateKeyFile /etc/openldap/ssl/ldap.key |
| + | |
| + | 以下の要領です。 |
| + | :include|このサーバで使用するスキーマを指定いたします。 |
| + | :moduleload|サーバで使用する機能のエクステンションモジュールを指定します。 |
| + | :access to|データにアクセスする際の権限。アクセスリストを指定します。これは、[[LDAPアクセスリスト設定>Gentoo Linuxな生活/LDAPアクセスリスト設定]]で詳しく記載します。 |
| + | :database|LDAPで使用するDBバックエンドです。hdbはBerklayDBを指定しています。 |
| + | :suffix|ツリーの起点となるドメイン名を指定します。example.comはdc=example,dc=comと文節ごとに分けて記載します。LDAPの記載ルールです。 |
| + | :rootdn|メンテナーさんのアカウントDNを指定します。 |
| + | :rootpw|先ほどslappasswdで作成したパスワード文字列を指定します。 |
| + | :index|データベース検索を高速化するために作成するインデックスの種別を指定します。ここだと、objectClassのインデックスを指定しています。 |
| + | :TLSXXX|SSLトランスポート用のサーバ証明書/秘密鍵を指定します。 |
| + | **ldap.conf [#u5c010f4] |
| + | 続いて、/etc/openldap/ldap.confを設定します。LDAPクライアントツール用の設定です。 |
| + | # |
| + | # LDAP Defaults |
| + | # |
| + | |
| + | # See ldap.conf(5) for details |
| + | # This file should be world readable but not world writable. |
| + | |
| + | BASE dc=example,dc=com |
| + | URI ldap://foo.example.com |
| + | |
| + | TLS_CACERT /etc/openldap/ssl/ldap.pem |
| + | TLS_REQCERT allow |
| + | :BASE|検索起点(BaseDN)を省略したときのデフォルトDNです |
| + | :URI|省略した際にアクセスしにいくデフォルトサーバとポートを指定します。ldap://はポート389、ldaps://だと636(SSL)になります。 |
| + | :TLS_CACERT|クライアント証明書を指定します |
| + | :TLS_REQCERT|証明書認証の結果どうするか。allowは失敗してもセッションを継続させることを選択します。 |
| + | |
| + | **/etc/conf.d/slapd [#lb2b3338] |
| + | 以下の行のコメントを外してやってください。 |
| + | OPTS="-h 'ldaps:// ldap:// ldapi://%2fvar%2frun%2fopenldap%2fslapd.sock'" |
| + | ldaps://(ポート636)、ldap://(ポート389),ldapi://(UNIXドメインソケット)を開いて待ち受ける設定です。 |
| + | |
| + | **起動 [#gf732d5f] |
| + | ここまで設定できたら、slapdを起動します。 |
| + | |
| + | # /etc/init.d/slapd start |
| + | |
| + | *サーバにデータをぶち込む [#h993c4ab] |
| + | **既存データのマイグレーション [#o297dda8] |
| + | ここでは、Linuxにすでに設定されている認証用データ(passwd/shadow/group/hosts)のデータをLDAPに登録することを考えます。 |
| + | [[MigrationTools>http://www.padl.com/download/MigrationTools.tgz]]をダウンロードしてきまして、解凍したします。解凍したディレクトリに移り、migrate_common.plを編集いたします。 |
| + | $DEFAULT_BASE = "dc=example,dc=com"; |
| + | $EXTENDED_SCHEMA = 1; |
| + | # Comment these lines out unless you have a mail schema loaded |
| + | #$DEFAULT_MAIL_DOMAIN = "mydomain.org"; |
| + | #$DEFAULT_MAIL_HOST = "mail.mydomain.org"; |
| + | |
| + | それから、以下のコマンドをそれぞれ実行しましょう。 |
| + | export ETC_SHADOW=/etc/shadow |
| + | ./migrate_base.pl > /tmp/base.ldif |
| + | ./migrate_group.pl /etc/group /tmp/group.ldif |
| + | ./migrate_hosts.pl /etc/hosts /tmp/hosts.ldif |
| + | ./migrate_passwd.pl /etc/passwd /tmp/passwd.ldif |
| + | |
| + | そして/tmp配下に吐き出したldifファイルを以下のコマンドでLDAPサーバにインポートします。 |
| + | # ldapadd -D "cn=Manager,dc=example,dc=com" -W -f <template_file> |
| + | きちんとインポートされたかどうかは、以下のコマンドで確認できます。 |
| + | # ldapsearch -D "cn=Manager,dc=example,dc=com" -W |
| + | これでサーバの準備ができました♪ |