Search code examples
gitgithubsshgist

ssh: connect to host gist.github.com port 22: Operation timed out fatal: Could not read from remote repository


I am trying to push some code to a gist. I know there are a lot of other people with similar issues, and I have looked at all of the other posts I can find and they don't seem to address my problem.

➜  streamgraph git:(master) git push
ssh: connect to host gist.github.com port 22: Operation timed out
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

The majority of people are suggesting it is a problem with the ssh. However I went through a lengthy process of making sure my ssh keys were updated and I get this message when I test out the ssh, which as far as I understand means there isn't a problem with my ssh setup.

➜  streamgraph git:(master) ssh -T [email protected]
Hi adrianturcato! You've successfully authenticated, but GitHub does not provide shell access.

One last point the git commands were working earlier in the day and then all of a sudden stopped working. There was also a period of time when I would run the git command it wouldn't work, and then I would run it again and it would work. But now for the last 24 hours it has consistently not worked.

Is this a problem with the internet connection or perhaps the github servers?


Solution

  • So it seems that is in fact an error with gits SSH gist server.

    While this works:

    streamgraph git:(master) ssh -T [email protected]
    Hi adrianturcato! You've successfully authenticated, but GitHub does not provide shell access.
    

    This times out:

    streamgraph git:(master) ssh -T [email protected]
    

    How I fixed this:

    I changed the git config file in terminal to force it to use HTTPS:

    git config --global url."https://gist.github.com/".insteadOf [email protected]
    git config --global url."https://".insteadOf git://
    

    You can always change this by using:

    git config --global --edit
    

    But this still wasn't working due to the fact my github has 2fa. So I made another github account which I will use temporarily.