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

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


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 git@github.com 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 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


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?