ssh: connect to host github.com port 22: Connection timed out
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.
For my case none of the suggested solutions worked so I tried to fix it myself and I got it resolved.
For me I am getting this error on my AWS EC2 UBUNTU instance, what I did to resolve it was to edit the ssh config (or add it if it does not exist).
sudo nano ~/.ssh/config
And I added the following
Host github.com
Hostname ssh.github.com
Port 443
Then, run the command ssh -T [email protected]
to confirm if the issue is fixed.
According to this
Sometimes, firewalls refuse to allow SSH connections entirely. If using HTTPS cloning with credential caching is not an option, you can attempt to clone using an SSH connection made over the HTTPS port. Most firewall rules should allow this, but proxy servers may interfere
Hopefully this helps anyone else who's having the same issue I did.
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 [email protected]
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 = [email protected]:username/repo.git
to
url = https://github.com/username/repo.git
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?
inside the .ssh folder Create "config" file
Host github.com
User git
Hostname ssh.github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
Port 443
Host gitlab.com
Hostname altssh.gitlab.com
User git
Port 443
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
I faced the same problem and couldn't find a working solution. I faced this problem while setting up a local server and the git couldn't connect through my proxy network but my workstation could. This was the output when I ran the command
ssh -vT [email protected]
ubuntu@server:~$ ssh -vT [email protected]
OpenSSH_7.2p2 Ubuntu-4ubuntu2.8, OpenSSL 1.0.2g 1 Mar 2016
debug1: Reading configuration data /home/ubuntu/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to github.com [13.234.176.102] port 22.
So I tried using an SSH connection made over the HTTPS port by editing the config file ~/.ssh/config
but to no avail.
Host github.com
Hostname ssh.github.com
Port 443
Finally, I found this article which solved and exposed the real problem.
# github.com
Host github.com
Hostname ssh.github.com
ProxyCommand nc -X connect -x <PROXY-HOST>:<PORT> %h %p
Port 443
ServerAliveInterval 20
User git
This is my config file and now git works perfectly well through ssh!