Bun*_*nyk 7 windows powershell remoting winrm
我有 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.
Run Code Online (Sandbox Code Playgroud)
我的用户的配置如下:
(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)
Run Code Online (Sandbox Code Playgroud)
(在每个安全描述符中,我的用户都被授予对受保护对象的一般访问权限)。
那么我应该设置什么安全描述符来使我的 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
Run Code Online (Sandbox Code Playgroud)
我在WSMan:\localhost\Plugin目录中没有发现这样的资源 URI 。:(文档说明:
资源 URI 可用于检索特定于 shell 实例的插件配置。
但是如何检索该插件配置以及如何更改它?
有效的是
winrm configSDDL default
Run Code Online (Sandbox Code Playgroud)
然后允许读取和执行权限。但奇怪的是,那里的设置与WSMan:\localhost\Service\RootSDDL. 这可能是因为 winrm configSDDL 重新加载了一些缓存或其他东西,我不知道......