ssh: connect to host github.com port 22: Connection timed out

匿名 (未验证) 提交于 2019-12-03 02:44:02

问题:

I am under a proxy and I am pushing in to git successfully for quite a while.
Now I am not able to push into git all of a sudden.
I have set the RSA key and the proxy and double checked them, with no avail and git is throwing me the error shown in the title of the page.

回答1:

The reason could be the firewall modification as you are under a network.(In which case they may deliberately block some ports)
To double check if this is the reason ... do

ssh -T git@github.com 

this should timeout. If that's the case use http protocol instead of ssh this way
just change your url in the config file to http.
Here is how :-

git config --local -e 

change entry of

 url = git@github.com:username/repo.git 

to

url = https://github.com/username/repo.git 


回答2:

Basic URL Rewriting

Git provides a way to rewrite URLs using git config. Simply issue the following command:

git config --global url."https://".insteadOf git:// 

Now, as if by magic, all git commands will perform a substitution of git:// to https://

source: git:// protocol blocked by company, how can I get around that?



回答3:

Execute:

nc -v -z <git-repository> <port> 

Your output should look like:

"Connection to <git-repository> <port> port [tcp/*] succeeded!" 

If you get:

connect to <git-repository> <port> (tcp) failed: Connection timed out 

You need to edit your ~/.ssh/config file. Add something like the following:

Host example.com Port 1234 


回答4:

I was having this same issue, but the answer I found was different, thought someone might come across this issue, so here is my solution.

I had to whitelist 2 IPs for port 22, 80, 443, and 9418:

  • 192.30.252.0/22

  • 185.199.108.0/22

In case these IP's don't work, it might be because they got updated, you can find the most current ones on this page.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!