Powershell从Linux客户端连接到Windows远程

11

我正在尝试从我的Linux工作站远程连接到Windows机器。

我在我的Arch Linux工作站上安装了PowerShell,目前正在尝试连接到主机。

在主机上:

Enable-PSRemoting

然后允许所有主机使用以下命令:Set-Item wsman:\localhost\client\trustedhosts *

使用以下命令检查所有内容:

PS C:\windows\system32> ls WSMan:\localhost\shell


   WSManConfig: Microsoft.WSMan.Management\WSMan::localhost\Shell

Type            Name                           SourceOfValue   Value
----            ----                           -------------   -----
System.String   AllowRemoteShellAccess                         true
System.String   IdleTimeout                                    7200000
System.String   MaxConcurrentUsers                             2147483647
System.String   MaxShellRunTime                                2147483647
System.String   MaxProcessesPerShell                           2147483647
System.String   MaxMemoryPerShellMB                            2147483647
System.String   MaxShellsPerUser                               2147483647
现在当我尝试从 Linux 工作站连接时:

现在当我尝试从 Linux 工作站连接时:

PS /home/user/tmp> Enter-PSSession -ComputerName "myuser" -Credential DOMAIN\myuser

Windows PowerShell credential request
Enter your credentials.
Password for user DOMAIN\myuser: *****************

Enter-PSSession : MI_RESULT_ACCESS_DENIED
At line:1 char:1
+ Enter-PSSession -ComputerName "myuser" -Credential DOMAIN\ajpalhare ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (myuser:String) [Enter-PSSession
   ], PSInvalidOperationException
    + FullyQualifiedErrorId : CreateRemoteRunspaceFailed

我在winrm windows事件日志中找不到任何信息。

欢迎任何建议,

3个回答

5

1

1
您是否也启用了HTTP/HTTPS远程控制?

最基本的操作包括以下命令:
winrm set winrm/config/client/auth @{Basic="true"}
winrm set winrm/config/service/auth @{Basic="true"}
winrm set winrm/config/service @{AllowUnencrypted="true"}

最好使用HTTPS和自签名证书。这是一个不错的指南: http://www.joseph-streeter.com/?p=1086

或者只需使用ansible提供的脚本: https://raw.githubusercontent.com/ansible/ansible/devel/examples/scripts/ConfigureRemotingForAnsible.ps1

玩得开心。


2
“基本身份验证在https上具有可接受的安全性,但是在http上使用基本身份验证的所有通信都未加密。请注意,这会将密码发送到未加密的http上。我们不建议这样做。” - https://github.com/PowerShell/psl-omi-provider - TessellatingHeckler
https://social.technet.microsoft.com/Forums/windowsserver/en-US/977381ef-dc7a-4e4a-8457-323ed4c32639/can-you-execute-winrm-2-set-commands-wthin-powershell-2#891e986c-2620-4756-a6eb-743f1ad1f337 - gsc

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接