「Sambaをドメインメンバーとして設定」の版間の差分
103行目: | 103行目: | ||
}} | }} | ||
= | = Sambaを設定 = | ||
== Setting up a Basic <code>smb.conf</code> File == | == Setting up a Basic <code>smb.conf</code> File == | ||
241行目: | 241行目: | ||
For further details, see <code>username map</code> parameter in the <code>smb.conf(5)</code> man page. | For further details, see <code>username map</code> parameter in the <code>smb.conf(5)</code> man page. | ||
= Joining the Domain = | = Joining the Domain = |
2019年2月28日 (木) 18:40時点における版
はじめに
Sambaドメインメンバーは、Sambaを実行していて、なおかつNT4のプライマリドメインコントローラ(PDC)や、あるいはActive Directory(AD)ドメインコントローラ(DC)のようなドメインサービスを提供することのない、ドメインに参加しているLinuxマシンです。
Sambaドメインメンバーでは次の事ができます:
- ファイルとディレクトリのローカルアクセス制御リストでユーザとグループを使用します。
- ファイルサーバーとして機能するように共有を設定します。
- プリントサーバーとして機能するように印刷サービスを設定します。
- ドメインユーザーがローカルにログオンできるように、あるいは、ローカルにインストールされているサービスに対して認証できるようにPAMを設定します。
Samba NT4 ドメイン、あるいはSamba ADをセットアップすることについては、ドメインコントロールを見てください。
{{#invoke:Message box|imbox}}
インストールの準備
一般的な準備
- Sambaプロセスが一つも動作していないことを確認:
# ps ax | egrep "samba|smbd|nmbd|winbindd"
- もし、
samba
、smbd
、nmbd
や、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のインストール を参照してください。
{{#invoke:Message box|imbox}}
Sambaを設定
Setting up a Basic smb.conf
File
When Setting up smb.conf on a Unix domain member, you will need to make a few decisions.
- Do you require users and groups to have the same IDs everywhere, including Samba AD DCs ?
- Do you only want your users and groups to have the same IDs on Unix domain members ?
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 ?
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.
{{#invoke:Message box|imbox}}
{{#invoke:Message box|imbox}}
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. If you use the 'rid' backend you do not need to add anything to AD and in fact, any RFC2307 attributes will be ignored. 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. By default on a Unix domain member, there are multiple blocks of users & groups:
- The local system users & groups: These will be from 0-999
- The local Unix users and groups: These start at 1000
- The 'well Known SIDs': ????
- 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: ????
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)
- {{#invoke:Message box|imbox}}
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.
{{#invoke:Message box|imbox}}
To map the domain administrator to the local root
account:
- Add the following parameter to the
[global]
section of yoursmb.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
- {{#invoke:Message box|imbox}}
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.
{{#invoke:Message box|imbox}}
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.
- Keep the
- Do not add the
winbind
entry to the NSSshadow
database. This can cause thewbinfo
utility fail.
- Do not add the
- {{#invoke:Message box|imbox}}
- {{#invoke:Message box|imbox}}
Starting the Services
Start the following services to have a fully functioning Unix domain member:
- The
smbd
service
- The
nmbd
service
- The
winbindd
service
- {{#invoke:Message box|imbox}}
- {{#invoke:Message box|imbox}}
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:
- File shares to act as a file server. For details, see Samba File Serving.
- Print services to act as a print server. For details, see Print Server Support.
- PAM authentication of domain users for local services. For details, see Authenticating Domain Users Using PAM.
Troubleshooting
For details, see Troubleshooting Samba Domain Members.