git - GitHub Error - "ssh: connect to host github.com port 22: Operation timed out fatal: Could not read from remote repository."

ID : 131350

viewed : 5

Tags : gitgithubgit

Top 5 Answer for git - GitHub Error - "ssh: connect to host github.com port 22: Operation timed out fatal: Could not read from remote repository."

vote vote

92

I have had this same problem the solution was edit ~/.ssh/config and put this lines:

Host github.com   Hostname ssh.github.com   Port 443 

If there is no file config in this folder, simply create one.

vote vote

83

That indicates that the git software cannot connect to Github through SSH: this often happens if your firewall, or the firewall set up by your ISP, blocks SSH connections on port 22. A quick workaround to see if this is the problem is to try the HTTPS URL provided by Github:

git remote add origin-https https://github.com/alicht/tweetanuber.git git push -u origin-https master 

If that works, then it's definitely your SSH port being closed. You could continue to use this alternate syntax, try to get port 22 unblocked on your computer or at your ISP, or check out the suggestion at https://stackoverflow.com/a/8081292/27310 and see if that works for you.

vote vote

75

The reason could be the firewall modification as you are under a network.(In which case they may deliberately block some ports): Which in my case I'm on the library and the firewall is blocking. For this work's do on terminal:

git config --local -e 

and change this(using vim you need to type the keyboard 'i' for insert):

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

for this:

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

Then for save(type the keyboard ESC and then type wq! and Enter).

Then try to push again.

vote vote

66

One of possible issues is network. To verify this check if outbound port 22 is open:
netcat nc -v portquiz.net 22 or with telnet telnet portquiz.net 22
Sample output for port 22

nc: connectx to portquiz.net port 22 (tcp) failed: Operation timed out 

Sample output for port 80

found 0 associations found 1 connections:      1: flags=82<CONNECTED,PREFERRED>     outif en4     src 192.168.0.103 port 55443     dst 5.196.70.86 port 80     rank info not available     TCP aux info available  Connection to portquiz.net port 80 [tcp/http] succeeded! 

tip about portquiz from Link

Possible solutions:

  • Change git config Link
  • Use VPN
  • Use mobile hotspot
  • Open port 22
vote vote

52

This was driving me crazy. Most likely the port 22 is blocked either by your firewall or your provider. Quick workarround is to change from git@github.com:USERNAME/REPO.git to **ssh://git@ssh.github.com:443**/USERNAME/REPO.git

Top 3 video Explaining git - GitHub Error - "ssh: connect to host github.com port 22: Operation timed out fatal: Could not read from remote repository."

Related QUESTION?