「Sambaをドメインメンバーとして設定」の版間の差分

提供: 雑廉堂Wiki
(Configuring Samba)
(Setting up a Basic smb.conf File)
107行目: 107行目:
 
== Setting up a Basic <code>smb.conf</code> File ==
 
== Setting up a Basic <code>smb.conf</code> File ==
  
When Setting up smb.conf on a Unix domain member, you will need to make a few decisions.  
+
Unixドメインメンバー上でsmb.confを設定するとき、あなたは何点か決めておく必要があります。
  
* Do you require users and groups to have the same IDs everywhere, including Samba AD DCs ?
+
* Samba AD DCを含め、すべての場所でユーザーとグループが同じIDを持つ必要がありますか?
* Do you only want your users and groups to have the same IDs on Unix domain members ?
+
* あなたのユーザとグループだけがUnixドメインメンバー上で同じIDを持ちたいですか?
 
   
 
   
After making your decision, you will have another decision to make, this decision could affect what you think you have already decided.
+
あなたの決断をした後、あなたは決断をするための別の決断をするでしょう。この決断はあなたがすでに決断したと思うことに影響を与えるかもしれません。
* Do you want or need individual users to have different login shells and/or Unix home directory paths ?
+
* 個々のユーザに異なるログインシェルやUnixホームディレクトリパスを持たせたい、または必要としますか
  
If you need your users to have different login shells and/or Unix home directory paths, or you want them to have the same ID everywhere, you will need to use the winbind 'ad' backend and add RFC2307 attributes to AD.
+
ユーザに異なるログインシェルやUnixホームディレクトリパスを持たせる必要がある場合、またはどこでも同じIDを持つようにしたい場合は、winbindの 'ad'バックエンドを使用してADにRFC2307属性を追加する必要があります。
  
 
{{Imbox
 
{{Imbox
| type = note
+
| type = notice
| text = The RFC2307 attributes are not added automatically when users or groups are created.
+
| text = ユーザーまたはグループが作成されても、RFC 2307属性は自動的には追加されません。
 
}}
 
}}
  
  
 
{{Imbox
 
{{Imbox
| type = important
+
| type = content
| text = The ID numbers found on a DC (numbers in the 3000000 range) are NOT rfc2307 attributes They cannot and will not be used on Unix Domain Members, if you want to have the same ID numbers everywhere, you must add uidNumber & gidNumber attributes to AD and use the winbind 'ad' backend on Unix Domain Members. If you do decide to add uidNumber & gidNumber attributes to AD, you do not need to use numbers in the 3000000 range and in fact it would definitely be a good idea to use a different range.
+
| text = DCにあるID番号(3000000番台の番号)は、rfc2307属性ではありません。Unixのドメインメンバーでは使えません。どこでも同じID番号を使用したい場合は、ADにuidNumberとgidNumber属性を追加して、Unixドメインメンバ上でwinbindの'ad'バックエンドを使用しなくてはいけません。ADにuidNumberとgidNumber属性を追加することにした場合は、3000000番台の番号を使う必要はなく、実際には違う範囲の番号を使用することは、明らかに良い考えです。
 
}}
 
}}
  
 +
ユーザーが認証のためだけにSamba AD DCを使用し、データを保存したり、ログインしたりしない場合、winbindの 'rid' バックエンドを使用することが出来ます。これは、ユーザーとグループのIDをWindows RIDから算出し、すべてのUnixドメインメンバーのsmb.confで、同じ[global]セクションを使用すれば、同じIDを取得することができます。
 +
'rid'バックエンドを使うのであれば、ADに何か追加する必要はありません。実際、RFC2307の属性はすべて無視されます。
 +
'rid'バックエンドを使用するときは、smb.confで 'template shell'と 'template homedir'パラメータを設定しなければなりません。これらはグローバル設定で、個々にホームディレクトリとシェルを設定できる、RFC2307属性とは異なって、全員が同じログインシェルとUnixホームディレクトリパスを取得します。
  
 +
別にもう一つ、Sambaを設定する方法があります。これは、ユーザーとグループがどこでも同じIDを持たせたいが、同じログインシェルとUnixホームディレクトリパスを使用することのみ必要とするところです。これを行うには、winbindの 'ad'バックエンドを使用し、smb.confのテンプレート行を使用します。これにより、uidNumberおよびgidNumbers属性をADに追加するだけで済みます。
  
