无法使用 ssh 进行 git 克隆、推送、拉取,引发 kex_exchange_identification 错误

问题描述 投票:0回答:1

在 macOS Catalina 上,当我按

推送本地存储库时
> 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.

我也尝试 ssh 到 [电子邮件受保护],它也返回了

> ssh -Tv [email protected]
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

我的配置文件是

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 ****

一开始,我认为 id_rsa 可能是错误的,所以我在另一台 Linux 服务器上使用相同的密钥

~/.ssh/id_rsa
,它工作正常。

> ssh -T [email protected]
Hi weleen! You've successfully authenticated, but GitHub does not provide shell access.

我发现了一些类似的问题但没有解决。

git macos github ssh
1个回答
-3
投票

如果您切换网络(互联网连接),也许它会起作用。请检查以下链接:

使用 ssh 到 github 获取 kex_exchange_identification 提示

© www.soinside.com 2019 - 2024. All rights reserved.