ssh - 从 linux 到 windows 的 ssh 只能通过密码而不是密钥工作
问题描述
在我的目标场景中,我需要从 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
有人知道这里可能导致错误的原因吗?
解决方案
对于任何有兴趣的人,我通过进一步研究解决了这个问题。
命令/设置非常好,但是我使用“Add-WindowsCapability”cmdlet 安装的捆绑包中包含的开放 ssh 服务器版本存在一个突出问题。
这个捆绑包在我的 Win10 机器上安装了 7.6p1-beta 版。但事实上,这个问题在 7.6.1p1-beta 中已经修复,请参阅:https ://github.com/PowerShell/Win32-OpenSSH/issues/1098
手动下载并运行最新版本的 SSH 服务器为我修复了它。
推荐阅读
- django - 如何避免自引用多对多关系中的无限递归
- xml - 使用嵌套的 For Each 和 If 从不同的子节点返回节点值
- python - 为什么可变变量的重新定义不会传播回调用它们的函数?
- c++ - 以向量/列表迭代器为键创建地图
- javascript - 在文本上浮动透明 PNG
- sql - 从具有最大日期的多个连接中获取聚合
- .net - .NET Core 2.2 - 实体框架 - 自定义分配 [NotMapped] 模型属性 w/ DbSet.FromSql()
- python - 如何调试说构造函数不带参数的错误
- sql - 无法弄清楚这个查询
- python - 对从大型数据集聚合的数据使用 Altair