SSSD:如何強制不同群組的使用者使用不同的shell

SSSD:如何強制不同群組的使用者使用不同的shell

我有一個 Active Directory,使用 sssd 作為我的 CentOS 7 伺服器的 ID、存取和身份驗證提供者。我一直在關注這個郵政為了讓不同群組的使用者在登入時使用不同的 shell,但我遇到了一些問題。這是我的sssd.conf文件:

[sssd]
domains = dev, domain.local
config_file_version = 2
services = nss, pam

[nss]
default_shell = /bin/bash

[domain/dev]
ad_domain = domain.local
krb5_realm = DOMAIN.LOCAL
ad_server = adserver.domain.local
id_provider = ad
access_provider = ad
ldap_id_mapping = True
use_fully_qualified_names = False
fallback_homedir = /home/%u
override_shell = /bin/tcsh
ldap_user_search_base = cn=dev,ou=Security Groups,ou=Domain,dc=domain,dc=local #According to sssd-ldap man page ldap_user_search_filter is deprecated


[domain/domain.local]
ad_server = adserver.domain.local
ad_domain = domain.local
krb5_realm = DOMAIN.LOCAL
realmd_tags = manages-system joined-with-adcli
cache_credentials = True
id_provider = ad
krb5_store_password_if_offline = True
default_shell = /bin/bash
ldap_id_mapping = True
use_fully_qualified_names = False
fallback_homedir = /home/%u
access_provider = ad


這個想法是,當開發組的某人登入時,shell 將是 tcsh,而當其他人登入時,它會使用 bash。問題是,透過這個conf,我可以使用開發組成員史密斯成功登錄,並且成功登入 tcsh,但是如果我使用也是網域成員但不是開發組成員的約翰登錄,則會發生以下情況:

  • 回顧一下,/var/log/secure我首先從 pam_unix 獲得身份驗證失敗,然後從 pam_sss 獲得成功
  • 第一個使用者登入為並john取得其 shell 為 tcsh(即使它應該是 bash)。[email protected]第三,使用者再次登錄,john現在它獲得了正確的 shell (bash)

顯然,sssd 在使用 FQDN 檢查第二個網域後,它會快取使用者 shell,並且在第三次登入時它會正確執行。
為了讓每個使用者登入其對應的 shell,哪個配置是正確的?

更新
看起來有時登入過程僅透過 pam 模組,有時透過從活動目錄取得的基於 sssd GPO 的策略。我嘗試禁用過濾器並重新啟動 sssd 幾次,其中一次我在日誌中得到了這些:

Aug 28 15:42:43 co-proy-02 sssd[be[dev.domain.local]]: Warning: user would have been denied GPO-based logon access if the ad_gpo_access_control option were set to enforcing mode.

Smith透過停用過濾器,群組中的使用者dev可以成功取得 tcsh,但也可以獲得john.啟用過濾器後,兩者都會得到 bash。

更新2
顯然有一個名為 的包sssd-tools,其中有一個命令可以讓您覆蓋任何單獨用戶的 shell,但是,在嘗試此解決方案後,我仍然沒有得到適當的結果。這是命令,但至少對我來說,它沒有按預期工作:
sss_override user-add smith -s /usr/bin/sh

答案1

經過長時間的搜索,並在 @ChristopheDrevet-Droguet 的幫助下以過濾器ou=Domain,dc=domain,dc=local?subtree?(memberOf=cn=dev,ou=Security Groups,ou=Domain,dc=domain,dc=local)為基礎,唯一缺少的是要解析的對象樹,我的意思是,可以在其中找到用戶。
sssd 應該如下所示才能使其工作(至少對我來說):

[sssd]
domains = dev, domain.local
config_file_version = 2
services = nss, pam

[nss]
default_shell = /bin/bash

[domain/dev]
ad_domain = domain.local
krb5_realm = DOMAIN.LOCAL
ad_server = adserver.domain.local
id_provider = ad
access_provider = ad
ldap_id_mapping = True
use_fully_qualified_names = False
fallback_homedir = /home/%u
override_shell = /bin/tcsh
ldap_user_search_base = dc=domain,dc=local??(&(memberOf=cn=dev,ou=Security Groups,ou=Domain,dc=veritran,dc=local)(objectClass=*))


[domain/domain.local]
ad_server = adserver.domain.local
ad_domain = domain.local
krb5_realm = DOMAIN.LOCAL
realmd_tags = manages-system joined-with-adcli
cache_credentials = True
id_provider = ad
krb5_store_password_if_offline = True
default_shell = /bin/bash
ldap_id_mapping = True
use_fully_qualified_names = False
fallback_homedir = /home/%u
access_provider = ad
ldap_user_search_base = dc=domain,dc=local??(&(memberOf=cn=other,ou=Security Groups,ou=Domain,dc=veritran,dc=local)(objectClass=*))

相關內容