我的机器上安装了 Kubuntu 18.04,并按照给出的说明安装了 PowerShell Core:在 Linux 中安装 PowerShell 核心。
然后我按照此处描述的步骤设置远程处理:通过 SSH 进行 PowerShell 远程控制。
尽管这些步骤针对的是 Ubuntu 14.04,但我仍然可以完成它们。
但是,当我尝试通过远程处理在我自己的机器上执行一些简单的事情时,我得到了:
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
知道如何让 PowerShell Core 远程处理与 Ubuntu 协同工作吗?
答案1
正如 LotPings 所述:
您的第二个链接需要使用
[-HostName <string>] [-UserName <string>]
#
# Linux to Linux
#
$session = New-PSSession -HostName UbuntuVM1 -UserName TestUser
我试过:
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>
看来它很有效,我的错!