Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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,

like image 833
Alfredo Palhares Avatar asked May 02 '17 17:05

Alfredo Palhares


2 Answers

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

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

like image 98
Phil Avatar answered Sep 19 '22 04:09

Phil


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

like image 30
guy_from_irc Avatar answered Sep 21 '22 04:09

guy_from_irc