简体   繁体   English

Github - 无法通过ssh连接

[英]Github - can't connect via ssh from time to time

Situation 情况

I'm using linux ( mint mate 17.2 ), when push to github via ssh, from time to time connection fails, usually it resume after reboot computer & network. 我正在使用linux( mint mate 17.2 ),当通过ssh推送到github时,连接失败,通常在重新启动计算机和网络后恢复。 After several days, it might become bad again, quite confusing. 几天后,它可能会再次变坏,相当令人困惑。

Push via http never has such issue, but it requires password which is not convenient. 通过http推送从来没有这样的问题,但它需要密码,这是不方便的。

Debug info 调试信息

When push via ssh: 当通过ssh推送时:

debug1: Connecting to github.com [192.30.252.129] port 22. debug1:连接到github.com [192.30.252.129]端口22。

It stuck at the above line. 它停留在上面一行。

Then after a long wait, get timeout tip: 经过漫长的等待,得到超时提示:

debug1: connect to address 192.30.252.129 port 22: Connection timed out debug1:连接到地址192.30.252.129端口22:连接超时

ssh: connect to host github.com port 22: Connection timed out ssh:连接到主机github.com端口22:连接超时

fatal: Could not read from remote repository. 致命:无法从远程存储库读取。

Questions: 问题:

What could be the reason, how to fix that? 可能是什么原因,如何解决这个问题?


More debug info: 更多调试信息:

ping is good: ping很好:

eric@eric-pc:~$ ping 192.30.252.129
PING 192.30.252.129 (192.30.252.129) 56(84) bytes of data.
64 bytes from 192.30.252.129: icmp_seq=1 ttl=50 time=345 ms
64 bytes from 192.30.252.129: icmp_seq=2 ttl=50 time=452 ms
64 bytes from 192.30.252.129: icmp_seq=3 ttl=50 time=373 ms
64 bytes from 192.30.252.129: icmp_seq=4 ttl=50 time=349 ms
64 bytes from 192.30.252.129: icmp_seq=5 ttl=50 time=346 ms
64 bytes from 192.30.252.129: icmp_seq=6 ttl=50 time=442 ms
64 bytes from 192.30.252.129: icmp_seq=7 ttl=50 time=344 ms

telnet is bad: telnet很糟糕:

eric@eric-pc:~$ telnet 192.30.252.129 22
Trying 192.30.252.129...

@Update: @Update:

I setup another computer in the same network, with the same ssh key, it succeed to push to github via ssh, while the original computer still get timeout. 我在同一个网络中设置另一台计算机,使用相同的ssh密钥,它成功通过ssh推送到github,而原始计算机仍然超时。

Actions: 操作:

  • Restart the network , it still can't connect. 重启网络 ,仍然无法连接。

  • Restart the ssh-agent , it still can't connect, the old process become a defunct ssh-agent process, while there is a new ssh-agent: 重新启动ssh-agent ,它仍然无法连接,旧的进程成为一个已经失效的ssh-agent进程,而有一个新的ssh-agent:

eric      2552  0.0  0.0      0     0 ?        Zs   Jan08   0:00 [ssh-agent] 
    eric     27080  0.0  0.0  10628   316 ?        Ss   15:26   0:00 ssh-agent
    eric     27168  0.0  0.0  17028  2548 pts/7    S+   15:27   0:00 grep --color=auto ssh-agent
  • Reboot linux , then ssh works, 重启linux ,然后ssh工作,

Guess: 猜测:

  • ssh-agent has issue, ssh-agent有问题,
  • github blocked my client due to some reason, github由于某种原因阻止了我的客户,

Actually, before ask, from google, I saw similar question, but none solved the issue, and none explained the reason. 实际上,在问之前,从谷歌,我看到了类似的问题,但没有一个解决了问题,没有人解释原因。

And this issue is really annoying, because I don't want to input password every time push, and also don't want to reboot my pc from time to time, any help? 而这个问题真的很烦人,因为我不想每次都输入密码,而且也不想不时重启我的电脑,有什么帮助吗?

Try changing your git default ssh port using the command $ git remote add origin ssh://user@host:1234/srv/git/example and your ssh port to 1234. you can use anyother port you like rather than 1234 (larger than 1000 are recommended).see if it can solve your problem. 尝试使用命令$ git remote add origin ssh://user@host:1234/srv/git/example和ssh端口更改你的git默认ssh端口到1234.你可以使用你喜欢的任何其他端口而不是1234(大于建议1000。)看看它是否可以解决您的问题。 :) :)

.try changing your ~/.ssh/config file if doesn't exit create one. .try如果不退出则改变你的〜/ .ssh / config文件。

Host github.com Port 22 Host * Port 1234

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM