aptx1231
aptx1231

Reputation: 59

'ssh -vT [email protected]' results in error "kex_exchange_identification: Connection closed by remote host"

The way I configuration the SSH key, I generate a new SSH key, and add it to my GitHub account, but something is wrong. I tried many ways, but I could not fix it.

ssh -vT [email protected]

Output:

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

What can I do?

Upvotes: 5

Views: 13314

Answers (3)

jason
jason

Reputation: 108

I guess you are using a VPN connection in your network and the VPN may have disabled port 22, so you need to cancel the VPN use or change the GitHub connection to port 443.

Edit ~/.ssh/config file, and save it.

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

Again test (as root):

ssh -T [email protected]

Output:

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.

Upvotes: 5

VonC
VonC

Reputation: 1326696

If you have only one key, try and regenerate it with the old PEM format, and no passphrase, for testing:

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

Copy the content of id_rsa.pub to your GitHub profile, and try again.

Upvotes: 1

phd
phd

Reputation: 94676

I suspect there're too many keys in your ~/.ssh/. Point ssh to the exact key you use. In ~/.ssh/config:

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

Then try ssh -Tv [email protected] again.

Upvotes: 1

Related Questions