简体   繁体   中英

Powershell connecting from a linux client to a windows remote

I am trying to remotely connect to a windows machine from my Linux workstation.

I installed powershell on my Arch Linux workstation and I am currently trying to connect to the host.

On the host:

Enable-PSRemoting

Then allowed all hosts with Set-Item wsman:\\localhost\\client\\trustedhosts *

Checking everything with:

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

Now when I try to connect from Linux workstation:

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

I don't anything on the the winrm windows event logs.

Any suggestions welcome,

WinRM from Linux/OSX is not currently supported but support is on the way.

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

Have you also enabled Remoting over HTTP/HTTPS?

At the most basic, this involves these commands:

winrm set winrm/config/client/auth @{Basic="true"}
winrm set winrm/config/service/auth @{Basic="true"}
winrm set winrm/config/service @{AllowUnencrypted="true"}

Probably better to use HTTPS and a self signed cert. This is a nice guide: http://www.joseph-streeter.com/?p=1086

Or just use the script provided by ansible: https://raw.githubusercontent.com/ansible/ansible/devel/examples/scripts/ConfigureRemotingForAnsible.ps1

have fun

It's possible to do with PowerShell Core (server and client) and OpenSSH.

Enter-PSSession -HostName myserver -UserName myuser

Read the articles:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM