Search code examples
gitgithubgit-clone

Why I can't clone this GitHub repository when I am under a proxy?


I am pretty new in Git and GitHub and I think I have some configuration problem.

Yesterday I have correctly configured the SSH connection between my local GIT and my GitHub account. It works fine.

Today I go to the office where I am under a proxy and using the same laptop I try to clone a remote repository (on my GitHub account) to my local repository.

The proxy is correctly setted on my Git, in fact doing:

$ git config --global http.proxy
http://XX.YY.ZZ.AAA:3228

That is the same proxy that I use to navigate on Internet that I have setted into the browser settings.

The problem is that when I try to clone my repository on GitHub into my local repository I obtain this error message:

$ git clone git@github.com:AndreaNobili/recipes.git
Cloning into 'recipes'...
ssh: connect to host github.com port 22: Connection timed out
fatal: Could not read from remote repository.

If I connect to Internet using my smartphone connection (that is not under proxy) it works fine.

Why? What am I missing?


Solution

  • Although you've configured an http proxy, you haven't instructed Git to use http - you've specified that it should use ssh to connect:

    $ git clone git@github.com:AndreaNobili/recipes.git
    

    And indeed, your error message is that ssh timed out:

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

    This happens because you have a firewall blocking your connection. Instead, specify the repository as an HTTP URL, and Git will use the corporate proxy you've configured:

    $ git clone https://github.com/AndreaNobili/recipes.git