このチュートリアルでは、認証目的で Linux サーバー (Centos/RHEL) を Windows Active Directory と統合する方法について説明します。私の場合、Centos/RHEL 6 サーバーを使用しています。以下の手順に従って、samba、winbind、および Kerberos を使用してこれらのサーバーを AD と統合します。
ステップ 1 :samba-winbind および kerberos パッケージをインストールします。
# yum install samba-winbind samba-winbind-clients samba krb5-libs krb5-workstation pam_krb5
ステップ 2 :時刻同期。
AD は、認証中の時間の一致について非常にうるさいです。そのため、Linux サーバーと AD サーバーの時刻は ntp サーバーに同期する必要があります。以下のコマンドを使用して、Linux サーバーの時刻を ntp サーバーと同期させます。
# ntpdate [ntp-server-ip-address/dns-name]
上記の構成を永続的にするには、ファイル「/etc/ntp.conf」を編集し、そこにあるものをドメイン上の 1 つ以上の NTP サーバーに置き換えます。
# vi /etc/ntp.conf server [ntp-server-ip-address/dns-name]
サービスを開始:
# /etc/init.d/ntpd start # chkconfig ntpd on
ステップ 3 :/etc/hosts ファイルを編集します。
# vi /etc/hosts [ip-address] adserver.yourdomain adserver
ステップ 4 :/etc/krb5.conf を編集します。
# vi /etc/krb5.conf [domain_realm] yourdomain = YOURDOMAIN [libdefaults] ticket_lifetime = 24000 default_realm = YOURDOMAIN dns_lookup_realm = true dns_lookup_kdc = false cache_type = 1 forwardable = true proxiable = true default_tgs_enctypes = des3-hmac-sha1 des-cbc-crc permitted_enctypes = des3-hmac-sha1 des-cbc-crc allow_weak_crypto = no [realms] YOURDOMAIN = { kdc = [ip address of AD server:Port] admin_server = [ip address of AD server:Port] default_domain = yourdomain }
[appdefaults] pam = { debug = true ticket_lifetime = 36000 renew_lifetime = 36000 forwardable = true krb4_convert = false } [logging] default = FILE:/var/krb5/kdc.log kdc = FILE:/var/krb5/kdc.log admin_server = FILE:/var/log/kadmind.log
ステップ 5 :では、Kerberos 認証をテストしてください。
# kinit [user-name]
パスワードの入力を求めるプロンプトが表示された場合は、ユーザーの広告パスワードを入力してください。問題がなければ、プロンプトが表示されます。それ以外の場合は、krb5.conf ファイルを再確認してください。
ステップ 6 :Samba と Winbind を構成します。
/etc/samba/smb.conf を編集します .
# vi /etc/samba/smb.conf [global] workgroup = [Workgroup-Name] netbios name = site2 ## replace the site2 with hostname realm =security = ADS template shell = /bin/bash idmap backend = tdb idmap uid = 1-100000000 idmap gid = 1-100000000 winbind use default domain = Yes winbind nested groups = Yes winbind enum users = Yes winbind enum groups = Yes template shell = /bin/bash template homedir = /home/%D/%U winbind separator = / winbind nss info = sfu winbind offline logon = true hosts allow = 127.0.0.1 0.0.0.0/0 obey pam restrictions = yes socket options = TCP_NODELAY max log size = 150 passdb backend = tdbsam printing = cups load printers = yes cups options = raw printcap name = cups disable spoolss = Yes show add printer wizard = No interfaces = eth0 lo bind interfaces only = yes winbind refresh tickets = true log file = /var/log/samba/log.%m max log size = 50 log level = 3 encrypt passwords = yes #map untrusted to domain = yes #auth methods = winbind guest sam map untrusted to domain = Yes [printers] comment = All Printers path = /var/spool/samba browseable = yes public = yes guest ok = yes writable = no printable = yes
ステップ 7 :/etc/nsswitch.conf を構成します 認証を処理するファイル
# vi /etc/nsswitch.conf passwd: compat winbind shadow: winbind group: compat winbind
ステップ 8 :winbind と Samba サービスを再起動してください。
# /etc/init.d/smb restart # /etc/init.d/winbind restart
今すぐドメインに参加してください:
# net ads join -U [User Name]
上記のコマンドで「Join is OK」と報告された場合は、winbind をテストします。
すべての AD ユーザーを一覧表示するコマンド:
# wbinfo -u
ステップ 9 :ここでテストを行い、AD ユーザー資格情報を使用して Linux サーバーにログインしてみてください。
# ssh [username]@[ipaddress or hostname of linux server]