Windows

如何允許非管理員使用者訪問 winrs?

  • November 20, 2014

我有 Windows Server 2012(和 Server 2008,但它是下一個優先級)使用txwinrm監控它。txwinrm 庫內部使用 WinRS 協議。我必須使用最低權限的使用者對其進行監控,但不知道如何為他配置訪問權限。

我設法做的就是為我的使用者配置遠端 Powershell 會話,但看起來 winrs 和 powershell 會話具有不同的安全描述符:

Invoke-Command -ComputerName 192.168.173.206 -Credential (credential Administrator $pwd) -ScriptBlock { 2 + 2}
# gives 4
Invoke-Command -ComputerName 192.168.173.206 -Credential (credential lpu1 $pwd) -ScriptBlock { 2 + 2}
# gives 4
winrs -r:192.168.173.206 -u:Administrator -p:$pwd 'powershell -command "2+2"'
# gives 4
winrs -r:192.168.173.206 -u:lpu1 -p:$pwd 'powershell -command "2+2"'
# Gives Winrs error: Access is denied.

我的使用者的配置如下:

(Get-Item WSMan:\localhost\Service\RootSDDL).value
# O:NSG:BAD:P(A;;GA;;;BA)(A;;GA;;;S-1-5-21-3231263931-1371906242-1889625497-1141)S:P(AU;FA;GA;;;WD)(AU;SA;GWGX;;;WD)
(Get-PSSessionConfiguration -name Microsoft.Powershell).SecurityDescriptorSddl
# O:NSG:BAD:P(A;;GA;;;BA)(A;;GA;;;S-1-5-21-3231263931-1371906242-1889625497-1149)S:P(AU;FA;GA;;;WD)(AU;SA;GXGW;;;WD)

(在每個安全描述符中,我的使用者都被授予對受保護對象的一般訪問權限)。

那麼我應該設置什麼安全描述符以使我的 winrs 查詢對非管理員使用者有效?

**UPD:**最近我發現我可以檢索有關 winrm shell的資訊:

 winrm enumerate shell
Shell
   ShellId = 3793B153-CCCF-4500-99FB-8534074E1738
   ResourceUri = http://schemas.microsoft.com/wbem/wsman/1/windows/shell/cmd

而且我在WSMan:\localhost\Plugin目錄中沒有找到這樣的資源 URI。:(文件狀態:

資源 URI 可用於檢索特定於 shell 實例的外掛配置。

但是如何檢索該外掛配置以及如何更改它?

有效的是

winrm configSDDL default

然後允許讀取和執行權限。但奇怪的是,那裡的設置與WSMan:\localhost\Service\RootSDDL. 可能是因為 winrm configSDDL 重新載入了一些記憶體之類的,我不知道…

您可以使用以下方式添加使用者:

winrm configSDDL http://schemas.microsoft.com/wbem/wsman/1/windows/shell/cmd

來源

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