Search code examples
gitversion-controlgithub

Unable to push files to my github repository


I've set up git on my Ubuntu 12.04 LTS but whenever I try to push files to my remote repository (git push -u origin master), I get the following error-

ssh: connect to host github.com port 22: Connection timed out
fatal: The remote end hung up unexpectedly

What does this mean? and How can I fix it?


I installed Git using the following-

sudo apt-get install git

My local repository is here-

/media/48B9-FD83/foobar

it is not in the home directory, it is on a mounted drive (is that a problem?).

I initialized git in that directory and followed the steps given here - GitHub's official tutorial.

And when pushing the files, I get those ssh and fatal errors, mentioned above.

How can I fix this?


Solution

  • Try stuff in this order:

    • ping github.com. You should not see any timeouts.
    • sudo apt-get install telnet.
    • telnet github.com 22. You should see something like this:

     Trying 204.232.175.90...
     Connected to github.com.
     Escape character is '^]'.
     SSH-2.0-OpenSSH_5.5p1 Debian-6+squeeze1+github9
    

    • Exit out of telnet by typing Ctrl+] followed by Ctrl+d.
    • Follow steps mentioned in the Github: Generating ssh keys guide.
    • Make sure ~/.ssh and its contents are only readable to you by typing:

      • chmod 0755 ~/.ssh
      • chmod -R 0600 ~/.ssh/*
    • Next, ssh -T [email protected] should say:


    Hi <username>! You've successfully authenticated, but GitHub does not provide shell access.
    

    Report back if you see any error messages while trying any of these commands. Don't forget to post the error message you see in the comment.

    Best of luck!