2017-08-05 180 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的多個實例,在這種情況下,你必須全部殺死它們。