【发布时间】:2020-07-20 13:01:36
【问题描述】:
在 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 到 git@github.com,它返回
> 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
我的配置文件是
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 git@github.com
Hi weleen! You've successfully authenticated, but GitHub does not provide shell access.
我发现了一些类似的问题,但没有解决。
【问题讨论】:
-
我在 macOS BigSur 11.6.2 上遇到了同样的问题。我已经在做一个 React 项目,从 Github 远程拉和推分支。我让笔记本电脑处于睡眠模式几个小时,并在深夜错误地在父文件夹中安装依赖项,当我清理错误时,尝试重新克隆时出现此错误:
bash Cloning into 'react-project'... 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.