我有一台运行 OpenSSH 的 Windows 10 计算机,我需要使用 PuTTY 通过 SSH 连接到该计算机。我已使用 PuTTYgen 在主机上创建了公钥/私钥。我将 public 加载到 .ssh/authorized_keys 下的用户配置文件目录中。当我从网络外部的计算机连接 PuTTY 时,我收到以下错误消息:
"Server refused our key"
我读过几篇文章,它们都表明公钥没有被正确读取。我进行了以下更改,但没有成功。
- 更新 .ssh 和/authorized_keys 上的用户权限,将用户设置为所有者。
- 目前我的 .ssh 文件夹位于 %SYSTEMDRIVE%/users/[USERNAME]/.ssh
- 我在数据驱动器上重新创建了此目录,以确保这不是问题:“D:/users/[USERNAME]/.ssh
- 因为我使用的帐户是管理员帐户,所以我创建了“%Program Data/ssh/adminstrators_authorized_keys
- 我注释掉了 sshd_config 中当用户是管理员时查看 #4 中的文件的行。
这些尝试都没有解决问题。我以前从未在 Windows 10 主机上设置过 SSH,所以我没有想法。我在 sshd_config 中设置了日志记录,但没有生成日志文件。
有人可以帮我解决这个问题吗?
最佳答案
首先,如this tutorial ,确保复制 OpenSSH 公钥
The OpenSSH public key is located in the box under
Key / Public key for pasting info OpenSSH authorized_keys file
:. The public key begins withssh-rsa
followed by a string of characters.
第二,如this gist ,启动 sshd -d
以在 Debug模式下获得一次性 session :您将看到更多关于为什么它拒绝您的公钥的线索。
sshd -d
gave me the information I needed.It was a file permissions issue. I had set the file permissions to the specifications from the OpenSSH setup instructions, but access to the file was getting blocked.
Once I updated the file permissions, I was able to connect without any trouble.
关于ssh - 无法通过运行 OpenSSH 的 SSH 连接到 Windows 10,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63365074/