Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git pull encounters kex_exchange_identification: Connection closed by remote host

When I used git pull to pull code from GitHub, I encounted the following error:

kex_exchange_identification: Connection closed by remote host
Connection closed by 20.205.243.166 port 22
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

I'm sure this ssh key worked fine until yesterday, But I don't know why this error occurs. My laptop is Macbook Air 13, Monterey 12.4. Can anyone help me? Thank a lot.

I try ssh -vT [email protected] to debug, but it seems that there is no bug. I don't know how to handle, can anyone help me? Thank a lot. The following is the msg output by ssh -vT [email protected] (username is replaced by ${username})

OpenSSH_8.6p1, LibreSSL 3.3.6
debug1: Reading configuration data /Users/${username}/.ssh/config
debug1: /Users/${username}/.ssh/config line 7: Applying options for github.com
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 21: include /etc/ssh/ssh_config.d/* matched no files
debug1: /etc/ssh/ssh_config line 54: Applying options for *
debug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling
debug1: Connecting to github.com port 22.
debug1: Connection established.
debug1: identity file /Users/${username}/.ssh/id_github_rsa type 0
debug1: identity file /Users/${username}/.ssh/id_github_rsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.6
kex_exchange_identification: Connection closed by remote host
Connection closed by 20.205.243.166 port 22
like image 234
ZYinNJU Avatar asked Sep 06 '25 03:09

ZYinNJU


1 Answers

I added the Hostname for Git on my ~/.ssh/config, which fixed my issue. I was on VPN when I came across the same issue as yours.

Host github.com
 Hostname ssh.github.com
 Port 443
like image 82
Ronny Wang Avatar answered Sep 07 '25 15:09

Ronny Wang