首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >麦克:如果不改变一些东西,SSH就不能工作了。

麦克:如果不改变一些东西,SSH就不能工作了。
EN

Stack Overflow用户
提问于 2017-11-12 14:22:32
回答 2查看 6.7K关注 0票数 1

在网上搜索了一天,没有一个好的解决方案,我在这里告诉你我的问题。

三天前,我设置了一个SSH密钥,将git用于SSH。一切都很好,我能够把所有事情推到GitHub上。从昨天起我就不能再做了。我总是得到相同的错误(如下所示)。SSH-key是SSH代理的一部分,配置文件没有被更改,甚至不可能通过SSH连接到GitHub。在其他项目和其他回复中也进行了尝试,得到了同样的错误。在过去的几天里,我没有更新塞拉或者别的什么,所以这也不可能是原因。

终端输入和输出:

代码语言:javascript
运行
复制
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-连接:

代码语言:javascript
运行
复制
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以获得以下内容:

代码语言:javascript
运行
复制
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.

代码语言:javascript
运行
复制
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
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2017-11-14 10:39:07

对于所有寻找解决方案的人:我做了以下几次,然后成功了:

代码语言:javascript
运行
复制
User-MacBook-Pro:~ user$ ssh git@github.com
The authenticity of host 'github.com (192.30.253.112)' can't be established.
RSA key fingerprint is  <fingerprint>.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,192.30.253.112' (RSA) to the list of known hosts.
PTY allocation request failed on channel 0
Hi <username>! You've successfully authenticated, but GitHub does not provide shell access.
Connection to github.com closed.

现在,git和ssh又开始工作了。不知道为什么这个解决方案以前不起作用。

不管怎样,谢谢你的回复。

票数 0
EN

Stack Overflow用户

发布于 2017-11-12 15:00:14

代码语言:javascript
运行
复制
debug1: Connecting to github.com [192.30.253.113] port 443.
...
ssh_exchange_identification: Connection closed by remote host

"ssh_exchange_identification:由远程主机关闭的连接“是指远程服务器在接收该连接后立即故意关闭它。尚未发生密钥交换或身份验证尝试。

您正在连接到端口443 (HTTPS),而不是端口22 (SSH)。当我尝试这个错误时,我会得到同样的错误:

代码语言:javascript
运行
复制
$ ssh -p 443 git@github.com
ssh_exchange_identification: Connection closed by remote host
$ ssh  git@github.com
Permission denied (publickey).

连接到端口443会产生与您所得到的相同的错误。连接到适当的ssh端口至少会尝试身份验证(因为我没有在github上设置它),所以失败了。

显然,github不接受端口443上的ssh连接。改为连接到端口22。

编辑:

代码语言:javascript
运行
复制
ssh: connect to host github.com port 22: Connection refused

“连接拒绝”意味着您没有建立到远程服务器的TCP连接。在这种情况下,我的猜测是,这是由于您的本地网络内的防火墙,阻塞了传出的SSH连接。这可能就是为什么您首先要为SSH使用端口443。

正如@phd所指出的,github支持ssh到端口443,但您必须安排连接到"ssh.github.com“,而不是只连接"github.com”。请参阅github文件

或者,您可以与本地网络管理员讨论允许ssh访问github的问题。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47249917

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档