从 linux 到 windows 的 ssh 只能通过密码工作,不能通过密钥工作
ssh from linux to windows works works only via password, not keys
在我的目标场景中,我需要从 linux 远程连接到 windows 并执行 powershell 命令。为此,我在 windows 上安装了本机开放 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
有人知道可能导致这里错误的原因吗?
对于任何感兴趣的人,我通过进一步研究解决了这个问题。
command/setup 非常好,但是我使用 "Add-WindowsCapability" cmdlet 安装的捆绑包中包含的开放式 ssh 服务器版本存在一个突出的问题。
这个包在我的 Win10 机器上安装了 7.6p1-beta 版。但事实上这个问题已经在 7.6.1p1-beta 中得到修复,参见:https://github.com/PowerShell/Win32-OpenSSH/issues/1098
手动下载并运行 最新版本的 SSH 服务器为我修复了它。
在我的目标场景中,我需要从 linux 远程连接到 windows 并执行 powershell 命令。为此,我在 windows 上安装了本机开放 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
有人知道可能导致这里错误的原因吗?
对于任何感兴趣的人,我通过进一步研究解决了这个问题。
command/setup 非常好,但是我使用 "Add-WindowsCapability" cmdlet 安装的捆绑包中包含的开放式 ssh 服务器版本存在一个突出的问题。
这个包在我的 Win10 机器上安装了 7.6p1-beta 版。但事实上这个问题已经在 7.6.1p1-beta 中得到修复,参见:https://github.com/PowerShell/Win32-OpenSSH/issues/1098
手动下载并运行 最新版本的 SSH 服务器为我修复了它。