If your users will only use the Samba AD DC for authentication and will not store data on it or log into it, you can use the the winbind 'rid' backend, this calculates the user and group IDs from the Windows RID, if you use the same [global] section of the smb.conf on every Unix domain member, you will get the same IDs.
+
どちらのwinbindバックエンドを使うか決めたら、smb.confの 'idmap config'で使用する範囲を決めます。
If you use the 'rid' backend you do not need to add anything to AD and in fact, any RFC2307 attributes will be ignored.
+
Unixドメインメンバーのデフォルトでは、ユーザーとグループのブロックは複数あります:
When using the 'rid' backend you must set the 'template shell' and 'template homedir' parameters in smb.conf, these are global settings and everyone gets the same login shell and Unix home directory path, unlike the RFC2307 attributes where you can set individual Unix home directory paths and shells.
 
 
There is another way of setting up Samba, this is where you require your users and groups to have the same ID everywhere, but only need your users to have the same login shell and use the same Unix home directory path. You can do this by using the winbind 'ad' backend and using the template lines in smb.conf. This way you only have to add uidNumber & gidNumbers attributes to AD.
 
  
Having decided which winbind backend to use, you now have a further decision to make, the ranges to use with 'idmap config' in smb.conf.
+
* ローカルシステムのユーザーとグループ:これらは0から999までとなります
By default on a Unix domain member, there are multiple blocks of users & groups:
+
* ローカルのUnixユーザーとグループ:    これらは1000から始まります
 
+
* 既知のSID:                          ????
* The local system users & groups: These will be from 0-999
+
* ドメインユーザーとグループ:          ADUCでは、デフォルト10000から開始します
* The local Unix users and groups: These start at 1000
+
* 信頼されるドメイン:                  ????
* The 'well Known SIDs':          ????
+
* 既知のSID、DOMAINのメンバー、信頼できるドメイン以外のものは何でも:????
* The DOMAIN users and groups:    ADUC, by default, starts these at 10000
 
* Trusted domains:                ????
 
* Anything that isn't a 'well Known SID' or a member of DOMAIN or a trusted domain: ????
 
  
  
187行目: 185行目:
 
  # smbd  -b | grep CONFIGFILE
 
  # smbd  -b | grep CONFIGFILE
 
   CONFIGFILE: /usr/local/samba/etc/smb.conf
 
   CONFIGFILE: /usr/local/samba/etc/smb.conf
 
  
 
== Choose backend for id mapping in winbindd ==
 
== Choose backend for id mapping in winbindd ==

2019年2月28日 (木) 20:34時点における版

はじめに

Sambaドメインメンバーは、Sambaを実行していて、なおかつNT4のプライマリドメインコントローラ(PDC)や、あるいはActive Directory(AD)ドメインコントローラ(DC)のようなドメインサービスを提供することのない、ドメインに参加しているLinuxマシンです。

Sambaドメインメンバーでは次の事ができます:

  • ファイルとディレクトリのローカルアクセス制御リストでユーザとグループを使用します。
  • ファイルサーバーとして機能するように共有を設定します。
  • プリントサーバーとして機能するように印刷サービスを設定します。
  • ドメインユーザーがローカルにログオンできるように、あるいは、ローカルにインストールされているサービスに対して認証できるようにPAMを設定します。

Samba NT4 ドメイン、あるいはSamba ADをセットアップすることについては、ドメインコントロールを見てください。


インストールの準備

一般的な準備

  • Sambaプロセスが一つも動作していないことを確認:
# ps ax | egrep "samba|smbd|nmbd|winbindd"
もし、sambasmbdnmbdや、winbinddのようなプロセスが表示されるのであれば、それらのプロセスを停止させてください。
  • もし、以前にこのホスト上でSambaのインストールを実行したのであれば:
  • smb.confを削除してください。ファイルへのパスを表示させるには、次のように入力:
# smbd -b | grep "CONFIGFILE"
   CONFIGFILE: /usr/local/samba/etc/samba/smb.conf
  • *.tdbと、*.ldbファイルのような、Sambaデータベースファイルを削除してください。Sambaデータベースのあるフォルダを表示させるには:
# smbd -b | egrep "LOCKDIR|STATEDIR|CACHEDIR|PRIVATE_DIR"
  LOCKDIR: /usr/local/samba/var/lock/
  STATEDIR: /usr/local/samba/var/locks/
  CACHEDIR: /usr/local/samba/var/cache/
  PRIVATE_DIR: /usr/local/samba/private/
クリーンな環境からスタートするのは、混乱を防ぐのに役立ちますし、また、以前のSambaのインストールからのどのファイルも、新たなドメインメンバーのインストールと混在することはありません。


