winbindによるメンバーサーバを作ってみる。
内容はsssdによるメンバーサーバ作成と同じです。連携方法がwinbinddにした場合のお話
winbindによるメンバーサーバ作成だからと言って特別なことはない.
ホスト名 | IPアドレス | OS | 参照DNS | 参照NTP |
samba-winbind.chaperone.jp | 192.168.0.152 | RockyLinux8.5 | ad.chaperone.jp | ad.chaperone.jp |
/etc/hostsファイルは、自身のアドレスのみで可
[root@samba-winbind ~]# hostnamectl set-hostname samba-winbind.chaperone.jp
[root@samba-winbind ~]# echo `hostname -I` `hostname -A` `hostname -s` >> /etc/hosts
[root@samba-winbind ~]# echo "192.168.0.131 ad.chaperone.jp ad" >> /etc/hosts
[root@samba-winbind ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.0.152 samba-winbind.chaperone.jp samba-winbind
192.168.0.131 ad.chaperone.jp ad
[root@samba-winbind ~]# echo "pool ad iburst" > /etc/chrony.conf
そしてドメイン参加に必要なパッケージをインストールする
[root@samba-winbind ~]# dnf install samba-common samba-winbind
ドメインコントローラの CHAPERONE\Domain Users にGIDを付与します。これがないとどうも無理みたい。
付与の方法はwindowsのツールを使います. samba/RSATの「ADSIエディター」を起動させ、画面左上の「ADSIエディター」ノードを右クリックして、「接続...」を選択します
その後、現れた「接続の設定」パネルではそのまま「OK」ボタンを押下します
「ADSIエディター」画面の左ツリーを展開して「CN=Users」を選択します
そして右側から「CN=Domain Users」を右クリックして、「プロパティ」を選びます
開いた「CN=Domain Usersのプロパティ」から「gidNumber」をダブルクリックして値を入力します.
gidNumberの値は何でもいいですが、ここでは3000にしてます。
これで「OK」ボタンを押下します.
メンバーサーバの /etc/samba/smb.conf を調整して、
/etc/samba/smb.conf は samba-common パッケージに含まれている
[root@samba-winbind ~]# cat << _EOT_ > /etc/samba/smb.conf
[global]
workgroup = CHAPERONE
security = ADS
realm = CHAPERONE.JP
password server = ad.chaperone.jp
idmap config CHAPERONE:backend = ad
idmap config CHAPERONE:schema_mode = rfc2307
idmap config CHAPERONE:range = 1000-30000
idmap config CHAPERONE:unix_nss_info = yes
idmap config CHAPERONE:unix_primary_group = yes
idmap config *:range = 30001-30010
idmap config *:backend = tdb
#winbind nss info = rfc2307
winbind use default domain = true
_EOT_
[root@samba-winbind ~]#
net コマンドを使って sybyl ドメインに参加します。
[root@samba-winbind ~]# net ads join osName=RockyLinux osVer=8.5 -Uadministrator
Enter administrator's password:
Using short domain name -- CHAPERONE
Joined 'SAMBA-WINBIND' to dns domain 'chaperone.jp'
[root@samba-winbind ~]#
参加完了後、ユーザ情報参照先と認証情報参照先を変更して、winbinddを起動させます。
[root@samba-winbind ~]# authselect create-profile samba-winbind -b winbind --symlink-pam --symlink-dconf
New profile was created at /etc/authselect/custom/samba-winbind
[root@samba-winbind ~]# echo "Enable SAMBA-WINBIND for system authentication" > /etc/authselect/custom/samba-winbind/README
[root@samba-winbind ~]# authselect current
No existing configuration detected.
[root@samba-winbind ~]# authselect list
- minimal Local users only for minimal installations
- nis Enable NIS for system authentication
- sssd Enable SSSD for system authentication (also for local users only)
- winbind Enable winbind for system authentication
- custom/samba-winbind Enable SAMBA-WINBIND for system authentication
[root@samba-winbind ~]# authselect select custom/samba-winbind --force
Backup stored at /var/lib/authselect/backups/2022-05-04-02-13-54.pe5Clq
Profile "custom/samba-winbind" was selected.
The following nsswitch maps are overwritten by the profile:
- passwd
- group
Make sure that winbind service is configured and enabled. See winbind documentation for more information.
[root@samba-winbind ~]# authselect current
Profile ID: custom/samba-winbind
Enabled features: None
[root@samba-winbind ~]# systemctl enable winbind --now
そしてテスト。「getent passwd | grep illya」では表示されません。「getent passwd illya」でないと表示されない
[root@samba-winbind ~]# id illya
uid=1002(illya) gid=2000(fate) groups=2000(fate),3000(domain users)
[root@samba-winbind ~]# getent passwd illya
illya:*:1002:2000:Illyasviel von Einzbern:/home/illya:/bin/bash
[root@samba-winbind ~]#
留意 事前にドメインコントローラの CHAPERONE\Domain Users にGIDを割り当てることが必須みたい.
ipmadのbackendにadをここでは使っているが、
仮に別のbackend、例えば rid らを使った際、ユーザのUID、GIDはそのマシンでのみ有効でADDCのUID,GIDとは異なる。
一度ridらを使うとそれが残ってしまい、backendをadに切り替えてもUID,GIDは更新されない。
それをクリアにするためには下記を実行する
[root@c ~]# systemctl stop winbind *あるいはsystemctl stop samba
[root@c ~]# net cache flush
[root@c ~]# rm -f /var/lib/samba/*.tdb
[root@c ~]# rm -f /var/lib/samba/group_mapping.ldb
[root@c ~]# systemctl start winbind