为 Windows 设置 SSH 权限被拒绝(公钥)

为 Windows 设置 SSH 权限被拒绝(公钥)

我正在关注设置 SSH 的线程

但我在第 5 步时收到以下错误

$ ssh -T [email protected]
Warning: Permanently added the RSA host key for IP address 'xxx.xx.xxx.xxx' to the list of known hosts.
Permission denied (publickey).

以下是详细日志

$ ssh -vT [email protected]
$ ssh -vT [email protected]
OpenSSH_7.1p1, OpenSSL 1.0.2d 9 Jul 2015
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to github.com [192.30.252.128] port 22.
debug1: Connection established.
debug1: identity file /c/Users/Kiran B/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/Kiran B/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/Kiran B/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/Kiran B/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/Kiran B/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/Kiran B/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/Kiran B/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/Kiran B/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.1
debug1: Remote protocol version 2.0, remote software version libssh-0.7.0
debug1: no match: libssh-0.7.0
debug1: Authenticating to github.com:22 as 'git'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client [email protected] <implicit> none
debug1: kex: client->server [email protected] <implicit> none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ssh-rsa 
SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8
debug1: Host 'github.com' is known and matches the RSA host key.
debug1: Found key in /c/Users/Kiran B/.ssh/known_hosts:1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /c/Users/Kiran B/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: Trying private key: /c/Users/Kiran B/.ssh/id_dsa
debug1: Trying private key: /c/Users/Kiran B/.ssh/id_ecdsa
debug1: Trying private key: /c/Users/Kiran B/.ssh/id_ed25519
debug1: No more authentication methods to try.
Permission denied (publickey).

答案1

创建 SSH 配置文件

如何将 ssh 密钥添加到 github 账户?

  • 登录github账户
  • 点击右上角的牧场主(设置)
    github 账户设置
  • 点击SSH keys
    ssh 密钥部分
  • 点击Add ssh key
    添加 ssh 密钥
  • 粘贴您的密钥并保存

现在一切准备就绪:-)

答案2

最近我遇到了同样的问题。

也许你的ssh 身份已被删除。如果运行此命令

ssh-添加-l

您收到此消息“该代理人没有身份。


我建议你生成一个新ssh密钥

ssh-keygen -t rsa -b 4096 -C “你的 github 邮件账户”

  • [按回车键]
  • [输入安全密码]
  • 再次输入相同的密码

您将收到身份保存消息。

现在,运行此命令,

ssh-添加〜/.ssh/id_rsa

输入您的密码。


复制你的 SSH RSA 密钥

剪辑 < ~/.ssh/id_rsa.pub

现在,转到您的 GitHub 帐户 > 设置 > SSH 密钥 > 新 SSH 密钥并粘贴复制的密钥。

验证与 GitHub 的 SSH 连接。

SSH-T[电子邮件保护]

最后,你收到这条消息,

你好...!您已成功验证,但 GitHub 不提供 shell 访问权限。

相关内容