【问题标题】:GitHub.com SSH access failsGitHub.com SSH 访问失败
【发布时间】:2022-01-10 13:01:00
【问题描述】:

我无法通过 SSH 访问 GitHub.com(用于使用 GitHub 桌面推送)。我的客户端是 Windows 10 系统。 它曾经工作到昨天。我遇到了一些问题,然后我决定重新初始化 SSH 环境。我删除了服务器(GitHub.com)端的公钥,然后再次添加。从那以后我就陷入了困境。推送时我看到:

我创建了一个 ed25519 公钥/私钥对并将公钥添加到服务器。一切似乎都很好。 发出“ssh -T git@github.com”时,响应为:

PS C:\WINDOWS\system32> ssh git@github.com
PTY allocation request failed on channel 0
Hi <user>! You've successfully authenticated, but GitHub does not provide shell access.
Connection to github.com closed.

当发出“sss -T @github.com”时,响应是:

PS C:\WINDOWS\system32> ssh <user>@github.com
<user>@github.com: Permission denied (publickey).

完整的痕迹是:

PS C:\WINDOWS\system32> ssh -vT <user>@github.com
OpenSSH_for_Windows_8.1p1, LibreSSL 3.0.2
debug1: Connecting to github.com [140.82.121.4] port 22.
debug1: Connection established.
debug1: identity file C:\\Users\\User/.ssh/id_rsa type -1
debug1: identity file C:\\Users\\User/.ssh/id_rsa-cert type -1
debug1: identity file C:\\Users\\User/.ssh/id_dsa type -1
debug1: identity file C:\\Users\\User/.ssh/id_dsa-cert type -1
debug1: identity file C:\\Users\\User/.ssh/id_ecdsa type -1
debug1: identity file C:\\Users\\User/.ssh/id_ecdsa-cert type -1
debug1: identity file C:\\Users\\User/.ssh/id_ed25519 type -1
debug1: identity file C:\\Users\\User/.ssh/id_ed25519-cert type -1
debug1: identity file C:\\Users\\User/.ssh/id_xmss type -1
debug1: identity file C:\\Users\\User/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_for_Windows_8.1
debug1: Remote protocol version 2.0, remote software version babeld-8eb00d7e
debug1: no match: babeld-8eb00d7e
debug1: Authenticating to github.com:22 as '<user>'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:p2QAMXNIC1TJYWeIOttrVc98/R1BUFWu3/LiyKgUfQM
debug1: Host 'github.com' is known and matches the ECDSA host key.
debug1: Found key in C:\\Users\\User/.ssh/known_hosts:7
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: Will attempt key: <email> ED25519 SHA256:n1SJK1uvYimJC8EhOeJXmLUskx4CWQd2HQ/kjT0BKzg agent
debug1: Will attempt key: C:\\Users\\User/.ssh/id_rsa
debug1: Will attempt key: C:\\Users\\User/.ssh/id_dsa
debug1: Will attempt key: C:\\Users\\User/.ssh/id_ecdsa
debug1: Will attempt key: C:\\Users\\User/.ssh/id_ed25519
debug1: Will attempt key: C:\\Users\\User/.ssh/id_xmss
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp256-cert-v01@openssh.com,sk-ssh-ed25519-cert-v01@openssh.com,sk-ecdsa-sha2-nistp256-cert-v01@openssh.com,rsa-sha2-512-cert-v01@openssh.com,rsa-sha2-256-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ssh-dss-cert-v01@openssh.com,sk-ssh-ed25519@openssh.com,sk-ecdsa-sha2-nistp256@openssh.com,ssh-ed25519,ecdsa-sha2-nistp521,ecdsa-sha2-nistp384,ecdsa-sha2-nistp256,rsa-sha2-512,rsa-sha2-256,ssh-rsa,ssh-dss>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: <email> ED25519 SHA256:n1SJK1uvYimJC8EhOeJXmLUskx4CWQd2HQ/kjT0BKzg agent
debug1: Authentications that can continue: publickey
debug1: Trying private key: C:\\Users\\User/.ssh/id_rsa
debug1: Trying private key: C:\\Users\\User/.ssh/id_dsa
debug1: Trying private key: C:\\Users\\User/.ssh/id_ecdsa
debug1: Trying private key: C:\\Users\\User/.ssh/id_ed25519
debug1: Trying private key: C:\\Users\\User/.ssh/id_xmss
debug1: No more authentication methods to try.
<user>@github.com: Permission denied (publickey).

对此有什么想法吗?

【问题讨论】:

  • 您不应该使用您的用户名。你总是应该使用git@github.com,它表明它工作得很好。向我们展示您的存储库中git remote -v 的输出,以及您尝试从命令行推送时得到的结果(作为编辑到您问题中的代码块)。

标签: github ssh permission-denied ed25519


【解决方案1】:

任何不使用 git 的 ssh 都会失败:git唯一允许在 SSH 端口上查询 GitHub 的服务帐户,与该查询关联的私钥/公钥足以进行身份​​验证你。

Testing your SSH connection”页面确实使用了ssh -T git@github.com

转到您的存储库,然后测试 git -c "core.sshCommand='ssh -Tv'" ls-remote
您将确切地看到在 ls-remote 命令期间考虑了哪些用户和密钥(它需要与拉/推/克隆相同的凭据)。

【讨论】:

    猜你喜欢
    • 2019-06-13
    • 1970-01-01
    • 1970-01-01
    • 2019-02-18
    • 2021-10-19
    • 1970-01-01
    • 2021-02-25
    • 2021-03-23
    • 1970-01-01
    相关资源
    最近更新 更多