【发布时间】:2018-04-25 06:49:45
【问题描述】:
在网上搜索了一天没有好的解决方案后,我在这里告诉你我的问题。
三天前我设置了一个 SSH-key 来使用 git 和 SSH。一切正常,我能够将所有内容推送和拉取到 GitHub。从昨天开始,我不能再这样做了。我总是得到同样的错误(如下所示)。 SSH-key 是 ssh-agent 的一部分,配置文件没有更改,甚至无法通过 SSH 正常连接到 GitHub。也尝试了其他项目和其他 repos 并得到了同样的错误。最近几天我没有更新 Sierra 或其他内容,所以这也不是原因。
终端输入和输出:
User-MBP:data-analysis user$ git push -v origin master
Pushing to git@github.com:Username/data-analysis.git
ssh_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 连接:
User-MBP:data-analysis user$ ssh -v git@github.com
OpenSSH_7.4p1, LibreSSL 2.5.0
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: Connecting to github.com [192.30.253.113] port 443.
debug1: Connection established.
debug1: identity file /Users/user/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/user/.ssh/id_rsa-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.4
ssh_exchange_identification: Connection closed by remote host
感谢您的帮助!
更新
将端口改回 22 以获得以下内容:
User-MBP:data-analysis user$ git push origin master
ssh: connect to host github.com port 22: Connection refused
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
和
User-MBP:data-analysis user$ ssh -v git@github.com
OpenSSH_7.4p1, LibreSSL 2.5.0
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: Connecting to github.com [192.30.253.113] port 22.
debug1: connect to address 192.30.253.113 port 22: Connection refused
debug1: Connecting to github.com [192.30.253.112] port 22.
debug1: connect to address 192.30.253.112 port 22: Connection refused
ssh: connect to host github.com port 22: Connection refused
【问题讨论】: