git - 无法使用 ssh 进行 git clone、push、pull,引发 kex_exchange_identification 错误
问题描述
在 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 可能是错误的,所以我~/.ssh/id_rsa
在另一台 Linux 服务器上使用了相同的密钥,它可以正常工作。
> ssh -T git@github.com
Hi weleen! You've successfully authenticated, but GitHub does not provide shell access.
我发现了一些类似的问题,但没有解决。
解决方案
如果您将 remote-ulr 从 SSH 切换到 HTTPS,它应该可以工作。
推荐阅读
- android-studio - How can you set an OnChangeListener to a radio_group in android with ActivityMainBinding?
- javascript - 如何使用reduce将数组中的相似项目组合在一起并使用arr.reduce返回一个objext?
- android - 如何在 by esys-flutter-share 插件中检查用户是否共享了某些内容
- flutter - 如何压缩来自 multi_image_picker 颤振的图像资产?
- typescript - 关于 TypeScript 联合类型的困惑
- java - JSON Array get JsonObject 总是返回空
- batch-file - CMD:按文件夹结构对文件进行排序
- hdfs - hdfs 将文件夹复制到网络文件系统最终出错
- swift5 - Swift 5:我的导航栏中的 barbutton 不合适
- paypal - paypal-checkout-sdk 捕获功能仅捕获一次 如何在第二次发生致命错误时修复它