【问题标题】:Powershell connecting from a linux client to a windows remote从 linux 客户端连接到 Windows 远程的 Powershell
【发布时间】:2017-09-30 07:32:53
【问题描述】:

我正在尝试从我的 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 工作站连接时:

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 事件日志中没有任何内容。

欢迎任何建议,

【问题讨论】:

    标签: linux powershell windows-10 remote-access


    【解决方案1】:

    可以使用 PowerShell Core(服务器和客户端)和 OpenSSH。

    Enter-PSSession -HostName myserver -UserName myuser
    

    阅读文章:

    【讨论】:

      【解决方案2】:

      目前不支持来自 Linux/OSX 的 WinRM,但支持正在进行中。

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

      【讨论】:

        【解决方案3】:

        您是否还启用了通过 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

        玩得开心

        【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2017-12-10
        • 1970-01-01
        • 2020-07-20
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-09-02
        相关资源
        最近更新 更多