-1

在我的目标场景中,我需要从 linux 远程连接到 windows 并执行 powershell 命令。为此,我在 windows 上安装了本机 open ssh 服务器,并在两台机器上安装了 pwoershell core 6。

如果我在 sshd 上使用密码身份验证,远程处理就可以正常工作。当需要基于密钥的身份验证时,它不起作用。

PS /> Enter-PSSession -HostName computername -UserName 'domain\username' -KeyFilePath ./sshkeys/win/win10 -Verbose
Enter passphrase for key '/sshkeys/win/win10':
Enter-PSSession : The background process reported an error with the following message: The SSH client session has ended with error message: Connection to computername closed by remote host..
At line:1 char:1
+ Enter-PSSession -HostName computername -UserName 'domain\username' -KeyFilePath ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ResourceUnavailable: (:) [Enter-PSSession], PSRemotingTransportException

有人知道这里可能导致错误的原因吗?

4

1 回答 1

0

对于任何有兴趣的人,我通过进一步研究解决了这个问题。

命令/设置非常好,但是我使用“Add-WindowsCapability”cmdlet 安装的捆绑包中包含的开放 ssh 服务器版本存在一个突出问题。

这个捆绑包在我的 Win10 机器上安装了 7.6p1-beta 版。但事实上,这个问题在 7.6.1p1-beta 中已经修复,请参阅:https ://github.com/PowerShell/Win32-OpenSSH/issues/1098

手动下载并运行最新版本的 SSH 服务器为我修复了它。

于 2018-12-09T04:51:26.000 回答