0

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?

halfer
  • 19,824
  • 17
  • 99
  • 186
AndreaNobili
  • 40,955
  • 107
  • 324
  • 596
  • 1
    That port 22 is most probably closed on the proxy server. Try to clone via https - (https://github.com/AndreaNobili/recipes.git). That should work cause port 443 should be open on a web proxy – sestus Aug 17 '16 at 10:00
  • Try setting `http_proxy` environment variable. If you already have `HTTP_PROXY` environment variable set, try the lower case version. – Shubham Vasaikar Aug 17 '16 at 10:02
  • @ShubhamVasaikar I have http_proxy setted, I am under Windows so I think that is not case sensitive – AndreaNobili Aug 17 '16 at 10:07
  • @sestus How can I clone via https instead via SSH? – AndreaNobili Aug 17 '16 at 10:08
  • @AndreaNobili when you go to your github repo page on the website and click on the green `Clone or Download` button, you should see a `Use HTTPS` option there. – Shubham Vasaikar Aug 17 '16 at 10:15
  • 2
    @AndreaNobili use this: `git clone https://github.com/AndreaNobili/recipes.git` – sestus Aug 17 '16 at 10:16

2 Answers2

1

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
Edward Thomson
  • 74,857
  • 14
  • 158
  • 187
0

Looks like you need to set the environment variable as http_proxy as curl and libcurl don't seem to recognize upper case variable HTTP_PROXY.

This link elaborates more on that:

The variable "HTTP_PROXY", using all caps, is no longer permitted/understood (since 7.7.2 actually).

Here's why: When CGI scripts get executed from within web servers, they usually get environment variables set before the script is executed. Headers in the incoming request that activate the script get converted to variables named HTTP_[header].

So, if anyone wrote a CGI script that in turn was using curl, you could actually trick curl to use a http proxy of your choice by passing a 'Proxy: [yada yada]' header.

http_proxy', using lower case, on the other hand is perfectly understood by curl.

Shubham Vasaikar
  • 698
  • 9
  • 23
  • If you see my original post I have correctly setted the http_proxy. What you means that it have to be setted as curl? – AndreaNobili Aug 17 '16 at 10:18
  • No, you don't have to set anything as `curl`. `curl` is a URL transfer library. But since, you are using Windows, the case for the environment variables should not matter. – Shubham Vasaikar Aug 17 '16 at 10:24