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

Alf*_*res 7 linux powershell remote-access windows-10

我正在尝试从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
Run Code Online (Sandbox Code Playgroud)

现在当我尝试从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
Run Code Online (Sandbox Code Playgroud)

我在winrm windows事件日志中没有任何内容.

欢迎任何建议,

小智 5

目前不支持Linux / OSX上的WinRM,但正在支持中。

https://github.com/PowerShell/PowerShell/issues/942

  • 问题现在已经关闭,这应该工作吗? (3认同)

小智 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"}
Run Code Online (Sandbox Code Playgroud)

使用 HTTPS 和自签名证书可能会更好。这是一个很好的指南: http://www.joseph-streeter.com/?p =1086

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

玩得开心

  • “*基本身份验证通过 https 具有可接受的安全性,但通过 http 使用基本身份验证的所有通信均未加密。[..]请注意,这会通过未加密的 http 发送密码。我们不建议这样做。*” - https://github.com /PowerShell/psl-omi-provider (2认同)