前回の記事の続きになります。前回の記事ではDirectory Server構成方法を紹介しました。本記事では、同じSolaris PC上に Zoneを構築し、こちらをLDAPクライントとして、LDAPクライアント側でのログイン認証を、構築したDirectory Serverから実行する手順を紹介します。
構成図に関しては、前回の記事をご参照ください。
LDAPクライアントを構築し、Directory Serverによりログイン認証させる手順は下記です。 (今回はZone上で構成しますので、Zone作成手順も含みます。)
- Zone作成
- ldapclient init コマンド実行
- ldapaddentにより、Directory Serverにログイン認証用のユーザのエントリを追加
- 実際にLDAPクライアント上でのログインが、Directory Server側で認証されるか確認
1.Zone作成
Zoneではなく、Directory Serverと異なるSolarisマシンをLDAPクライアントとして使用する場合は、Zoneを構築する必要はありません。
今回は1台のSolaris PC で構築するために、Zoneを使用しています。
# zonecfg -z zone1
zone1: そのような構成済みゾーンはありません
'create' を使用して、新しいゾーンの構成を開始してください。
zonecfg:zone1> create
zonecfg:zone1>
zonecfg:zone1> set zonepath=/zone/zone1
zonecfg:zone1>
zonecfg:zone1> add net
zonecfg:zone1:net> set physical=iprb0
zonecfg:zone1:net> set address=192.168.10.20
zonecfg:zone1:net> end
zonecfg:zone1>
zonecfg:zone1> set autoboot=true
zonecfg:zone1>
zonecfg:zone1> info
zonename: zone1
zonepath: /zone/zone1
brand: native
autoboot: true
bootargs:
pool:
limitpriv:
scheduling-class:
ip-type: shared
inherit-pkg-dir:
dir: /lib
inherit-pkg-dir:
dir: /platform
inherit-pkg-dir:
dir: /sbin
inherit-pkg-dir:
dir: /usr
net:
address: 192.168.10.20
physical: iprb0
zonecfg:zone1>
zonecfg:zone1>
zonecfg:zone1> verify
zonecfg:zone1>
zonecfg:zone1>
zonecfg:zone1> exit
#
#
#
# zoneadm list -cv
ID NAME STATUS PATH BRAND IP
0 global running / native shared
- zone1 configured /zone/zone1 native shared
#
Zoneインストール
bash-3.00# zoneadm -z zone1 install
Preparing to install zone <zone1>.
Creating list of files to copy from the global zone.
Copying <2646> files to the zone.
Initializing zone product registry.
Determining zone package initialization order.
Preparing to initialize <1165> packages on the zone.
Initialized <1165> packages on zone.
Zone <zone1> is initialized.
Installation of <1> packages was skipped.
The file </zone/zone1/root/var/sadm/system/logs/install_log> contains a log of the zone installation.
インストールされたことを確認します。
| # zoneadm list -cv ID NAME STATUS PATH BRAND IP 0 global running / native shared - zone1 installed /zone/zone1 native shared |
Zone起動 起動を確認します。 # zoneadm -z zone1 boot
# zoneadm list -cv
ID NAME STATUS PATH BRAND IP
0 global running / native shared
1 zone1 running /zone/zone1 native shared
#
Zoneにコンソールでログイン
| # zlogin -C zone1 |
起動すると、最初はコンソール上で、時間や言語の設定等を行う行程がありますので、そちらの設定をします。完了すると、下記のログインプロンプトがあがってきます。
| zone1 console login: root Password: Feb 27 17:52:58 zone1 login: ROOT LOGIN /dev/console Sun Microsystems Inc. SunOS 5.10 Generic January 2005 # |
ログイン出来ました。ホスト名を確認すると、
| # hostname zone1 |
正しくzone1にログインしています。IPを確認します。
| # ifconfig -a lo0:1: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1 inet 127.0.0.1 netmask ff000000 iprb0:1: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2 inet 192.168.10.20 netmask ffffff00 broadcast 192.168.10.255 |
2.LDAPクライアントの設定
前回の記事で構築したDirectory Serverインスタンスのクライアントにする設定を行います。
※下記の設定を Directory Server本体(今回の場合ではglobal zone)上で設定してはいけません。必ず本体と異なるマシン、またはzoneなどの仮想OS環境で実行してください。
| # ldapclient
init -a profileName=default -a domainName=example.com -a
proxyDN=cn=proxyagent,ou=profile,dc=example,dc=com -a
proxyPassword=proxyagent 192.168.10.10 システムは正常に構成されました |
このように、「システムは正常に構成されました」と表示されれば、OKです。表示されない場合は、Directory Server側の設定に問題がある可能性があります。(特にidsconfigコマンド部分)
Directory Serverインスタンスにユーザのエントリを追加
今回は、一度LDAPクライアントZone上で、testuserを追加して、/etc/passwd, /etc/shadow 内にある testuserのエントリをDirectory Serverインスタンスに追加します。
まず、testuserをzone1上で作成します。
| # mkdir /export/home # useradd -d /export/home/testuser -m testuser 64 ブロック |
testuserのパスワードを設定します。
| # passwd testuser 新しいパスワード: 新しいパスワードを再入力してください: passwd: testuser のパスワードが変更されました |
/var/tmp以下にpasswdファイルを作成して、そこへ/etc/passwdファイル内のtestuserの行を/var/tmp/passwdファイルに書き込みます。
| # vi /var/tmp/passwd testuser:x:100:1::/export/home/testuser:/bin/sh |
ldapaddentにより、上記のエントリを追加します。
| # ldapaddent -D "cn=Directory Manager" -w <passwd> -f /var/tmp/passwd passwd 1 個のエントリが追加されました |
同様に/var/tmp以下にshadowファイルも作成して、そこへ/etc/shadowファイル内のtestuserの行を/var/tmp/shadowファイルに書き込みます。
| # vi /var/tmp/shadow testuser:CLJY.I43OF/7k:13936:::::: |
| # ldapaddent -D "cn=Directory Manager" -w <password> -f /var/tmp/shadow shadow 1 個のエントリが追加されました |
この段階で、念のためName Service Cacheを再起動します。
| # svcadm restart svc:/system/name-service-cache:default |
上記のエントリ追加、name-service-cacheを再起動後、ldapsearchコマンドでtestuserを検索すると、下記のように表示されます。
| # ldapsearch -h 192.168.10.10 -b "dc=example,dc=com" uid=testuser version: 1 dn: uid=testuser,ou=people,dc=example,dc=com cn: testuser uidNumber: 100 gidNumber: 1 homeDirectory: /export/home/testuser loginShell: /bin/sh objectClass: posixAccount objectClass: shadowAccount objectClass: account objectClass: top uid: testuser shadowLastChange: 13936 shadowFlag: 0 |
正しく検索できることを確認後、zone1上の /etc/passwd, /etc/shadow内のtestuserの行を削除します。(Directory Serverインスタンスで認証させるため。)
ldapclient 実行後の作業
LDAPクライアントzone上で、ldapclient実行後、/etc/nsswitch.confが書き換えられており、host名等もLDAPのみを参照する設定になっています。今回はhost名は登録していないので、/etc/nsswitch.confを修正します。
/etc/nsswitch.conf
# the following two lines obviate the "+" entry in /etc/passwd and /etc/group.
passwd: files ldap
group: files ldap
# consult /etc "files" only if ldap is down.
hosts: ldap [NOTFOUND=return] files
# Note that IPv4 addresses are searched for in all of the ipnodes databases
# before searching the hosts databases.
ipnodes: ldap [NOTFOUND=return] files
networks: ldap [NOTFOUND=return] files
protocols: ldap [NOTFOUND=return] files
rpc: ldap [NOTFOUND=return] files
ethers: ldap [NOTFOUND=return] files
netmasks: ldap [NOTFOUND=return] files
bootparams: ldap [NOTFOUND=return] files
publickey: ldap [NOTFOUND=return] files
[NOTFOUND=return] をとる。
| # the following two lines obviate the "+" entry in /etc/passwd and /etc/group. passwd: files ldap group: files ldap # consult /etc "files" only if ldap is down. hosts: ldap files # Note that IPv4 addresses are searched for in all of the ipnodes databases # before searching the hosts databases. ipnodes: ldap files networks: ldap files protocols: ldap files rpc: ldap files ethers: ldap files netmasks: ldap files bootparams: ldap files publickey: ldap files |
あとは、/etc/hostsに Directory Serverやzoneのホスト名が登録されていれば、ping ホスト名で、正しく名前解決出来ます。
# vi /etc/hosts
::1 localhost
127.0.0.1 localhost
192.168.10.20 zone1 zone1.example.com loghost
192.168.10.10 funa funa.example.com
Directory Serverインスタンスにより、認証が正しく行われているか確認
まず、Directory Server側(global zone側)で、Directory Serverインスタンスを停止します。 停止したことを確認します。# svcadm disable svc:/application/sun/ds:ds--var-opt-SUNWdsee-dsins1 # svcs -a | grep ds
legacy_run 16:30:12 lrc:/etc/rc2_d/S72utds
disabled 17:06:00 svc:/application/sun/ds:default
disabled 18:36:59 svc:/application/sun/ds:ds--var-opt-SUNWdsee-dsins1
#
Directory Server(global zone)から、LDAPクライアント(zone1)へsshでのログインを試みます。
| # ssh -l testuser zone1 パスワード: パスワード: パスワード: アクセス権がありません (gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive)。 # |
Directory Server インスタンスが停止しており、認証できないためログインできません。(zone1の/etc/passwd,/etc/shadow内のtestuser行が削除されているため)
次にDirectory Serverインスタンスを起動します。# svcadm enable svc:/application/sun/ds:ds--var-opt-SUNWdsee-dsins1
起動したことを確認します。
| # svcs -a | grep ds legacy_run 16:30:12 lrc:/etc/rc2_d/S72utds disabled 17:06:00 svc:/application/sun/ds:default online 18:39:57 svc:/application/sun/ds:ds--var-opt-SUNWdsee-dsins1 # |
これで、LDAPクライアント(zone1)にtestuserでログインを試みると、Directory Serverインスタンスにより認証されるので、ログインが可能となります。# ssh -l testuser zone1
パスワード:
Last login: Wed Feb 27 18:33:20 2008 from funa
Sun Microsystems Inc. SunOS 5.10 Generic January 2005
$
これで、LDAPクライアント側(ローカルゾーン)の通常のログイン(dtlogin)の場合もDirectory Server側の認証を受けて���グイン出来ています。
以上で、動作確認は終了です!お疲れ様でした!




先日のナイトセミナーはお疲れ様でした。
実際にこの手順書を見ながら自社検証サーバにて構築を進めています。
とても参考になります。
Posted by sho on 3月月 18日, 2008年 at 08:27 午後 JST #
sho さん
ありがとうございます。
実際に手順書をご活用頂いているとのこと、嬉しく思っております。
今後とも Night Seminar や OpenSolaris の活動にぜひご参加ください。
funasaki
Posted by funasaki on 3月月 27日, 2008年 at 11:02 午前 JST #