ssh linux 到 windows 失败,连接重置

ssh linux 到 windows 失败,连接重置

我已按照官方文档在 Windows 11 中设置了 sshd 服务器。我已将我的公钥作为 Administrators_authorized_keys 传输到 Windows 计算机的 C:\ProgramData\ssh\,并按照文档中所写更改了权限:

在客户端上获取先前生成的公钥文件 $authorizedKey = Get-Content -Path $env:USERPROFILE.ssh\id_ed25519.pub

生成要远程运行的 PowerShell,它将把客户端上先前生成的公钥文件复制到服务器上的 authorized_keys 文件中

添加内容 -Force -Path $env:ProgramData\ssh\administrators_authorized_keys -Value "$authorizedKey"; icacls.exe "$env:ProgramData\ssh\administrators_authorized_keys" /inheritance:r /grant "Administrator:F" /grant "SYSTEM:F"

另外,我取消注释了 C:\ProgramData\ssh\ 中的 sshd_config 文件行,并将其设置为 PubkeyAuthentication yes

我仍然无法连接。它挂了大约 2 秒钟,然后连接中断并显示错误:连接由 192.168.2.132 端口 22 重置

这是调试消息的输出:

debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 134217728 blocks
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_ext_info_client_parse: server-sig-algs=<ssh-ed25519,[email protected],ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected],[email protected]>
debug1: SSH2_MSG_SERVICE_ACCEPT received
ls
Connection reset by 192.168.2.132 port 22

相关内容