ssh - 无法通过运行 OpenSSH 的 SSH 连接到 Windows 10

标签 ssh windows-10 openssh

我有一台运行 OpenSSH 的 Windows 10 计算机,我需要使用 PuTTY 通过 SSH 连接到该计算机。我已使用 PuTTYgen 在主机上创建了公钥/私钥。我将 public 加载到 .ssh/authorized_keys 下的用户配置文件目录中。当我从网络外部的计算机连接 PuTTY 时,我收到以下错误消息:

"Server refused our key"

我读过几篇文章,它们都表明公钥没有被正确读取。我进行了以下更改,但没有成功。

  1. 更新 .ssh 和/authorized_keys 上的用户权限,将用户设置为所有者。
  2. 目前我的 .ssh 文件夹位于 %SYSTEMDRIVE%/users/[USERNAME]/.ssh
  3. 我在数据驱动器上重新创建了此目录,以确保这不是问题:“D:/users/[USERNAME]/.ssh
  4. 因为我使用的帐户是管理员帐户,所以我创建了“%Program Data/ssh/adminstrators_authorized_keys
  5. 我注释掉了 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 with ssh-rsa followed by a string of characters.

第二,如this gist ,启动 sshd -d 以在 Debug模式下获得一次性 session :您将看到更多关于为什么它拒绝您的公钥的线索。


OP gacto确认in the comments :

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/

相关文章:

shell - 在Shell脚本中的ssh session 中评估和分配变量

linux - 检查 Perl 远程服务器中是否存在目录

c# - 如何从 hWnd 获取 "Application Name"for Windows 10 Store Apps (e.g. Edge)

macos - SSH 错误 : Permission denied (publickey, gssapi-with-mic)

Cygwin - 自动安装 OpenSSH 服务器

python - 解耦、冗余、异步在远程服务器上执行命令

linux - Linux 中的用户特定主机

php - 如何检查 python 脚本 (test.py) 是否在 Windows 10 上运行

c++ - GetTempFileName 在 Windows 10 上似乎已损坏

sockets - 使用原始套接字获取SSH Banner