“ssh -vT git@github.com”导致错误“kex_exchange_identification:连接被远程主机关闭”

apt*_*231 5 git ssh github ssh-keys

我配置 SSH 密钥的方式是生成一个新的 SSH 密钥,并将其添加到我的 GitHub 帐户,但出现了问题。我尝试了很多方法,但无法修复。

ssh -vT git@github.com
Run Code Online (Sandbox Code Playgroud)

输出:

OpenSSH_8.1p1, OpenSSL 1.1.1d  10 Sep 2019
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to github.com [111.40.234.2] port 22.
debug1: Connection established.
debug1: identity file /c/Users/dell/.ssh/id_rsa type 0
debug1: identity file /c/Users/dell/.ssh/id_rsa-cert type -1
debug1: identity file /c/Users/dell/.ssh/id_dsa type -1
debug1: identity file /c/Users/dell/.ssh/id_dsa-cert type -1
debug1: identity file /c/Users/dell/.ssh/id_ecdsa type -1
debug1: identity file /c/Users/dell/.ssh/id_ecdsa-cert type -1
debug1: identity file /c/Users/dell/.ssh/id_ed25519 type -1
debug1: identity file /c/Users/dell/.ssh/id_ed25519-cert type -1
debug1: identity file /c/Users/dell/.ssh/id_xmss type -1
debug1: identity file /c/Users/dell/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.1
kex_exchange_identification: Connection closed by remote host
Run Code Online (Sandbox Code Playgroud)

我能做些什么?

phd*_*phd 1

我怀疑你的钥匙太多了~/.ssh/。指向ssh您使用的确切键。在~/.ssh/config

Host github.com
    User git
    HostName github.com
    IdentityFile ~/.ssh/id_rsa # or whatever key you use with Github
Run Code Online (Sandbox Code Playgroud)

然后再试ssh -Tv git@github.com一次。