Samba の設定はシンプルです。Samba に対する変更はすべて /etc/samba/smb.conf 設定ファイル内で行われます。デフォルトの smb.conf ファイルは適切に記述されていますが、LDAP、Active Directory、数多くのドメインコントローラの実装などの複雑なトピックは対処していません。
次のセクションでは Samba サーバのさまざまな設定方法について解説しています。ニーズを把握し、正しく設定するために smb.conf ファイルに必要とされる変更に留意してください。
スタンドアローンのサーバはワークグループサーバでもワークグループ環境のメンバーでも構いません。スタンドアローンサーバはドメインコントローラではなく、ドメインに参加するわけでもありません。次の例は anonymous 共有レベルのセキュリティ設定と単一ユーザーレベルのセキュリティ設定をいくつか示しています。共有レベル及びユーザーレベルのセキュリティモードについての詳細は、項14.4 を参照してください。
次の smb.conf ファイルは anonymous 読み取り専用ファイルの共有の実装に必要な設定の例です。security = share パラメータで共有が anonymous になります。単一の Samba サーバのセキュリティレベルは混在できないので注意してください。security ディレクティブは smb.conf ファイルの [global] 設定セクションにあるグローバル Samba パラメータです。
[global] workgroup = DOCS netbios name = DOCS_SRV security = share [data] comment = Documentation Samba Server path = /export read only = Yes guest only = Yes |
次の smb.conf ファイルは anonymous 読み取り/書き込みファイルの共有を実装するのに必要な設定の例です。anonymous 読み取り/書き込みファイルの共有を有効にするには、read only ディレクティブを no に設定します。また、force user と force group ディレクティブが追加されおり、 共有内で新規に配置されるファイルの所有権を強制指定しています。
![]() | 注記 |
---|---|
サーバを anonymous 読み取り/書き込みにすることはできますがお勧めしません。共有スペースに置かれるファイルはすべて、ユーザーに関係なく smb.conf ファイル内の汎用ユーザ (force user) とグループ (force group) で指定されているユーザー/グループの組合わせが割り当てられます。 |
[global] workgroup = DOCS netbios name = DOCS_SRV security = share [data] comment = Data path = /export force user = docsbot force group = users read only = No guest ok = Yes |
次の smb.conf ファイルは anonymous プリントサーバの実装に必要な設定の例です。設定例のbrowsable を no にすると Windows のマイネットワーク(または、ネットワークコンピュータなど)にあるプリンタの一覧を表示しなくなります。ブラウジングからは隠されますが、プリンタを明示的に設定することはできます。NetBIOS を使って DOCS_SRV に接続すると、クライアントも DOCS ワークグループの一部であればそのクライアントはプリンタにアクセスすることができます。また、use client driver ディレクティブが Yes に設定され、クライアントが正しいローカルプリンタドライバをインストールしていると仮定しています。この場合、Samba サーバはクライアントに対する 共有プリンタドライバの役割は果たしません。
[global] workgroup = DOCS netbios name = DOCS_SRV security = share printcap name = cups disable spools= Yes show add printer wizard = No printing = cups [printers] comment = All Printers path = /var/spool/samba guest ok = Yes printable = Yes use client driver = Yes browseable = Yes |
次の smb.conf ファイルは安全な読み取り/書き込みプリントサーバの実装に必要な設定の例です。security ディレクティブを user に設定することで Samba がクライアント接続を認証するよう強制します。[homes]共有にはforce user や force group ディレクティブがなく、[public] 共有にはこれらのディレクティブがあるのがわかります。[homes] 共有は [public] のforce user と force group に対立するすべての新規ファイルに認証ユーザーの情報を使用します。
[global] workgroup = DOCS netbios name = DOCS_SRV security = user printcap name = cups disable spools = Yes show add printer wizard = No printing = cups [homes] comment = Home Directories valid users = %S read only = No browseable = No [public] comment = Data path = /export force user = docsbot force group = users guest ok = Yes [printers] comment = All Printers path = /var/spool/samba printer admin = john, ed, @admins create mask = 0600 guest ok = Yes printable = Yes use client driver = Yes browseable = Yes |
スタンドアローンサーバに似ていますが、ドメインメンバーはドメインコントローラ(Windows または Samba のどちらか)にログインされ、ドメインのセキュリティルールに従います。ドメインメンバーサーバの例としては、Samba を実行している部門別サーバでプライマリドメインコントローラ (PDC) にマシンアカウント持つものでしょう。その部門のクライアントすべてはまだ PDC で認証しているので、デスクトッププロファイルやすべてのネットワークポリシーファイルが含まれています。違いは部門別サーバはプリンタとネットワーク共有の制御機能があるということです。
次の smb.conf ファイルは Active Directory ドメインメンバーサーバの実装に必要な設定の例です。この例では、Samba はローカルに実行されているサービスに対してユーザーを認証するだけでなく、Active Directory のクライアントも認証します。ご使用の kerberos realm パラメータがすべて大文字で表示されていることを確認します(例、realm = EXAMPLE.COM)。Windows 2000/2003 は Active Directory 認証に Kerberos が必要となるので、realm ディレクティブが必要です。Active Directory と Kerberos が異なるサーバで実行している場合は、区別できるよう password server ディレクティブが必要になる場合があります。
[global] realm = EXAMPLE.COM security = ADS encrypt passwords = yes # Optional. Use only if Samba cannot determine the Kerberos server automatically. password server = kerberos.example.com |
メンバーサーバを Active Directory ドメインに参加させるためには、次の手順にしたがってください。
メンバーサーバにある smb.conf ファイルの設定
メンバーサーバにある /etc/krb5.conf ファイルを含む Kerberos の設定
Active Directory ドメインサーバにあるマシンアカウントの作成
メンバーサーバの Active Directory ドメインへの関連付け
マシンアカウントを作成して Windows 2000/2003 Active Directory に参加するには、まず、メンバーサーバが Active Directory ドメインに参加要請するよう Kerberos を初期化する必要があります。管理 Kerberos チケットを作成するには、root としてメンバーサーバ上で次のコマンドを入力します。
root# kinit administrator@EXAMPLE.COM |
kinit コマンドは Kerberos 初期化スクリプトで Active Directory 管理者アカウントと Kerberos 領域を参照します。Active Directory は Kerberos チケットを必要とするため、kinit はクライアント/サーバ認証用の Kerberos ticket-granting チケットを取得してキャッシュします。Kerberos /etc/krb5.conf ファイル、及び kinit コマンドについての詳細は章19章 を参照してください。
Active Directory サーバ (windows1.example.com) に参加するには、メンバーサーバで root として次のコマンドを入力します。
root# net ads join -S windows1.example.com -U administrator%password |
マシン windows1 は自動的に該当 Kerberos で見つかったので (kinit コマンドの成功)、net コマンドが必要される管理者アカウントとパスワードを使って Active Directory に接続します。これにより Active Directory 上に適切なマシンアカウントが作成され、Samba ドメインメンバーサーバがそのドメインに参加する許可を与えます。
![]() | 注記 |
---|---|
security = ads が使用され security = user は使用されていないため、smbpasswd などのローカルなパスワードバックエンドは必要ありません。security = adsをサポートしていない旧式のクライアントは security = domain が設定されているように認証されます。この変更は機能に影響せず、ドメインにいなかったローカルユーザーを許可します。 |
次の smb.conf ファイルは Windows NT4 ベースのドメインメンバーサーバの実装に必要な設定の例です。NT4 ベースのドメインのメンバーサーバになるというのは、Active Directory に接続するのに似ています。主な違いは NT4 ベースのドメインはその認証方法に Kerberos を使用しないことです。このため、smb.conf ファイルは簡潔になります。この例では、Samba メンバーサーバは NT4 ベースのドメインサーバへ通じるパスの役割を果たします。
[global] workgroup = DOCS netbios name = DOCS_SRV security = domain [homes] comment = Home Directories valid users = %S read only = No browseable = No [public] comment = Data path = /export force user = docsbot force group = users guest ok = Yes |
Samba をドメインメンバーサーバにするとさまざまな状況で役に立ちます。 Samba サーバはファイルやプリンタ共有の他にも別な用途で使用できる機会があります。ドメイン環境で Linux のみ対応のアプリケーションを使用する必要がある場合などに Samba をドメインメンバーサーバにすると便利なことがあります。管理者は Windows ベースではなくてもドメイン内のマシンすべてを追跡しておく 傾向にあります。Windows ベースのサーバハードウェアが廃止になった場合、smb.conf ファイルを変更してサーバを Samba ベースの PDC に非常に簡単に転向することができます。Windows NT ベースのサーバが Windows 2000/2003 にアップグレードされる場合、必要であれば Active Directory へのインフラストラクチャ変更を統合するのにsmb.conf ファイルを簡単に変更することができます。
![]() | 重要 | |
---|---|---|
smb.conf ファイルを設定したら、ドメインに参加し、その後、次のコマンドを root で入力して Samba を起動します。
|
ドメインサーバのホスト名を指定する -S オプションは net rpc join コマンドに指定する必要はありませんので注意してください。Samba は smb.conf ファイルにある workgroup ディレクティブで指定されるホスト名を使用するので明示的には記述しません。
Windows NT のドメインコントローラは機能的に Linux 環境の Network Information Service (NIS) サーバに似ています。ドメインコントローラと NIS サーバはいずれもユーザー/グループ情報のデータベース及び関連サービスをホストします。ドメインコントローラは主にユーザーのドメインリソースへのアクセス認証などセキュリティの目的で使用されます。ユーザー/グループデータベースの整合性を管理するサービスは Security Account Manager (SAM) と呼ばれています。SAM データベースは Windows と Linux Samba ベースのシステムでは保管が異なるため、SAM の複製は作成できず、PDC/BDC 環境でプラットフォームは混在できません。
Samba 環境では、PDC は 1 台のみ、BDC はいくつでも置くことができます。
![]() | 重要 |
---|---|
Samba は Samba/Windows 混在のドメインコントローラ環境では存在できません(Samba は Windows PDC の BDC にはなれず、その逆もできません)。これに対し、Samba PDC と BDC は共存することができます。 |
一番簡単で一般的な Samba PDC の実装は tdbsam パスワードデータベースのバックエンドを使用します。古い smbpasswd バックエンドを交換する予定があるなら、tdbsam は数多くの改良が加えられていますので、詳細は項14.5をご覧ください。passdb backend ディレクティブは PDC にどのバックエンドを使用するかを管理します。
[global] workgroup = DOCS netbios name = DOCS_SRV passdb backend = tdbsam security = user add user script = /usr/sbin/useradd -m %u delete user script = /usr/sbin/userdel -r %u add group script = /usr/sbin/groupadd %g delete group script = /usr/sbin/groupdel %g add user to group script = /usr/sbin/usermod -G %g %u add machine script = \ /usr/sbin/useradd -s /bin/false -d /dev/null \ -g machines %u # The following specifies the default logon script # Per user logon scripts can be specified in the user # account using pdbedit logon script = logon.bat # This sets the default profile path. # Set per user paths with pdbedit logon path = \\%L\Profiles\%U logon drive = H: logon home = \\%L\%U domain logons = Yes os level = 35 preferred master = Yes domain master = Yes idmap uid = 15000-20000 idmap gid = 15000-20000 [homes] comment = Home Directories valid users = %S read only = No browseable = No writable = Yes [public] comment = Data path = /export force user = docsbot force group = users guest ok = Yes [netlogon] comment = Network Logon Service path = /var/lib/samba/netlogon/scripts admin users = ed, john, sam guest ok = No browseable = No writable = No # For profiles to work, create a user directory under the # path shown. mkdir -p /var/lib/samba/profiles/john [Profiles] comment = Roaming Profile Share path = /var/lib/samba/profiles read only = No browseable = No guest ok = Yes profile acls = Yes # Other resource shares ... ... |
![]() | 注記 |
---|---|
ドメインコントローラが複数台またはユーザー数が250以上必要な場合、tdbsam 認証バックエンドは使用しないでください。このような場合は LDAP をお勧めします。 |
最もパワフルで用途の広い Samba PDC の実装は LDAP パスワードバックエンドを使用できる機能があります。LDAP は非常にスケーラブルで、LDAP データベースサーバは冗長に使用することができ、Samba BDC に複製させてフェールオーバーできます。LDAP PDC と BDC のグループに負荷分散させるのが企業環境では理想的です。一方、LDAP の設定は本質的にセットアップや管理が複雑です。SSL を LDAP に統合するとさらに設定は複雑になります。複雑とは言え、十分に注意して厳密に計画を立てれば、LDAP は企業環境に理想的なソリューションとなります。
passdb backend ディレクティブ及び特定の LDAP サフィックス指定に注意してください。LDAP の Samba 設定はシンプルですが、OpenLDAP のインストールは容易ではありません。LDAP をインストールし設定してから Samba の設定を行います。また、Samba と LDAP を機能させるために同じサーバに置く必要はありません。企業環境では、この2つを別々にすることをお勧めします。
[global] workgroup = DOCS netbios name = DOCS_SRV passdb backend = ldapsam:ldap://ldap.example.com username map = /etc/samba/smbusers security = user add user script = /usr/sbin/useradd -m %u delete user script = /usr/sbin/userdel -r %u add group script = /usr/sbin/groupadd %g delete group script = /usr/sbin/groupdel %g add user to group script = /usr/sbin/usermod -G %g %u add machine script = \ /usr/sbin/useradd -s /bin/false -d /dev/null \ -g machines %u # The following specifies the default logon script # Per user logon scripts can be specified in the # user account using pdbedit logon script = scripts\logon.bat # This sets the default profile path. # Set per user paths with pdbedit logon path = \\%L\Profiles\%U logon drive = H: logon home = \\%L\%U domain logons = Yes os level = 35 preferred master = Yes domain master = Yes ldap suffix = dc=example,dc=com ldap machine suffix = ou=People ldap user suffix = ou=People ldap group suffix = ou=Group ldap idmap suffix = ou=People ldap admin dn = cn=Manager ldap ssl = no ldap passwd sync = yes idmap uid = 15000-20000 idmap gid = 15000-20000 ... # Other resource shares ... ... |
![]() | 注記 |
---|---|
この smb.conf ファイルでの LDAP 実装は、稼働中の LDAP サーバが ldap.example.com に正しくインストールされていると仮定しています。 |
BDC は企業仕様の Samba/LDAP ソリューションには欠くことのできない部分です。PDC と BDC 間の smb.conf ファイルは実質的に domain master ディレクティブ以外は同一になります。PDC の値が Yes で、BDC の値は No になっていることを確認してください。PDC の BDC が複数ある場合、os level ディレクティブがBDC 選択プライオリティを設定するのに役に立ちます。値を高くすると、接続クライアントのサーバプライオリティが高くなります。
![]() | 注記 |
---|---|
BDC は PDC の LDAP データベースか自身の LDAP データベースいずれかを使用できます。この例では、passdb backend ディレクティブでわかるように PDC の LDAPデータベース を使用しています。 |
[global] workgroup = DOCS netbios name = DOCS_SRV2 passdb backend = ldapsam:ldap://ldap.example.com username map = /etc/samba/smbusers security = user add user script = /usr/sbin/useradd -m %u delete user script = /usr/sbin/userdel -r %u add group script = /usr/sbin/groupadd %g delete group script = /usr/sbin/groupdel %g add user to group script = /usr/sbin/usermod -G %g %u add machine script = \ /usr/sbin/useradd -s /bin/false -d /dev/null \ -g machines %u # The following specifies the default logon script # Per user logon scripts can be specified in the # user account using pdbedit logon script = scripts\logon.bat # This sets the default profile path. # Set per user paths with pdbedit logon path = \\%L\Profiles\%U logon drive = H: logon home = \\%L\%U domain logons = Yes os level = 35 preferred master = Yes domain master = No ldap suffix = dc=example,dc=com ldap machine suffix = ou=People ldap user suffix = ou=People ldap group suffix = ou=Group ldap idmap suffix = ou=People ldap admin dn = cn=Manager ldap ssl = no ldap passwd sync = yes idmap uid = 15000-20000 idmap gid = 15000-20000 ... # Other resource shares ... ... |