Why do I on git get ssh_exchange_identification: Connection closed by remote host?

Viewed 4203

Cloning a repo form the terminal:

git clone git@github.foohost.com:barrepo.git
Cloning into 'foorepo'...
ssh_exchange_identification: Connection closed by remote host
fatal: Could not read from remote repository.

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

I've followed the steps on generating and adding the SSH key but when I test my SSH connection I have the same result:

ssh -T git@github.foohost.com:
ssh_exchange_identification: Connection closed by remote host

using verbose

ssh -v git@github.foohost.com
OpenSSH_7.9p1, LibreSSL 2.7.3
debug1: Reading configuration data /Users/Fred/.ssh/config
debug1: /Users/Fred/.ssh/config line 18: Applying options for *
debug1: /Users/Fred/.ssh/config line 27: Applying options for github.foohost.com
debug1: /Users/Fred/.ssh/config line 41: Applying options for *.foohost.com
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 48: Applying options for *
debug1: Executing proxy command: exec ssh -q b.snc1 nc github 22
debug1: identity file /Users/Fred/.ssh/baz_rsa type 0
debug1: identity file /Users/Fred/.ssh/baz_rsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.9
ssh_exchange_identification: Connection closed by remote host

I can clone the repo using https but after that I cannot perform other actions (checkout/push...).

Any suggestions what may cause this or how to fix it?

1 Answers

In my case this was due to a missing VPN connection.

Also, @YesThatIsMyName commented:

You may try the steps from this website, like ssh -v for more verbose output. P.S. You may update your question with the verbose output. –

Related