Samba AD 無法在 Linux 用戶端上登入網域用戶

Samba AD 無法在 Linux 用戶端上登入網域用戶

過去兩週我正在嘗試使用 Samba 作為我的家庭網路中的活動目錄控制器。

我按照一些指南和影片在 ubuntu 伺服器 22.04 上安裝了 samba,但是這一頁涵蓋了大部分內容。我能夠將 Windows 和 Linux 電腦加入網域。我可以使用 列出已加入的電腦samba-tool computer list

我使用 samba 工具成功建立了使用者和群組。我可以從 Windows 用戶端使用這些帳戶登入。

從 linux(ubuntu 23.04 和 23.10)我可以加入網域關注ubuntu官方文檔,但我無法登入。

bp@bas-hp:samba (master) % sudo login                   
bas-hp login: [email protected]
Password: 

Login incorrect
bas-hp login: [email protected]
Password: 

Login incorrect

我能夠創建 kerberos 票證

bp@bas-hp:samba (master) % klist           
Ticket cache: FILE:/tmp/krb5cc_1000
Default principal: [email protected]

Valid starting     Expires            Service principal
16-04-24 22:26:57  17-04-24 08:26:57  krbtgt/[email protected]
    renew until 17-04-24 22:26:53

我嘗試遵循的文檔中的測試部分的結果似乎開始得很好:

bp@legion-ubuntu:~ % getent passwd [email protected]
[email protected]:*:1494001108:1494000513:Bas Prins:/home/[email protected]:/bin/bash
bp@legion-ubuntu:~ % getent passwd [email protected] 
[email protected]:*:1494001104:1494000513:bp:/home/[email protected]:/bin/bash

但是當我發出命令時,groups我確實看到了一些相關的結果

bp@legion-ubuntu:~ % groups [email protected]       
[email protected] : domain [email protected] denied rodc password replication [email protected] [email protected] enterprise [email protected] domain [email protected]
bp@legion-ubuntu:~ % groups [email protected]
[email protected] : domain [email protected] denied rodc password replication [email protected] [email protected] enterprise [email protected] domain [email protected]

當「拒絕 rodc 密碼複製」意味著以及我是否/如何需要解決該問題時,我會同時進行Google搜尋。


完整的 sssd.conf

[sssd]
domains = sb.lan
config_file_version = 2
services = nss, pam

[domain/sb.lan]
default_shell = /bin/bash
krb5_store_password_if_offline = True
cache_credentials = True
krb5_realm = SB.LAN
realmd_tags = manages-system joined-with-adcli
id_provider = ad
fallback_homedir = /home/%u@%d
ad_domain = sb.lan
use_fully_qualified_names = True
ldap_id_mapping = True
access_provider = ad
timeout = 20
ldap_uri = ldap://dc.sb.lan
ldap_search_base = dc=sb,dc=lan
auth_provider = krb5
krb5_server = dc.sb.lan
krb5_passwd = dc.sb.lan
krb5_validate = True

我希望對 samba/AD 有更多了解的人可以給我一些如何最好地解決這個問題的建議。我可以使用哪些工具來深入了解根本原因?

更新2

在 ubuntu 用戶端電腦上的 sssd.conf 中新增以下行後

ad_gpo_access_control = permissive

我終於可以透過命令列登入了sudo login。但是,不幸的是,成功登入後,它嘗試下載我認為的策略,但失敗了。

Last login: Wed Apr 17 14:15:01 CEST 2024 on pts/2
Applying machine settings
ERROR Error from server: error while updating policy: can't get policies for "legion-ubuntu": failed to retrieve the list of GPO (exited with 1): exit status 1
Failed to bind - LDAP client internal error: NT_STATUS_INVALID_PARAMETER
Failed to connect to 'ldap://dc.sb.lan' with backend 'ldap': LDAP client internal error: NT_STATUS_INVALID_PARAMETER
Failed to open session: (1, 'LDAP client internal error: NT_STATUS_INVALID_PARAMETER') 

Failure setting user credentials

我正在同時解決這個問題,當然希望有人能告訴我在哪裡修復什麼;-)。如果我能自己解決這個問題,我會更新問題。

答案1

在我的客戶端 PC 上重新安裝 ubuntu 並再次檢查所有步驟後,我成功解決了該問題。我現在可以登入我的 samba AD 伺服器。

我必須做的兩件事與官方文件有所不同:

  • 加入前修復 krb5.conf
  • 加入後,修補sssd.conf

第一步,我需要在 ubuntu 用戶端上停用 krb5 中的反向 dns。

[libdefaults]
    rdns = false

接下來,成功加入網域後,sudo realm -v join <domain-name>我必須在 ubuntu 用戶端上的 sssd.conf 中新增以下行

# THIS IS MANDATORY to fix "permission denied" when PAM tries to authenticate
# https://serverfault.com/questions/872542/debugging-sssd-login-pam-sss-system->
# suggested work around in question
ad_gpo_access_control = permissive

一旦我這樣做了,並重新啟動 sssd

sudo systemctl restart sssd

我可以登入

bp@legion-ubuntu:~ % sudo login                   
legion-ubuntu.sb.lan login: SB\bp
Password: 
Welcome to Ubuntu 23.04 (GNU/Linux 6.2.0-37-generic x86_64)

不再出現錯誤。當我登出本機使用者時,我終於可以以 AD 使用者身分登入

相關內容