ActiveDirectoryドメインに参加するドメインメンバーの準備

DNSの設定

Active Directory(AD)はバックグラウンドでDNSを使用して、Kerberosなどの他のDCおよびサービスを見つけます。 したがって、ADドメインメンバーとサーバーはAD DNSゾーンを解決できなければなりません。

以下に、DNSサーバーを使用するようにLinuxクライアントを手動で構成する方法を説明します。 クライアントコンピュータにDNS設定を提供するDHCPサーバーを実行している場合は、DNSサーバーのIPアドレスを送信するようにDHCPサーバーを構成します。

/etc/resolv.conf の設定

/etc/resolv.conf にDNSサーバーのIPアドレスとAD DNSドメインを設定します。 例えば:

nameserver 10.99.0.1
search samdom.example.com

NetworkManagerなどの一部のユーティリティは、そのファイルの手動で変更した内容を上書きすることがあります。 永続的に名前解決を設定する方法については、ディストリビューションのドキュメントを参照してください。

DNSの名前解決をテスト

DNS設定が正しく、クライアントまたはサーバーがIPアドレスとホスト名を解決できることを確認するには、 nslookup コマンドを使用します。 このコマンドはLinuxとWindowsで利用可能です。



前方参照

ホスト名を、そのIPアドレスに解決するには:

# nslookup DC1.samdom.example.com
Server:         10.99.0.1
Address:        10.99.0.1#53

Name:   DC1.samdom.example.com
Address: 10.99.0.1



後方参照

IPアドレスをそのホスト名に解決するには:

# nslookup 10.99.0.1
Server:        10.99.0.1
Address:	10.99.0.1#53

1.0.99.10.in-addr.arpa	name = DC1.samdom.example.com.

Samba ADでは、リバースゾーンは自動的には設定されません。 逆ゾーンを設定するには、DNSの管理を参照してください。



SRVレコードの解決

Active Directory(AD)はSRVレコードを使用してKerberosやLDAPなどのサービスを見つけます。 SRVレコードが正しく解決されたことを確認するには、 nslookup インタラクティブシェルを使用します:

# nslookup
Default Server:  10.99.0.1
Address:  10.99.0.1

> set type=SRV
> _ldap._tcp.samdom.example.com.
Server:  UnKnown
Address:  10.99.0.1

_ldap._tcp.samdom.example.com   SRV service location:
          priority       = 0
          weight         = 100
          port           = 389
          svr hostname   = dc1.samdom.example.com
samdom.example.com      nameserver = dc1.samdom.example.com
dc1.samdom.example.com  internet address = 10.99.0.1

エラーメッセージ

  • DNSサーバーはホスト名を解決できません:
** server can't find DC1.samdom.example.com: NXDOMAIN
  • DNSサーバーはIPアドレスを解決できません:
** server can't find 1.0.99.10.in-addr.arpa: NXDOMAIN
  • 使用されているDNSサーバーが利用できません:
;; connection timed out; no servers could be reached




Configuring Kerberos

SambaはHeimdalとMIT Kerberosのバックエンドをサポートしています。 ドメインメンバーにKerberosを設定するには、 /etc/krb5.conf ファイルに次のように設定します。

[libdefaults]
	default_realm = SAMDOM.EXAMPLE.COM
	dns_lookup_realm = false
	dns_lookup_kdc = true

前の例では、 SAMDOM.EXAMPLE.COM レルムにKerberosを設定しています。

Sambaチームは、 /etc/krb5.conf ファイルにこれ以上パラメータを設定しないことをお勧めします。

/etc/krb5.conf include 行が含まれていても機能しません。この行を削除する必要があります。

時刻の同期の設定

Kerberosでは、すべてのドメインメンバで時刻の同期が必要です。 したがって、NTPクライアントを設定することをお勧めします。 詳細については、 Unixドメインメンバーでの時刻同期の設定を参照してください。

ローカルホストの名前解決

ホストをドメインに参加させると、SambaはAD DNSゾーンにホスト名を登録しようとします。 これを行うには、 net ユーティリティがDNSを使用するか /etc/hosts ファイルの正しいエントリを使用してホスト名を解決できる必要があります。

ホスト名が正しく解決されたことを確認するには、 getent hosts コマンドを使用してください。 例えば:

# getent hosts M1
10.99.0.5      M1.samdom.example.com    M1

ホスト名とFQDNは、 127.0.0.1 IPアドレス、またはドメインメンバーのLANインターフェースで使用されているもの以外のIPアドレスに解決されてはなりません。

