在我的目标场景中,我需要从 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
有人知道这里可能导致错误的原因吗?