ssh -vTgit@github.com关键字交换标识:连接被远程主机关闭

n6lpvg4x  于 2022-11-27  发布在  Git
关注(0)|答案(3)|浏览(204)

the way I config 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

我能做什么呢?

gzszwxb4

gzszwxb41#

我怀疑您的~/.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

hyrbngr7

hyrbngr72#

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

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

id_rsa.pub的内容复制到您的GitHub档案中,然后重试。

uyto3xhc

uyto3xhc3#

我猜你在你的网络中使用了一个vpn,并且vpn可能已经禁用了端口22,所以你需要取消vpn的使用或者将github连接更改为端口443。
编辑~/.ssh/config文件并保存

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

再次测试

root@node02:~# 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.

相关问题