Samba PDC (lenny)

提供:Samba-JP
2009年9月12日 (土) 16:30時点におけるMonyo (トーク | 投稿記録)による版
ナビゲーションに移動検索に移動

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
  • 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
  • /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 use_first_pass
+password   required pam_smbpass.so use_authtok try_first_pass

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

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

  • 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 パッケージは管理用。動作上は不要。

# apt-get install libpam-smbpass
  • 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





smb.conf の設定

mv /etc/samba/smb.conf /etc/samba/smb.conf.org
smb.conf ファイルを作成
  • /etc/samba/smb.conf /etc/samba/mgrshare
上記ファイルを追加
# chmod +x /etc/samba/mgrshare
ファイルが存在しないことによるエラーを抑止
# touch /etc/printcap
# smbpasswd -w ldap

/home/shared を作成。

/var/lib/samba/shares 以下の共有の作成

libpam-smbpass
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/printers

smbldap-tools の設定

  • apt-get install smbldap-tools

/etc/smbldap-tools に smbldap_bind.conf と smbldap.conf を作成。smbldap_bind.conf,smbldap.conf は /usr/share/doc/smbldap-tools/examples配下にある。

smbldap_bind.confは

slaveDN="cn=admin,dc=samba,dc=local"
slavePw="ldap"
masterDN="cn=admin,dc=samba,dc=local"
masterPw="ldap"
  • net getlocalsid で取得した SID を smbldap.conf に設定
  • smbldap-populate -a Administrator -b Guest

Administrator のパスワードには「samba」を指定。

# 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
# mkdir /home/Guest
# chgrp "Domain Guests" /home/Guest
# chmod 700 /home/Guests
  • 一般ユーザを作成
# smbldap-useradd -a -u 1001 -m ldap01
# smbldap-passwd ldap01