「Samba PDC (lenny)」の版間の差分

提供:Samba-JP
ナビゲーションに移動検索に移動
 
(2人の利用者による、間の38版が非表示)
1行目: 1行目:
=debian GNU/Linux リリース媒体の入手=
=debian GNU/Linux リリース媒体の入手=
[http://www.debian.org/distrib/netinst#smallcd 小さなCD] にある 180MB 以下のイメージを入手。
[http://www.debian.or.jp/using/ クイックインストール用媒体]や[http://www.debian.or.jp/using/ 各種ISOイメージ]をダウンロードしておく。今回はネットワークで追加インストールをすることを前提にして、debian-500-i386-netinst.isoを使う。

= VMware 仮想マシンの作成 =
= VMware 仮想マシンの作成 =


== 仮想マシン作成の手順 ==
== 仮想マシン作成の手順 ==


仮想マシン作成ウィザードで以下を指定(以下VMware6環境で作成することを前提)
仮想マシン作成ウィザードで以下を指定(VMware 5.5.8 環境で構築)


* カスタムを選択
* ''custom'' を選択
* ハードウェア互換性として Workstation5 を選択
* ハードウェア互換性として ''legacy'' を選択(なるべく多くのバージョンで動作するように)
* ゲストOSとして Linux を選択
* ゲストOSとして ''Linux''を選択
* バージョンとして Other Linux 2.6.x kernel を選択
* バージョンとして ''Other Linux 2.6.x kernel'' を選択
* 仮想マシン名として sambapdc3 を指定
* 仮想マシン名として ''sambapdc-3.0'' を指定
* メモリ容量を ''64MB'' に変更
* 格納場所は任意
* ネットワーク接続を ''NAT'' に変更
* プロセッサ数は 1 を指定
* メモリは既定値のまま
* ネットワーク接続は NAT を指定(ブリッジでも可)
* I/Oアダプタは既定値のまま
* I/Oアダプタは既定値のまま
* ディスクは既定値のまま
* 新規ディスクを作成
** ''SCSI'' を選択
* 仮想ディスクタイプは IDEを指定
** ディスクサイズほかは規定値のまま(4GB/あらかじめ割り当てない)
* ディスク容量は8GB、「ディスクを2GBのファイルに分割します」にチェック
* ディスクファイルを sambapdc3.vmdk と指定
** 仮想ディスクファイルsambapdc.vmdk と指定


仮想マシン設定で以下を調整
仮想マシン作成後に以下を調整


* フロッピーを削除
* USBを削除
* サウンドアダプタを削除
* サウンドアダプタを削除

* CD-ROMをダウンロードしてきたISOイメージ(または媒体)に指定
== Lenny インストール ==
== Lenny インストール ==


32行目: 31行目:
インストーラで以下を指定
インストーラで以下を指定


* 初期画面で「Install」を選択(Graphical Installではなく)
* 「Choose language」で「English」を選択
* 「Choose language」で「English」を選択
* 「Choose country」で「Japan」を選択
* 「Choose country」で「Japan」を選択
* 「Keymap to use」で「Japanese」を選択
* 「Keymap to use」で「American English」を選択
* 「Configure network」で以下を指定
* 「Configure network」で以下を指定
** ホスト名「sambapdc」
** ホスト名「sambapdc」
40行目: 40行目:
* パーティション設定で以下を指定
* パーティション設定で以下を指定
** 「Guided - use entire disk(デフォルト)」を選択
** 「Guided - use entire disk(デフォルト)」を選択
** パーティションを作成するディスクとして IDE1 master を選択(それ以外選択できない)
** パーティション構成で「All files in one partition(デフォルト)」を選択
** パーティション構成で「All files in one partition(デフォルト)」を選択
** 「Finish partitioning and write changes to disk」を押す
** 「Finish partitioning and write changes to disk」を押す
** 「Write changes to disks?」に <Yes>を選択
** 「Write changes to disks?」に <Yes>を選択
* ここで「Installing the base system」画面になり、基本的なパッケージがインストールされる
* Root password を「samba」に設定
* ユーザとしてlocal」を作成
* 「Root password」でsamba」を設定
* ''「Set up users and passwords」の「Full name for new user」で「Debian installer main menu」になるまで、何度か「<Go back>」を選択''
* Configure the package manager で「Japan」を選択
*
* ''Full name for new user で「Debian installer main menu」になるまで、何度か<Go back> を選択''
: これを行わずに普通にインストールを続行すると、無用なパッケージがインストールされるので注意。
: これを行わずに普通にインストールを続行すると、無用なパッケージがインストールされるので注意。
* 「Install the GRUB boot loader on a hard disk」を選択
** Install the GRUB boot loader to the master boot record? に <yes> を選択
* Installation complete で <Continue>
: ここで再起動が行われる

このほか聞かれた場合は、以下のように選択

* Install the base system を選択
* Install the base system を選択
* Kernel to install で「linux-image-2.6-686」を選択
* Kernel to install で「linux-image-2.6-686」を選択
* Use a network mirror で <No>
* Use a network mirror で <No>
* Choose software to install ですべてのチェックをはずす
* GRUB boot loader to the master boot record? に <yes>
* Installation complete で <Continue>
: ここで再起動が行われる
* Create new identity に No
: Yes にした場合、以下の eth1 を認識される設定を行うまでネットワークが利用できない。
* 仮想マシンの名称を Samba PDC 2.0 に変更


=== 基本的な設定 ===
=== 基本的な設定 ===


* eth1 用の設定を追加
* eth1 用の設定を追加(オプション)


: 仮想マシンのイメージを他で転用すると、通常 MAC アドレスが変更となり、OS から認識されるインタフェース名も eth0 ではなく eth1 になる。そのための設定
: 仮想マシンのイメージを他で転用すると、仮想マシン起動時に「Create new identity」といったメッセージが表示される。ここで Yes を選択した場合は MACアドレスが変更されるため OS から認識されるインタフェース名も eth0 ではなく eth1 や eth2 などになる。そのための設定


: /etc/network/interfaces に以下を追加
: /etc/network/interfaces に以下を追加(eth1の場合)


allow-hotplug eth1
allow-hotplug eth1
76行目: 73行目:
: /etc/apt/sources.list の内容を以下に変更
: /etc/apt/sources.list の内容を以下に変更


<pre>
deb http://ftp.jp.debian.org/debian etch main contrib
deb-src http://ftp.jp.debian.org/debian etch main contrib
deb http://ftp.jp.debian.org/debian etch main contrib
deb http://security.debian.org/ etch/updates main contrib
deb-src http://ftp.jp.debian.org/debian etch main contrib
deb-src http://security.debian.org/ etch/updates main contrib
deb http://security.debian.org/ etch/updates main contrib
deb-src http://security.debian.org/ etch/updates main contrib
</pre>


: 以下のコマンドを実行
: 以下のコマンドを実行


apt-get update
apt-get update
apt-get clean
apt-get upgrade security
apt-get upgrade security
apt-get clean
apt-get clean
89行目: 89行目:
: カーネルがバージョンアップされた場合は、一度再起動する
: カーネルがバージョンアップされた場合は、一度再起動する
* 基本的な設定とパッケージのインストール
* ssh パッケージのインストール


apt-get install openssh-server
: 管理用パッケージをインストール
apt-get clean


クライアントも併せてインストールされる。
<pre>
apt-get install openssh-server openssh-client rcconf sysv-rc-conf jless
apt-get clean
</pre>


* lv(ページャ)をインストール
: ACL関連の設定


apt-get install lv
<pre>
apt-get install attr acl
apt-get clean
</pre>


* リモートログイン用アカウントの作成
: /etc/fstab で acl,user_xattr をマウントオプションに追加


# useradd -m local
: defaults,errors=remount-ro を defaults,acl,user_xattr,errors=remount-ro に変更
# passwd local


パスワードは「local」に設定。
: LDAP 関連のインストール


* ACLおよび拡張属性関連のパッケージインストールと設定
<pre>
apt-get install slapd ldap-utils
</pre>


apt-get install attr acl
: Admin password には ldap を指定する。
apt-get clean


: /etc/fstab で acl,user_xattr をマウントオプションに追加
: /etc/ldap/slapd.conf を変更
: ''errors=remount-ro'' を ''defaults,acl,user_xattr,errors=remount-ro'' に変更
: 再起動せずに、マウントオプションを変更


mount -o remount,defaults,acl,user_xattr,errors=remount-ro /dev/sda1 /
: /usr/share/doc/samba-doc/examples/LDAP/samba.schema.gz ファイルを解凍した後 /etc/ldap/schema にコピー


= Samba + LDAP 環境の設定 =
: 再起動


=== LDAP にアカウントを格納する設定 ===
== パッケージのイールと基本設定 ==


=== libnss-ldap / libpam-ldap のインストールと設定 ===
<pre>
apt-get install libnss-ldap
</pre>


: libnss-ldap URL はデフォルトのまま
apt-get install libnss-ldap libpam-ldap


* libnss-ldap の設定
: URL は ldap://localhost/
: DN は、dc=samba,dc=local
: DN は、dc=samba,dc=local
: LDAPのバージョンは3
: LDAP account for root は cn=admin,dc=samba,dc=local
: パスワードは ldap


* libpam-ldap の設定
: LDAP account for root は dc=admin,dc=samba,dc=local
: Make local database admin... はデフォルトのまま
: Does the LDAP database require login はデフォルトのまま(No)
: LDAP account for root は cn=admin,dc=samba,dc=local
: パスワードは ldap


* nscd をアンインストール
: LDAP version to use は「3(デフォルト)」


'''nscd が動作していると(なぜか)LDAP 上のユーザ情報が Linux から認識されないため、ここでは削除する。'''
: /etc/nsswitch.conf ファイルに LDAP キーワードを追加


# apt-get remove nscd
<pre>
Reading package lists... Done
apt-get install libpam-ldap
Building dependency tree
</pre>
Reading state information... Done
The following packages will be REMOVED:
nscd
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 274kB disk space will be freed.
Do you want to continue [Y/n]? y
(Reading database ... 14825 files and directories currently installed.)
Removing nscd ...
Stopping Name Service Cache Daemon: nscd.
Processing triggers for man-db ...


* /etc/nsswitch.conf ファイルに LDAP キーワードを追加
: LDAP account for root は dc=admin,dc=samba,dc=local


--- nsswitch.conf.org 2009-09-10 03:02:29.000000000 +0900
: パスワードは ldap
+++ nsswitch.conf 2009-09-07 22:10:09.000000000 +0900
@@ -4,9 +4,9 @@
# If you have the `glibc-doc-reference' and `info' packages installed, try:
# `info libc "Name Service Switch"' for information about this file.
-passwd: compat
-group: compat
-shadow: compat
+passwd: compat ldap
+group: compat ldap
+shadow: compat ldap
hosts: files dns
networks: files


* /etc/pam.d/common-account
* /etc/pam.d/common-account
: (-は行削除、+は行追加)


account sufficient pam_ldap.so ← 追加
+account sufficient pam_ldap.so
account required pam_unix.so
account required pam_unix.so


* /etc/pam.d/common-auth (-は行削除、+は行追加)
* /etc/pam.d/common-auth
: (-は行削除、+は行追加)


-auth required pam_unix.so nullok_secure
-auth required pam_unix.so nullok_secure
+auth sufficient pam_ldap.so
+auth sufficient pam_ldap.so
+auth required pam_unix.so nullok_secure use_first_pass
+auth required pam_unix.so nullok_secure use_first_pass
+#auth optional pam_smbpass.so debug


* /etc/pam.d/common-session
* /etc/pam.d/common-session
: (-は行削除、+は行追加)


session optional pam_ldap.so ←この行追加
session required pam_unix.so
+session optional pam_ldap.so
+session optional pam_mkhomedir.so skel=/etc/skel


* /etc/pam.d/common-password
* /etc/pam.d/common-password
: (-は行削除、+は行追加)


-password required pam_unix.so nullok obscure min=4 max=8 md5
-password required pam_unix.so nullok obscure
+password sufficient pam_unix.so nullok obscure min=4 max=8 md5
+password sufficient pam_unix.so nullok obscure min=4 max=8 md5
+password required pam_ldap.so use_first_pass
+password required pam_ldap.so try_first_pass
+password required pam_smbpass.so use_authtok try_first_pass
+password required pam_smbpass.so use_authtok try_first_pass


pam_smbpass 行は、次でインストールする pam_smbpass モジュールのための設定

=== Samba / OpenLDAP のインストール ===

* slapd パッケージのインストール

apt-get install slapd ldap-utils
apt-get clean

: Admin password には ldap を指定する。

ldap-utils パッケージは管理用。動作上は不要。

* Samba 関連パッケージのインストール

# apt-get install samba winbind smbclient
# apt-get clean

: workgroup/domain name に ''SAMBADOM'' を指定
: WINS settings from DHCP? に No(デフォルト)を指定

smbclient パッケージは管理用。動作上は不要。

* pam_smbpass パッケージのインストール

# apt-get install libpam-smbpass

* cracklib パッケージのインストール

# apt-get install libcrack2

※crackcheck コマンドが使用する。

* Samba スキーマファイルをインストール

# apt-get install samba-doc
# apt-get clean

# zcat /usr/share/doc/samba-doc/examples/LDAP/samba.schema.gz > /etc/ldap/schema/samba-3.2.5.schema

# apt-get remove samba-doc

* /etc/ldap/slapd.conf を設定

--- slapd.conf.org 2009-09-12 19:26:34.000000000 +0900
+++ slapd.conf 2009-09-12 19:50:27.000000000 +0900
@@ -12,6 +12,7 @@
include /etc/ldap/schema/cosine.schema
include /etc/ldap/schema/nis.schema
include /etc/ldap/schema/inetorgperson.schema
+include /etc/ldap/schema/samba-3.2.5.schema
# Where the pid file is put. The init.d script
# will not stop the server if you change this.
@@ -57,7 +58,8 @@
# rootdn directive for specifying a superuser on the database. This is needed
# for syncrepl.
-# rootdn "cn=admin,dc=samba,dc=local"
+rootdn "cn=admin,dc=samba,dc=local"
+rootpw "ldap"
# Where the database file are physically stored for database #1
directory "/var/lib/ldap"
@@ -83,7 +85,7 @@
dbconfig set_lk_max_lockers 1500
# Indexing options for database #1
-index objectClass eq
+index objectClass,uidNumber,gidNumber,uid,sambaSID,cn,memberuid eq
# Save the time that the entry gets modified, for database #1
lastmod on
@@ -106,6 +108,16 @@
by self write
by * none
+access to attrs=loginShell
+ by dn="cn=admin,dc=samba,dc=local" write
+ by self write
+ by * read
+
+access to attrs=sambaNTPassword,sambaLMPassword,sambaPwdLastSet,sambaPwdMustChange
+ by dn="cn=admin,dc=samba,dc=local" write
+# by self write
+ by * none
+
# Ensure read access to the base for things like
# supportedSASLMechanisms. Without this you may
# have problems with SASL not knowing what

=== crackcheck コマンドのインストール ===

開発環境のあるマシン上で以下を実施

# apt-get install cracklib2-dev

# apt-get install samba-doc
# cd /usr/share/doc/samba-doc/examples/auth/crackcheck
# make
# strip crackcheck

生成された crackcheck バイナリを、今回構築するマシンの /usr/local/sbin/crackcheck にインストール。

=== mgrshare スクリプトのインストール ===

mgrshare スクリプトを作成の上、以下を実施( mgrshare は [[http://wiki.samba.gr.jp/mediawiki/images/8/80/Sambapdc-3.0-conf.tar.gz | sambapdc-3.0.tar.gz]] 内にあります)

# mv mgrshare /usr/local/sbin/mgrshare
# chmod +x /usr/local/sbin/mgrshare

=== smbchsh のインストール ===

一般ユーザがシェルを変更できるように以下のスクリプトを /usr/local/bin/smbchsh としてインストール

#!/bin/sh
SHELL=$1
echo "dn: uid=${USER},ou=users,dc=samba,dc=local
changetype: modify
replace: loginShell
loginShell: $1
" | ldapmodify -x -D "uid=${USER},ou=users,dc=samba,dc=local" -W

=== ホームディレクトリの作成 ===

pam_mkhomedir を用いる関係上、パーミッションの設定が必須

# mkdir /home/SAMBADOM
# chmod 1777 /home/SAMBADOM
=== Samba ドメインで使用するディレクトリの作成 ===

# mkdir /var/lib/samba/shares
# mkdir /var/lib/samba/shares/netlogon
# mkdir /var/lib/samba/shares/profiles
# chmod 1777 /var/lib/samba/shares/profiles

=== ダミーの printcap ファイルの作成 ===

printing = bsd を指定し、/etc/printcap ファイルを作成することで、CUPS サーバに接続できないというエラー表示を抑止する。

# touch /etc/printcap

== Samba + LDAP 環境の設定 ==

=== 初期スキーマの作成 ===

* samba.local.ldif ファイルの作成

dn: ou=users,dc=samba,dc=local
objectClass: top
objectClass: organizationalUnit
ou: users
dn: ou=groups,dc=samba,dc=local
objectClass: top
objectClass: organizationalUnit
ou: groups
dn: ou=idmap,dc=samba,dc=local
objectClass: top
objectClass: organizationalUnit
ou: idmap
dn: ou=computers,dc=samba,dc=local
objectClass: top
objectClass: organizationalUnit
ou: computers

* ldapadd コマンドで上記 LDIF ファイルの内容を登録

# cat samba.local.ldif | ldapadd -h localhost -D cn=admin,dc=samba,dc=local -W -x
Enter LDAP Password:
adding new entry "ou=users,dc=samba,dc=local"
adding new entry "ou=groups,dc=samba,dc=local"
...

=== Samba の設定 ===
=== Samba の設定 ===


* Samba の停止
<pre>
# apt-get install samba smbclient libpam-smbpass
</pre>


# /etc/init.d/samba stop
* workgroup/domain name に SAMBADOM を指定
# /etc/init.d/winbind stop


* /etc/samba/smb.conf /etc/samba/mgrshare
* smb.conf のインストール


smb.conf ファイルを作成( smb.conf は [[http://wiki.samba.gr.jp/mediawiki/images/8/80/Sambapdc-3.0-conf.tar.gz | sambapdc-3.0.tar.gz]] 内にあります)の上、以下を実施
: 上記ファイルを追加


# mv /etc/samba/smb.conf /etc/samba/smb.conf.org
<pre>
# chmod +x /etc/samba/mgrshare
# mv smb.conf /etc/samba/smb.conf
</pre>


* LDAP パスワードの格納
: ファイルが存在しないことによるエラーを抑止


# smbpasswd -w ldap
<pre>
Setting stored password for "cn=admin,dc=samba,dc=local" in secrets.tdb
# touch /etc/printcap
</pre>


* Samba の基本ユーザ情報を LDAP に格納
<pre>
# smbpasswd -w ldap
</pre>


net sam provision コマンドを実行する前に、あらかじめ winbindd (のみ)を起動しておく必要がある。
/home/shared を作成。


# /etc/init.d/winbind start
/var/lib/samba/shares 以下の共有の作成
Starting the Winbind daemon: winbind.
# net sam provision
Checking for Domain Users group.
Adding the Domain Users group.
Checking for Domain Admins group.
Adding the Domain Admins group.
Check for Administrator account.
Adding the Administrator user.
Checking for Guest user.
Adding the Guest user.
Checking Guest's group.
Adding the Domain Guests group.


* Administrator アカウントの初期設定
<pre>
mkdir -p /var/lib/samba/shares/{netlogon,profiles,printers}
chmod 1777 /var/lib/samba/shares/profiles
chmod g+ws /var/lib/samba/shares/printers
chgrp "Print Operators" /var/lib/samba/shares/printer
</pre>


: パスワードを「samba」に設定
=== smbldap-tools の設定 ===


# smbpasswd Administrator
* apt-get install smbldap-tools
New SMB password:
Retype new SMB password:


: ユーザ権利を付与
/etc/smbldap-tools に smbldap_bind.conf と smbldap.conf を作成。
# net sam rights grant administrator SeMachineAccountPrivilege
Granted SeMachineAccountPrivilege to SAMBADOM\administrator
# net sam rights grant administrator SeTakeOwnershipPrivilege
Granted SeTakeOwnershipPrivilege to SAMBADOM\administrator
# net sam rights grant administrator SeBackupPrivilege
Granted SeBackupPrivilege to SAMBADOM\administrator
# net sam rights grant administrator SeRestorePrivilege
Granted SeRestorePrivilege to SAMBADOM\administrator
# net sam rights grant administrator SeRemoteShutdownPrivilege
Granted SeRemoteShutdownPrivilege to SAMBADOM\administrator
# net sam rights grant administrator SePrintOperatorPrivilege
Granted SePrintOperatorPrivilege to SAMBADOM\administrator
# net sam rights grant administrator SeAddUsersPrivilege
Granted SeAddUsersPrivilege to SAMBADOM\administrator
# net sam rights grant administrator SeDiskOperatorPrivilege
Granted SeDiskOperatorPrivilege to SAMBADOM\administrator


=== 共有ディレクトリの作成 ===
* net getlocalsid で取得した SID を smbldap.conf に設定


Domain Usersグループに所属するユーザであれば、誰でも読み書き可能な共有ディレクトリを作成しておく。
* smbldap-populate -a Administrator -b Guest


# mkdir /home/shared
Administrator のパスワードには「samba」を指定。
# chgrp domusers /home/shared
# chmod g+ws /home/shared


共有内に、あらかじめ URL ファイルをいくつか設置しておく。
<pre>
# mkdir /home/Administrator
# chgrp "Domain Admins" /home/Administrator
# chmod 700 /home/Administrator
# smbldap-usermod -H "Domain Users","Domain Admins" Administrator


== 動作確認 ==
# net rpc rights grant SeMachineAccountPrivilege Administrator -U Administrator%samba
# net rpc rights grant SeTakeOwnershipPrivilege Administrator -U Administrator%samba
# net rpc rights grant SeBackupPrivilege Administrator -U Administrator%samba
# net rpc rights grant SeRestorePrivilege Administrator -U Administrator%samba
# net rpc rights grant SeRemoteShutdownPrivilege Administrator -U Administrator%samba
# net rpc rights grant SePrintOperatorPrivilege Administrator -U Administrator%samba
# net rpc rights grant SeAddUsersPrivilege Administrator -U Administrator%samba
# net rpc rights grant SeDiskOperatorPrivilege Administrator -U Administrator%samba
</pre>


<pre>
# mkdir /home/Guest
# chgrp "Domain Guests" /home/Guest
# chmod 700 /home/Guests
</pre>


* 一般ユーザを作成


=== Windows NT Workstation 4.0 SP6a(以下 NTWS40) から Samba ドメインに参加 ===
<pre>

# smbldap-useradd -a -u 1001 -m ldap01
* ドメインに参加
# smbldap-passwd ldap01
* Administrator としてログオン
</pre>

=== 試験用ユーザを作成 ===

* ldap01 ユーザを作成
** パスワード ldap01
** ホームディレクトリ \\sambapdc\ldap01 を H: にマウント
** ユーザ名「LDAP User 01」
** パスワードを無期限にする

=== 動作確認 ===

* 初期状態で
** ldap01 として ssh でリモートマシンからログインが成功する
** smbchsh コマンドによりシェルを変更できる

ldap01@sambapdc:~$ /usr/local/bin/smbchsh /bin/sh
Enter LDAP Password:
modifying entry "uid=ldap01,ou=users,dc=samba,dc=local"
ldap01@sambapdc:~$ getent passwd ldap01
ldap01:*:10002:10000:ldap01:/home/SAMBADOM/ldap01:/bin/sh

** ldap01 として NTWS40 にログオンできる (パスワード ldap01)

* smbpasswd コマンドによりパスワードを変更できる
: その際、crackcheck コマンドにより、簡単なパスワードは設定できない

** ldap01 として NTWS40 にログオンできる (パスワードは変更後)
** ldap01 として ssh でリモートマシンからログインが成功する(パスワードは変更後)

* passwd コマンドによりパスワードを変更できる

** ldap01 として NTWS40 にログオンできる (パスワードは変更後)
** ldap01 として ssh でリモートマシンからログインが成功する(パスワードは変更後)

* Windows 2000 以降で Ctrl+Alt+Del した画面のパスワードの変更、からパスワードが変更できる
: その際、crackcheck コマンドにより、簡単なパスワードは設定できない

** ldap01 として NTWS40 にログオンできる (パスワードは変更後)
** ldap01 として ssh でリモートマシンからログインが成功する(パスワードは変更後)

* Windows 2000 に Administrator としてログオンして、「コンピュータ管理」ツールから
** ファイル共有が作成できる
** 作成したファイル共有にアクセスできる
** ファイル共有が削除できる

※Windows NT Workstation 4.0 からの共有の作成は、なぜかうまく動作していません。

2009年9月12日 (土) 19:52時点における最新版

debian GNU/Linux リリース媒体の入手

小さなCD にある 180MB 以下のイメージを入手。

VMware 仮想マシンの作成

仮想マシン作成の手順

仮想マシン作成ウィザードで以下を指定(VMware 5.5.8 環境で構築)

  • custom を選択
  • ハードウェア互換性として legacy を選択(なるべく多くのバージョンで動作するように)
  • ゲストOSとして Linuxを選択
  • バージョンとして Other Linux 2.6.x kernel を選択
  • 仮想マシン名として sambapdc-3.0 を指定
  • メモリ容量を 64MB に変更
  • ネットワーク接続を NAT に変更
  • I/Oアダプタは既定値のまま
  • 新規ディスクを作成
    • SCSI を選択
    • ディスクサイズほかは規定値のまま(4GB/あらかじめ割り当てない)
    • 仮想ディスクのファイル名を sambapdc.vmdk と指定

仮想マシン作成後に以下を調整

  • USBを削除
  • サウンドアダプタを削除

Lenny インストール

インストーラでの設定

インストーラで以下を指定

  • 初期画面で「Install」を選択(Graphical Installではなく)
  • 「Choose language」で「English」を選択
  • 「Choose country」で「Japan」を選択
  • 「Keymap to use」で「American English」を選択
  • 「Configure network」で以下を指定
    • ホスト名「sambapdc」
    • ドメイン名「samba.local」
  • パーティション設定で以下を指定
    • 「Guided - use entire disk(デフォルト)」を選択
    • パーティション構成で「All files in one partition(デフォルト)」を選択
    • 「Finish partitioning and write changes to disk」を押す
    • 「Write changes to disks?」に <Yes>を選択
  • ここで「Installing the base system」画面になり、基本的なパッケージがインストールされる
  • 「Root password」で「samba」を設定
  • 「Set up users and passwords」の「Full name for new user」で「Debian installer main menu」になるまで、何度か「<Go back>」を選択
これを行わずに普通にインストールを続行すると、無用なパッケージがインストールされるので注意。
  • 「Install the GRUB boot loader on a hard disk」を選択
    • Install the GRUB boot loader to the master boot record? に <yes> を選択
  • Installation complete で <Continue>
ここで再起動が行われる

このほか聞かれた場合は、以下のように選択

  • Install the base system を選択
  • Kernel to install で「linux-image-2.6-686」を選択
  • Use a network mirror で <No>

基本的な設定

  • eth1 用の設定を追加(オプション)
仮想マシンのイメージを他で転用すると、仮想マシン起動時に「Create new identity」といったメッセージが表示される。ここで Yes を選択した場合は MACアドレスが変更されるため、 OS から認識されるインタフェース名も eth0 ではなく eth1 や eth2 などになる。そのための設定
/etc/network/interfaces に以下を追加(eth1の場合)
allow-hotplug eth1
iface eth1 inet dhcp
  • APT コマンドの設定とパッケージの更新
/etc/apt/sources.list の内容を以下に変更
deb http://ftp.jp.debian.org/debian etch main contrib
deb-src http://ftp.jp.debian.org/debian etch main contrib
deb http://security.debian.org/ etch/updates main contrib
deb-src http://security.debian.org/ etch/updates main contrib
以下のコマンドを実行
apt-get update
apt-get clean
apt-get upgrade security
apt-get clean
カーネルがバージョンアップされた場合は、一度再起動する
  • ssh パッケージのインストール
apt-get install openssh-server
apt-get clean

クライアントも併せてインストールされる。

  • lv(ページャ)をインストール
apt-get install lv
apt-get clean
  • リモートログイン用アカウントの作成
# useradd -m local
# passwd local

パスワードは「local」に設定。

  • ACLおよび拡張属性関連のパッケージインストールと設定
apt-get install attr acl 
apt-get clean
/etc/fstab で acl,user_xattr をマウントオプションに追加
errors=remount-rodefaults,acl,user_xattr,errors=remount-ro に変更
再起動せずに、マウントオプションを変更
mount -o remount,defaults,acl,user_xattr,errors=remount-ro /dev/sda1 /

Samba + LDAP 環境の設定

パッケージのインストールと基本設定

libnss-ldap / libpam-ldap のインストールと設定

apt-get install libnss-ldap libpam-ldap
  • libnss-ldap の設定
URL は ldap://localhost/
DN は、dc=samba,dc=local
LDAPのバージョンは3
LDAP account for root は cn=admin,dc=samba,dc=local
パスワードは ldap
  • libpam-ldap の設定
Make local database admin... はデフォルトのまま
Does the LDAP database require login はデフォルトのまま(No)
LDAP account for root は cn=admin,dc=samba,dc=local
パスワードは ldap
  • nscd をアンインストール

nscd が動作していると(なぜか)LDAP 上のユーザ情報が Linux から認識されないため、ここでは削除する。

# apt-get remove nscd
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
  nscd
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 274kB disk space will be freed.
Do you want to continue [Y/n]? y
(Reading database ... 14825 files and directories currently installed.)
Removing nscd ...
Stopping Name Service Cache Daemon: nscd.
Processing triggers for man-db ...
  • /etc/nsswitch.conf ファイルに LDAP キーワードを追加
--- nsswitch.conf.org   2009-09-10 03:02:29.000000000 +0900
+++ nsswitch.conf       2009-09-07 22:10:09.000000000 +0900
@@ -4,9 +4,9 @@
 # If you have the `glibc-doc-reference' and `info' packages installed, try:
 # `info libc "Name Service Switch"' for information about this file.

-passwd:         compat
-group:          compat
-shadow:         compat
+passwd:         compat ldap
+group:          compat ldap
+shadow:         compat ldap

 hosts:          files dns
 networks:       files
  • /etc/pam.d/common-account
(-は行削除、+は行追加)
+account sufficient      pam_ldap.so
 account required        pam_unix.so
  • /etc/pam.d/common-auth
(-は行削除、+は行追加)
-auth   required        pam_unix.so nullok_secure
+auth   sufficient      pam_ldap.so
+auth   required        pam_unix.so nullok_secure use_first_pass
  • /etc/pam.d/common-session
(-は行削除、+は行追加)
 session        required        pam_unix.so
+session        optional        pam_ldap.so
+session        optional        pam_mkhomedir.so skel=/etc/skel
  • /etc/pam.d/common-password
(-は行削除、+は行追加)
-password   required   pam_unix.so nullok obscure
+password   sufficient pam_unix.so nullok obscure min=4 max=8 md5
+password   required pam_ldap.so try_first_pass
+password   required pam_smbpass.so use_authtok try_first_pass

pam_smbpass 行は、次でインストールする pam_smbpass モジュールのための設定

Samba / OpenLDAP のインストール

  • slapd パッケージのインストール
apt-get install slapd ldap-utils
apt-get clean
Admin password には ldap を指定する。

ldap-utils パッケージは管理用。動作上は不要。

  • Samba 関連パッケージのインストール
# apt-get install samba winbind smbclient
# apt-get clean
workgroup/domain name に SAMBADOM を指定
WINS settings from DHCP? に No(デフォルト)を指定

smbclient パッケージは管理用。動作上は不要。

  • pam_smbpass パッケージのインストール
# apt-get install libpam-smbpass
  • cracklib パッケージのインストール
  1. apt-get install libcrack2

※crackcheck コマンドが使用する。

  • Samba スキーマファイルをインストール
# apt-get install samba-doc
# apt-get clean
# zcat /usr/share/doc/samba-doc/examples/LDAP/samba.schema.gz > /etc/ldap/schema/samba-3.2.5.schema
# apt-get remove samba-doc
  • /etc/ldap/slapd.conf を設定
--- slapd.conf.org      2009-09-12 19:26:34.000000000 +0900
+++ slapd.conf  2009-09-12 19:50:27.000000000 +0900
@@ -12,6 +12,7 @@
 include         /etc/ldap/schema/cosine.schema
 include         /etc/ldap/schema/nis.schema
 include         /etc/ldap/schema/inetorgperson.schema
+include         /etc/ldap/schema/samba-3.2.5.schema

 # Where the pid file is put. The init.d script
 # will not stop the server if you change this.
@@ -57,7 +58,8 @@

 # rootdn directive for specifying a superuser on the database. This is needed
 # for syncrepl.
-# rootdn          "cn=admin,dc=samba,dc=local"
+rootdn          "cn=admin,dc=samba,dc=local"
+rootpw "ldap"

 # Where the database file are physically stored for database #1
 directory       "/var/lib/ldap"
@@ -83,7 +85,7 @@
 dbconfig set_lk_max_lockers 1500

 # Indexing options for database #1
-index           objectClass eq
+index           objectClass,uidNumber,gidNumber,uid,sambaSID,cn,memberuid eq

 # Save the time that the entry gets modified, for database #1
 lastmod         on
@@ -106,6 +108,16 @@
         by self write
         by * none

+access to attrs=loginShell
+        by dn="cn=admin,dc=samba,dc=local" write
+        by self write
+       by * read
+
+access to attrs=sambaNTPassword,sambaLMPassword,sambaPwdLastSet,sambaPwdMustChange
+        by dn="cn=admin,dc=samba,dc=local" write
+#        by self write
+        by * none
+
 # Ensure read access to the base for things like
 # supportedSASLMechanisms.  Without this you may
 # have problems with SASL not knowing what

crackcheck コマンドのインストール

開発環境のあるマシン上で以下を実施

# apt-get install cracklib2-dev
# apt-get install samba-doc
# cd /usr/share/doc/samba-doc/examples/auth/crackcheck
# make
# strip crackcheck

生成された crackcheck バイナリを、今回構築するマシンの /usr/local/sbin/crackcheck にインストール。

mgrshare スクリプトのインストール

mgrshare スクリプトを作成の上、以下を実施( mgrshare は [| sambapdc-3.0.tar.gz] 内にあります)

# mv mgrshare  /usr/local/sbin/mgrshare
# chmod +x /usr/local/sbin/mgrshare

smbchsh のインストール

一般ユーザがシェルを変更できるように以下のスクリプトを /usr/local/bin/smbchsh としてインストール

#!/bin/sh

SHELL=$1

echo "dn: uid=${USER},ou=users,dc=samba,dc=local
changetype: modify
replace: loginShell
loginShell: $1
" | ldapmodify -x -D "uid=${USER},ou=users,dc=samba,dc=local" -W

ホームディレクトリの作成

pam_mkhomedir を用いる関係上、パーミッションの設定が必須

# mkdir /home/SAMBADOM
# chmod 1777 /home/SAMBADOM

Samba ドメインで使用するディレクトリの作成

# mkdir /var/lib/samba/shares
# mkdir /var/lib/samba/shares/netlogon
# mkdir /var/lib/samba/shares/profiles
# chmod 1777 /var/lib/samba/shares/profiles

ダミーの printcap ファイルの作成

printing = bsd を指定し、/etc/printcap ファイルを作成することで、CUPS サーバに接続できないというエラー表示を抑止する。

# touch /etc/printcap

Samba + LDAP 環境の設定

初期スキーマの作成

  • samba.local.ldif ファイルの作成
dn: ou=users,dc=samba,dc=local
objectClass: top
objectClass: organizationalUnit
ou: users

dn: ou=groups,dc=samba,dc=local
objectClass: top
objectClass: organizationalUnit
ou: groups

dn: ou=idmap,dc=samba,dc=local
objectClass: top
objectClass: organizationalUnit
ou: idmap

dn: ou=computers,dc=samba,dc=local
objectClass: top
objectClass: organizationalUnit
ou: computers
  • ldapadd コマンドで上記 LDIF ファイルの内容を登録
# cat samba.local.ldif | ldapadd -h localhost -D cn=admin,dc=samba,dc=local -W -x

Enter LDAP Password: 
adding new entry "ou=users,dc=samba,dc=local"

adding new entry "ou=groups,dc=samba,dc=local"
...


Samba の設定

  • Samba の停止
# /etc/init.d/samba stop
# /etc/init.d/winbind stop
  • smb.conf のインストール

smb.conf ファイルを作成( smb.conf は [| sambapdc-3.0.tar.gz] 内にあります)の上、以下を実施

# mv /etc/samba/smb.conf /etc/samba/smb.conf.org
# mv smb.conf /etc/samba/smb.conf
  • LDAP パスワードの格納
# smbpasswd -w ldap
Setting stored password for "cn=admin,dc=samba,dc=local" in secrets.tdb
  • Samba の基本ユーザ情報を LDAP に格納

net sam provision コマンドを実行する前に、あらかじめ winbindd (のみ)を起動しておく必要がある。

# /etc/init.d/winbind start
Starting the Winbind daemon: winbind.
# net sam provision
Checking for Domain Users group.
Adding the Domain Users group.
Checking for Domain Admins group.
Adding the Domain Admins group.
Check for Administrator account.
Adding the Administrator user.
Checking for Guest user.
Adding the Guest user.
Checking Guest's group.
Adding the Domain Guests group.
  • Administrator アカウントの初期設定
パスワードを「samba」に設定
# smbpasswd Administrator
New SMB password:
Retype new SMB password:
ユーザ権利を付与
# net sam rights grant administrator SeMachineAccountPrivilege
Granted SeMachineAccountPrivilege to SAMBADOM\administrator
# net sam rights grant administrator SeTakeOwnershipPrivilege
Granted SeTakeOwnershipPrivilege to SAMBADOM\administrator
# net sam rights grant administrator SeBackupPrivilege
Granted SeBackupPrivilege to SAMBADOM\administrator
# net sam rights grant administrator SeRestorePrivilege
Granted SeRestorePrivilege to SAMBADOM\administrator
# net sam rights grant administrator SeRemoteShutdownPrivilege
Granted SeRemoteShutdownPrivilege to SAMBADOM\administrator
# net sam rights grant administrator SePrintOperatorPrivilege
Granted SePrintOperatorPrivilege to SAMBADOM\administrator
# net sam rights grant administrator SeAddUsersPrivilege
Granted SeAddUsersPrivilege to SAMBADOM\administrator
# net sam rights grant administrator SeDiskOperatorPrivilege
Granted SeDiskOperatorPrivilege to SAMBADOM\administrator

共有ディレクトリの作成

Domain Usersグループに所属するユーザであれば、誰でも読み書き可能な共有ディレクトリを作成しておく。

# mkdir /home/shared
# chgrp domusers /home/shared
# chmod g+ws /home/shared

共有内に、あらかじめ URL ファイルをいくつか設置しておく。

動作確認

Windows NT Workstation 4.0 SP6a(以下 NTWS40) から Samba ドメインに参加

  • ドメインに参加
  • Administrator としてログオン

試験用ユーザを作成

  • ldap01 ユーザを作成
    • パスワード ldap01
    • ホームディレクトリ \\sambapdc\ldap01 を H: にマウント
    • ユーザ名「LDAP User 01」
    • パスワードを無期限にする

動作確認

  • 初期状態で
    • ldap01 として ssh でリモートマシンからログインが成功する
    • smbchsh コマンドによりシェルを変更できる
ldap01@sambapdc:~$ /usr/local/bin/smbchsh /bin/sh
Enter LDAP Password:
modifying entry "uid=ldap01,ou=users,dc=samba,dc=local"

ldap01@sambapdc:~$ getent passwd ldap01
ldap01:*:10002:10000:ldap01:/home/SAMBADOM/ldap01:/bin/sh
    • ldap01 として NTWS40 にログオンできる (パスワード ldap01)
  • smbpasswd コマンドによりパスワードを変更できる
その際、crackcheck コマンドにより、簡単なパスワードは設定できない
    • ldap01 として NTWS40 にログオンできる (パスワードは変更後)
    • ldap01 として ssh でリモートマシンからログインが成功する(パスワードは変更後)
  • passwd コマンドによりパスワードを変更できる
    • ldap01 として NTWS40 にログオンできる (パスワードは変更後)
    • ldap01 として ssh でリモートマシンからログインが成功する(パスワードは変更後)
  • Windows 2000 以降で Ctrl+Alt+Del した画面のパスワードの変更、からパスワードが変更できる
その際、crackcheck コマンドにより、簡単なパスワードは設定できない
    • ldap01 として NTWS40 にログオンできる (パスワードは変更後)
    • ldap01 として ssh でリモートマシンからログインが成功する(パスワードは変更後)
  • Windows 2000 に Administrator としてログオンして、「コンピュータ管理」ツールから
    • ファイル共有が作成できる
    • 作成したファイル共有にアクセスできる
    • ファイル共有が削除できる

※Windows NT Workstation 4.0 からの共有の作成は、なぜかうまく動作していません。