georw
georw

Reputation: 43

Git clone works with https but not SSH when using Proxy

In my area, download speed is too slow when git clone. So I use Shadowsocks as my proxy on Macbook Mojave, but shadowsocks can't supply proxy for terminal directly, therefore I use Proxifier as transition. The terminal is iTerm2. They are all the background.

When using proxy, the git clone with ssh can't work and the error is

git clone [email protected]:zergtant/pytorch-handbook.git  
Cloning into 'pytorch-handbook'...
ssh_exchange_identification: Connection closed by remote host
fatal: Could not read from remote repository.

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

But git clone work well with https when using proxy.

Could anyone give me some hint about this problem?

Thank you very much for helping.

Upvotes: 3

Views: 1900

Answers (1)

VonC
VonC

Reputation: 1330102

You would need to:

That is:

git config --global http.proxy 'socks5://127.0.0.1:1080'
git config --global https.proxy 'socks5://127.0.0.1:1080'

(replace 1080 by your proxyfier port in your case)


The OP georw reports in the comments it does work with Shadowsocks alone, but not in combination with Proxifier.

Proxifier is configured well to proxy socks.

When the error occurs, logs of Proxifier is

ssh-github. 
 Com:22 open through proxy127.0.0.1:10801 SOCKS5 
ssh-github. 
 Com:22 close21 bytes sent0 bytes received lifetime <1 sec. 

So I found the reason is caused by ssh command.
When I input ssh -vvv [email protected] in the terminal, the output error is

ssh_exchange_identification: Connection closed by remote host. 

Upvotes: 4

Related Questions