Windows-Server-2008-R2

具有單向信任的 PowerShell 遠端處理

  • February 28, 2021

我的問題類似於Powershell Remoting: One way trust,但是存在差異並且解決方案(將伺服器添加到受信任列表)對我不起作用。

場景:

我有兩個域。DOMAIN 和 DOMAINDMZ。DOMAIN 具有來自 DOMAINDMZ 的傳入信任。也就是說 DOMAINDMZ 信任 DOMAIN,但反之則不然。

我有一個管理使用者DOMAIN\myadmin,他是 DOMAINDMZ 域中多台伺服器上的管理員本地組的成員:servera.domaindmz.comserverb.domaindmz.comserverc.domaindmz.com等。我可以從控制台或 RDP 使用 DOMAIN\myadmin 登錄這些伺服器。

我正在嘗試登錄 SERVERA 並使用 PowerShell 遠端處理在 SERVERB 上執行 PowerShell 腳本。在 SERVERB 上啟用了遠端管理。我在 SERVERA 上啟動提升的 PowerShell 會話,然後嘗試使用Invoke-Commandcmdlet。我收到以下錯誤:

PS C:\Windows\system32> Invoke-Command -ComputerName serverb.domaindmz.com -ScriptBlock {hostname}    
[serverb.domaindmz.com] Connecting to remote server failed with the following error message : WinRM cannot process the request. The following error occured while using Kerberos authentication: The network path was not found.
    Possible causes are:
     -The user name or password specified are invalid.
     -Kerberos is used when no authentication method and no user name are specified.
     -Kerberos accepts domain user names, but not local user names.
     -The Service Principal Name (SPN) for the remote computer name and port does not exist.
     -The client and remote computers are in different domains and there is no trust between the two domains.
    After checking for the above issues, try the following:
     -Check the Event Viewer for events related to authentication.
     -Change the authentication method; add the destination computer to the WinRM TrustedHosts configuration setting or use HTTPS transport.
    Note that computers in the TrustedHosts list might not be authenticated.
      -For more information about WinRM configuration, run the following command: winrm help config. For more information, see the about_Remote_Troubleshooting Help topic.
       + CategoryInfo          : OpenError: (:) [], PSRemotingTransportException
       + FullyQualifiedErrorId : PSSessionStateBroken

如果我在 DOMAINDMZ 域中提供包含使用者的憑據對象,則錯誤消失並且腳本塊按預期執行:

PS C:\Windows\system32> Invoke-Command -ComputerName serverb.domaindmz.com -Credential DOMAINDMZ\Administrator -ScriptBlock {hostname}
SERVERB

問題:

鑑於錯誤,我懷疑該問題與信任和 Kerberos 有關,但我不清楚我能做些什麼來解決。我應該為 DOMAIN\myadmin 還是 SERVERB 設置 SPN?還有什麼我可以嘗試的嗎?

正如 Joeqwerty 所說,通常可以接受的是,您將使用具有外部信任的 NTLM 身份驗證,以及具有森林信任的 Kerberos。

但是,可以使 Kerberos 身份驗證與外部域一起使用,但有條件。

必須使用完全限定域名 (FQDN) 創建信任。如果受信任域對像中缺少 FQDN,Kerberos 引用將失敗。

使用者名語法為 UPN,UPN 後綴可解析為 DNS 中的 DC(隱式 UPN)

UDP 389、UDP/TCP 88 和 UDP/TCP 464 埠對使用者域中的域控制器開放。

信任資源域中的伺服器名稱必須是 FQDN,並且伺服器名稱的域後綴必須與 AD DS 域的 DNS FQDN 匹配。

如果在那之後它仍然讓你心痛,我建議切換到使用 SSL 保護的協商身份驗證。

一些額外的閱讀/參考:

http://technet.microsoft.com/en-us/library/dd560679(WS.10).aspx

http://jorgequestforknowledge.wordpress.com/2011/09/07/kerberos-authentication-over-an-external-trust-is-it-possible-part-1/

引用自:https://serverfault.com/questions/364678