简体   繁体   中英

Fail to git clone, push, pull with ssh, raise kex_exchange_identification error

On macOS Catalina, when I push my local repo by

> git push origin master
kex_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.

And I try ssh to git@github.com also, it returns

> ssh -Tv git@github.com
OpenSSH_8.1p1, LibreSSL 2.7.3
debug1: Reading configuration data /Users/user/.ssh/config
debug1: /Users/user/.ssh/config line 1: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 47: Applying options for *
debug1: Connecting to github.com port 22.
debug1: Connection established.
debug1: identity file /Users/user/.ssh/id_rsa type 0
debug1: identity file /Users/user/.ssh/id_rsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.1
kex_exchange_identification: Connection closed by remote host

my config file is

Host *                                                                                                                                                                                                  
    AddKeysToAgent yes 
    UseKeychain yes 
    IdentityFile ~/.ssh/id_rsa
    ForwardX11 yes 
Host 23
    HostName 10.214.130.23
    User ****
Host 26
    HostName 10.214.130.26
    User ****
Host 27
    HostName 10.214.130.27
    User ****
Host desktop
    HostName 10.214.130.251
    User ****

At the beginning, I think the id_rsa maybe wrong, so I use the same key ~/.ssh/id_rsa on the other Linux server, it works correctly.

> ssh -T git@github.com
Hi weleen! You've successfully authenticated, but GitHub does not provide shell access.

I find some similar questions but not solved.

It should work if you switch your remote-ulr from SSH to HTTPS.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM