Not sure if this question belongs in this forum but I'll give it a chance.

I'm trying to connect my Ubuntu with GitHub via a proxy so I can clone repositories via the git command.

I've followed the normal steps to add the proxy settings to the .gitconfig file in /var/www/. The settings are visible in the configfile:


Result when I try to access GitHub:

root@server:/var/www/# git clone https://github.com/CybOXProject/python-cybox.git
Cloning into 'python-cybox'...
fatal: unable to access 'https://github.com/CybOXProject/python-cybox.git/': Received HTTP code 407 from proxy after CONNECT

When running the git clone command a tcpdump reveals that it is trying to connect to our proxy but lacks the authentication method/credentials. This behaviour is substantiated by looking at the logs of the proxy. The connection is denied because it's not authenticating.

xxxx.55728 > servername.domain.http-alt: Flags [P.], cksum 0x1efc (incorrect -> 0xf2a3), seq 111:222, ack 2957, win 275, options [nop,nop,TS val 4130126559 ecr 801030698], length 111: HTTP, length: 111
        CONNECT github.com:443 HTTP/1.1
        Host: github.com:443
        User-Agent: git/2.14.1
        Proxy-Connection: Keep-Alive

An application running on the same server is using the proxy with the same authentication method/credentials with success.

Any suggestions?


Solved. I didn't realise that the following command is needed to force git to send the credentials and authentication method to the proxy:

git config --global http.proxyAuthMethod 'basic'

Source: https://git-scm.com/docs/git-config#git-config-httpproxyAuthMethod

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.