从linux到windows的ssh只能通过密码工作,而不能通过密钥工作



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

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

PS /> Enter-PSSession -HostName computername -UserName 'domainusername' -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 'domainusername' -KeyFilePath ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ResourceUnavailable: (:) [Enter-PSSession], PSRemotingTransportException

有人知道是什么原因导致了这里的错误吗?

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

命令/setup非常好,但我使用"Add-WindowsCapability"cmdlet安装的捆绑包中包含的开放ssh服务器版本存在一个悬而未决的问题。

这个捆绑包在我的Win10机器上安装了7.6p1-beta版本。但事实上,截至7.6.1p1-β,该问题已得到解决,请参见:https://github.com/PowerShell/Win32-OpenSSH/issues/1098

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

最新更新