4

I have Kubuntu 18.04 installed on my machine and I installed PowerShell Core following the instructions given: Installing PowerShell core in linux.

I then setup the remoting following the steps described here: PowerShell remoting over SSH.

Even though the steps target Ubuntu 14.04, I could make my way through them.

But when I am trying something as simple as executing something on my own machine through remoting I get:

PS /etc/ssh> Invoke-Command -ComputerName ehouarn-perret-ThinkPad-E460 -ScriptBlock { Write-Output Hello }
Invoke-Command : MI_RESULT_ACCESS_DENIED
At line:1 char:1
+ Invoke-Command -ComputerName ehouarn-perret-ThinkPad-E460 -ScriptBloc ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : InvalidOperation: (:) [Invoke-Command], PSInvalidOperationException
+ FullyQualifiedErrorId : InvalidOperation,Microsoft.PowerShell.Commands.InvokeCommandCommand

Any idea how to make the PowerShell Core remoting work with Ubuntu?

GAD3R
  • 3,507

1 Answers1

2

As stated by LotPings:

Your 2nd link requires to use [-HostName <string>] [-UserName <string>]

#
# Linux to Linux
#
$session = New-PSSession -HostName UbuntuVM1 -UserName TestUser

I tried:

ehouarn-perret@ehouarn-perret-ThinkPad-E460:/etc/ssh$ pwsh-preview 
PowerShell 6.1.0-preview.4
Copyright (c) Microsoft Corporation. All rights reserved.

https://aka.ms/pscore6-docs
Type 'help' to get help.

PS /etc/ssh> Invoke-Command -HostName ehouarn-perret-ThinkPad-E460 -UserName ehouarn-perret  -ScriptBlock { Write-Output Hello }
The authenticity of host 'ehouarn-perret-thinkpad-e460 (127.0.1.1)' can't be established.
ECDSA key fingerprint is SHA256:woPvPaavotuV4g4K3fYXKXi78usIrboXm8+FIaJncOc.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'ehouarn-perret-thinkpad-e460' (ECDSA) to the list of known hosts.
ehouarn-perret@ehouarn-perret-thinkpad-e460's password: 
Hello
PS /etc/ssh> 

Seems it works like a charm, my bad!