“ssh -vTgit@github.com”导致错误“密钥交换标识:连接被远程主机关闭”

qv7cva1a  于 2023-02-28  发布在  Git
关注(0)|答案(3)|浏览(225)

The way I configuration the SSH key,我生成了一个新的SSH密钥,并将其添加到我的GitHub帐户中,但出现了一些问题。我尝试了许多方法,但都无法修复它。

ssh -vT git@github.com

输出:

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

我能怎么办?

pqwbnv8z

pqwbnv8z1#

我猜您在网络中使用的是VPN连接,VPN可能禁用了端口22,因此您需要取消VPN使用或将GitHub连接更改为端口443。
编辑~/.ssh/config文件并保存。

Host github.com
    HostName ssh.github.com
    User git
    Port 443

再次测试(作为root):

ssh -T git@github.com

输出:

The authenticity of host '[ssh.github.com]:443 ([20.205.243.160]:443)' can't be established.
ED25519 key fingerprint is SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '[ssh.github.com]:443' (ED25519) to the list of known hosts.
Hi xxxxxx You've successfully authenticated, but GitHub does not provide shell access.
gjmwrych

gjmwrych2#

我怀疑您的~/.ssh/中的密钥太多。请将ssh指向您使用的确切密钥。在~/.ssh/config中:

Host github.com
    User git
    HostName github.com
    IdentityFile ~/.ssh/id_rsa # or whatever key you use with Github

然后重试ssh -Tv git@github.com

f87krz0w

f87krz0w3#

如果您只有一个密钥,请尝试使用the old PEM format重新生成密钥,并且不使用密码短语,以进行测试:

ssh-keygen -t rsa -P "" -m PEM

id_rsa.pub的内容复制到您的GitHub配置文件,然后重试。

相关问题