【发布时间】:2019-01-09 03:31:38
【问题描述】:
在 Centos 7 上使用 PowerShell 版本 6.0.2,尝试获取到 Windows 2012 Server 的会话。 执行以下操作:
$secpasswd = ConvertTo-SecureString "password" -AsPlainText -Force
$mycreds = New-Object System.Management.Automation.PSCredential ("domain\username", $secpasswd)
Enter-PSSession -ComputerName Some-Host-Name -port 5985 -Credential $mycreds
得到以下错误:
Enter-PSSession : MI_RESULT_ACCESS_DENIED At line:1 char:2
+ Enter-PSSession -ComputerName Some-Host-Name -port 5985 -Credential $m ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (Some-Host-Name :String) [Enter-PSSession], PSInvalidOperationException
+ FullyQualifiedErrorId : CreateRemoteRunspaceFailed
应该获得与 Windows 机器的会话。
为了使 Windows 机器信任 centos 机器,请执行以下操作
Set-Item WSMAN:\Localhost\Client\TrustedHosts -Value * -Force
任何想法我需要做什么?
【问题讨论】:
-
您的 CentOS 主机是否在 TrustedHosts 列表中有 Windows 主机?否则它们需要在同一个域中,使用 Kerberos 进行身份验证/授权。
-
@TheIncorrigible1 是的。完成以下命令:Set-Item WSMAN:\Localhost\Client\TrustedHosts -Value * -Force
-
你在两端都这样做了吗?
-
@TheIncorrigible1 1. 为什么centos尝试连接时需要将windows机器加入信任列表? 2. 我该怎么做?
-
因为它是客户端配置,而不是服务器配置。在这种情况下,您的 CentOS 是一个客户端。您可以像在 Windows 机器上一样完成它。
标签: powershell remote-access powershell-remoting winrm