2017-08-05 179 views
0

我无法在git中将ssh传递给github或bitbucket或gitlab。
我通常有以下错误信息:我该如何避免它?ssh连接超时

==========输出============

ssh -T [email protected] -i ~/.ssh/id_rsa -v 
OpenSSH_7.2p2 Ubuntu-4ubuntu2.2, OpenSSL 1.0.2g 1 Mar 2016 
debug1: Reading configuration data /etc/ssh/ssh_config 
debug1: /etc/ssh/ssh_config line 19: Applying options for * 
debug1: Connecting to github.com [192.30.255.113] port 22. 
debug1: connect to address 192.30.255.113 port 22: Connection timed out 
debug1: Connecting to github.com [192.30.255.112] port 22. 
debug1: connect to address 192.30.255.112 port 22: Connection timed out 
ssh: connect to host github.com port 22: Connection timed out 
+0

我建议先用telnet测试连接:'telnet github.com 22'。如果此测试成功,您可以排除防火墙并知道sshd正在运行。 – Cyrus

+0

不要担心,ssh问题(所有18K)都是关于主题的,特别是当它们与Git相关时,它是用于开发的工具。 – VonC

+0

@Cyrus它不工作 的telnet:无法连接到远程主机:连接超时 不仅与github上也到位桶和gitlab。 –

回答

-1

此错误消息是典型当

  • 远程ssh守护进程没有运行(这是不是在这里关于GitHub的,到位桶或GitLab的情况下)
  • 本地端口22被阻止传出连接(通常是在企业工作时的情况:只有HTTP(S)是开放的,而不是SSH )

的OP确认ISP已阻止端口22

看看你是否可以使用HTTPS URL来代替:

cd /path/to/my/local/repo 
git remote set-url origin https://github.com/<user>/<repo> 

注意与trystack,则可能需要follow this gist

单击安全组选项卡,单击编辑规则,并添加几个规则:

imcp, from port: -1, to port: -1, cidr: 0.0.0.0/0 
tcp, from port: 22, to port: 22, cidr: your.ip.address.here/32 
+0

我在trystack中创建了一个实例,并尝试将其添加到ssh中,但它也失败了。 相同的连接超时。 我在[free-public-ssh-server-for-testing-purposes]中提到了[SDF](http://sdf.org/)(https://serverfault.com/questions/185153/free-public -ssh-server-for-testing-purpose),它也失败了。 –

+0

@SARAVANANSYR与“超时”相同的错误消息?那边的git版本是什么? – VonC

+0

@ VonC git版本2.13.3。我tink有一些问题ssh –

0

ISP已阻塞端口22. 已解决

0

杀死SSH进程并重新启动它。它解决了我类似的问题。我发现SSH的多个实例,在这种情况下,你必须全部杀死它们。