出力が表示されない、またはホストが間違ったIPアドレスに解決され、dhcpを使用していない場合は、 / etc / hosts ファイルに正しいエントリを設定してください。 例えば:

127.0.0.1      localhost
10.99.0.5      M1.samdom.example.com    M1

dhcpを使用している場合は、 / etc/hosts に上記の '127.0.0.1'行のみが含まれていることを確認してください。 問題が解決しない場合は、DHCPサーバーを管理しているシステム管理者に連絡してください。

  • Debian関連システムでは、/etc/hostsに 127.0.1.1 hostname という行も表示されますので、sambaをインストールする前に削除してください。
  • 127.0.0.1 localhost の行を残してください。

マシンのホスト名にエイリアスを追加する必要がある場合は、127.0.0.1の行ではなく、マシンのipaddressで始まる行の末尾に追加してください。

NT4ドメインに参加するためのドメインメンバーの準備

ホストをNT4ドメインに参加させるには、準備は必要ありません。

Sambaのインストール

詳細については、 Sambaのインストール を参照してください。

Sambaを設定

Setting up a Basic smb.conf File

Unixドメインメンバー上でsmb.confを設定するとき、あなたは何点か決めておく必要があります。

  • Samba AD DCを含め、すべての場所でユーザーとグループが同じIDを持つ必要がありますか?
  • あなたのユーザとグループだけがUnixドメインメンバー上で同じIDを持ちたいですか?

あなたの決断をした後、あなたは決断をするための別の決断をするでしょう。この決断はあなたがすでに決断したと思うことに影響を与えるかもしれません。

  • 個々のユーザに異なるログインシェルやUnixホームディレクトリパスを持たせたい、または必要としますか

ユーザに異なるログインシェルやUnixホームディレクトリパスを持たせる必要がある場合、またはどこでも同じIDを持つようにしたい場合は、winbindの 'ad'バックエンドを使用してADにRFC2307属性を追加する必要があります。


ユーザーが認証のためだけにSamba AD DCを使用し、データを保存したり、ログインしたりしない場合、winbindの 'rid' バックエンドを使用することが出来ます。これは、ユーザーとグループのIDをWindows RIDから算出し、すべてのUnixドメインメンバーのsmb.confで、同じ[global]セクションを使用すれば、同じIDを取得することができます。 'rid'バックエンドを使うのであれば、ADに何か追加する必要はありません。実際、RFC2307の属性はすべて無視されます。 'rid'バックエンドを使用するときは、smb.confで 'template shell'と 'template homedir'パラメータを設定しなければなりません。これらはグローバル設定で、個々にホームディレクトリとシェルを設定できる、RFC2307属性とは異なって、全員が同じログインシェルとUnixホームディレクトリパスを取得します。

別にもう一つ、Sambaを設定する方法があります。これは、ユーザーとグループがどこでも同じIDを持たせたいが、同じログインシェルとUnixホームディレクトリパスを使用することのみ必要とするところです。これを行うには、winbindの 'ad'バックエンドを使用し、smb.confのテンプレート行を使用します。これにより、uidNumberおよびgidNumbers属性をADに追加するだけで済みます。

どちらのwinbindバックエンドを使うか決めたら、smb.confの 'idmap config'で使用する範囲を決めます。 Unixドメインメンバーのデフォルトでは、ユーザーとグループのブロックは複数あります:

  • ローカルシステムのユーザーとグループ:これらは0から999までとなります
  • ローカルのUnixユーザーとグループ: これらは1000から始まります
  • 既知のSID: ????
  • ドメインユーザーとグループ: ADUCでは、デフォルト10000から開始します
  • 信頼されるドメイン: ????
  • 既知のSID、DOMAINのメンバー、信頼できるドメイン以外のものは何でも:????


As you can see from the above, you shouldn't set either the '*' or 'DOMAIN' ranges to start at 999 or less, as they would interfere with the local system users & groups. You also should leave a space for any local Unix users & groups, so starting the 'idmap config' ranges at 3000 seems to be a good compromise.

You need to decide how large your 'DOMAIN' is likely to grow to and you also need to know if you have any trusted domains or if you may need to have any in future.

Bearing the above information in mind, you could set the 'idmap config' ranges to the following:

Domain Range
* 3000-7999
DOMAIN 10000-999999

You could also have any trusted domains starting at:

Domain Range
TRUSTED 1000000-9999999

If you set the '*' range above the 'DOMAIN' range, the ranges will conflict if the 'Domain' grows to the point that the next ID would be the same as the '*' range start ID.

