powershell - Invoke-Command 行为澄清

标签 powershell windows-authentication kerberos powershell-4.0 invoke-command

我在使用 Invoke-Command cmdlet 时遇到了一些问题。我使用我的域身份登录到我的本地计算机,该域身份对 $server 具有管理员权限。如果我手动输入凭据,然后使用 Invoke-Command,我会收到错误:

Cannot open Service Control Manager on computer ''. This operation might require other privileges.

# Works
Get-Service -ComputerName $server-ErrorAction Ignore

# Doesn't work
$cred = Get-Credential
Invoke-Command -ComputerName localhost -ScriptBlock {param($serverIPAddress) Get-Service -ComputerName $server -ErrorAction Ignore} -Credential $cred -ArgumentList $server

使这项工作有效的内置凭据有什么特别之处吗?

最佳答案

这是经典的 kerberos 双跳。

发生的特殊事情是本地计算机拥有您的凭据。它可以与远程计算机通信并证明其拥有凭据,而无需发送凭据。

但是,如果远程计算机需要访问第三台计算机(第二跳)上的某些内容,它无法证明它具有凭据(因为它没有),因此它无法进行身份验证。

这是按设计工作的 Kerberos。

使用 Invoke-Command 到本地主机仍然进行远程连接,因此它仍然算作一个跃点。 Get-Service 调用是第二个跃点。


考虑:

Invoke-Command -ComputerName $server -ScriptBlock { Get-Service -ErrorAction Ignore } -Credential $cred

这将起作用(只要在远程计算机上启用了 powershell 远程处理)。

否则,您需要启用 kerberos 委派或 CredSSP,或者(如果可能的话最好)重新设计您正在执行的操作以不需要双跳。

Be wary of CredSSP (and delegation in general).

关于powershell - Invoke-Command 行为澄清,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36429196/

相关文章:

powershell - 无法使用Powershell从商店中删除证书

asp.net-mvc - ASP.NET MVC Windows 身份验证以不同用户身份登录

c# - 为一个 Windows 用户生成唯一 key

kerberos - ktpass 中 mapuser 的用途

hadoop - hadoop HA的Kerberos集成问题

azure - 将 blob 内容获取到本地的 PowerShell 代码

powershell - 无法在 Exchange 管理控制台中将变量与 Get-User -Filter 一起使用

powershell - 组合参数集

asp.net-mvc-4 - 为什么将 FormsAuthenticationTicket 与 Windows 身份验证结合使用?

hadoop - 将文件从不安全的 hdfs 传输到安全的 hdfs 集群