With the above suggested ranges, no range will overlap or interfere with another.

You may also have seen examples of the '*' range being used for everything, this is not recommended and should not be used.


Before joining the domain, configure the domain member's smb.conf file:

  • To locate the file, enter:
# smbd  -b | grep CONFIGFILE
  CONFIGFILE: /usr/local/samba/etc/smb.conf

Choose backend for id mapping in winbindd

After reading this wikipage, click on one of the following hyperlinks to find information about the relevant Samba domain back end:

Back End Documentation Man Page
ad idmap config ad idmap_ad(8)
rid idmap config rid idmap_rid(8)
autorid idmap config autorid idmap_autorid(8)
This message box is using an invalid "type=important" parameter and needs fixing.

Mapping the Domain Administrator Account to the Local root User

Samba enables you to map domain accounts to a local account. Use this feature to execute file operations on the domain member's file system as a different user than the account that requested the operation on the client.

This message box is using an invalid "type=note" parameter and needs fixing.

To map the domain administrator to the local root account:

  • Add the following parameter to the [global] section of your smb.conf file:
username map = /usr/local/samba/etc/user.map
  • Create the /usr/local/samba/etc/user.map file with the following content:
!root = SAMDOM\Administrator
This message box is using an invalid "type=important" parameter and needs fixing.

For further details, see username map parameter in the smb.conf(5) man page.

Joining the Domain

  • To join the host to an Active Directory (AD), enter:
# net ads join -U administrator
Enter administrator's password: Passw0rd
Using short domain name -- SAMDOM
Joined 'M1' to dns domain 'samdom.example.com'
  • To join the host to an NT4 domain, enter:
# net rpc join -U administrator
Enter administrator's password: Passw0rd
Joined domain SAMDOM.
This message box is using an invalid "type=important" parameter and needs fixing.

If you have problems joining the domain, check your configuration. For further help, see Troubleshooting Samba Domain Members.



Configuring the Name Service Switch

To enable the name service switch (NSS) library to make domain users and groups available to the local system:

  • Append the winbind entry to the following databases in the /etc/nsswitch.conf file:
passwd: files winbind
group:  files winbind
  • Keep the files entry as first source for both databases. This enables NSS to look up domain users and groups from the /etc/passwd and /etc/group files before querying the Winbind service.
  • Do not add the winbind entry to the NSS shadow database. This can cause the wbinfo utility fail.
This message box is using an invalid "type=note" parameter and needs fixing.
This message box is using an invalid "type=note" parameter and needs fixing.




Starting the Services

Start the following services to have a fully functioning Unix domain member:

  • The smbd service
  • The nmbd service
  • The winbindd service


This message box is using an invalid "type=note" parameter and needs fixing.


This message box is using an invalid "type=note" parameter and needs fixing.


Samba does not provide System V init scripts, systemd, upstart, or service files for other init services.

  • If you installed Samba using packages, use the script or service configuration file provided by the package to start Samba.
  • If you built Samba, see your distribution's documentation for how to create a script or configuration to start services.



Testing the Winbindd Connectivity

Sending a Winbindd Ping

To verify if the Winbindd service is able to connect to Active Directory (AD) Domain Controllers (DC) or a primary domain controller (PDC), enter:

# wbinfo --ping-dc
checking the NETLOGON for domain[SAMDOM] dc connection to "DC.SAMDOM.EXAMPLE.COM" succeeded

If the previous command fails, verify:

  • That the winbindd service is running.
  • Your smb.conf file is set up correctly.


Using Domain Accounts and Groups in Operating System Commands

Looking up Domain Users and Groups

The libnss_winbind library enables you to look up domain users and groups. For example:

  • To look up the domain user SAMDOM\demo01:
# getent passwd SAMDOM\\demo01
SAMDOM\demo01:*:10000:10000:demo01:/home/demo01:/bin/bash
  • To look up the domain group Domain Users:
# getent group "SAMDOM\\Domain Users"
SAMDOM\domain users:x:10000:


Assigning File Permissions to Domain Users and Groups

The name service switch (NSS) library enables you to use domain user accounts and groups in commands. For example to set the owner of a file to the demo01 domain user and the group to the Domain Users domain group, enter:

# chown "SAMDOM\\demo01:SAMDOM\\domain users" file.txt



Setting up Additional Services on the Domain Member

On a Samba domain member, you can additionally set up:



Troubleshooting

For details, see Troubleshooting Samba Domain Members.