本文介绍了如何设置 Git 通过代理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在工作时连接到GitHub,需要通过http代理.我可以使用命令使用 cURL 退出 FTP

I want to connect to GitHub at work and need to get through the http proxy. I am able to get out for FTP using cURL using the command

curl -v -g --ftp-pasv --upload-file MYFILE --proxy PROXYADDRESS:PROXYPORT --proxy-ntlm --proxy-user WINDOWSDOMAINWINDOWSUSER:WINDOWSPASSWORD ftp://FTPUSER:FTPPASS@FTPURL/

到目前为止,我还无法为 Git 提供等效的设置.

I've so far not been able to provide equivalent settings for Git.

我尝试按照 通过 Draconian 代理使用 Github 下的说明进行操作cygwin.

I tried following instructions on Using Github Through Draconian Proxies under cygwin.

我已经安装了 corkscrew 并尝试通过 SSH 连接到 GitHub

I've got corkscrew installed and tried to SSH to GitHub

ssh github.com

ssh ssh.github.com

我回来了

ssh:无法解析主机名 ssh.github.com:提供的主机名或服务名,或未知.

我试过设置 http 和 https 代理.

I've tried setting the http and https proxy.

这是 git --config -l 的输出

Here is the output from git --config -l

core.symlinks=false
core.autocrlf=true
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
pack.packsizelimit=2g
help.format=html
http.sslcainfo=C:/Program Files/Git/bin/curl-ca-bundle.crt
sendemail.smtpserver=/bin/msmtp.exe
diff.astextplain.textconv=astextplain
user.name=Peter Wilkinson
user.email=someemail@gmail.com
github.user=ProggerPete
github.token=shouldprobablykeepthissecret
http.proxy=http://somedomainsomeuser:somepass@10.167.116.142:80
https.proxy=http://somedomainsomeuser:somepass@10.167.116.142:80

我也跑了

export https_proxy=http://somedomainsomeuser:somepass@10.167.116.142:80
export http_proxy=http://somedomainsomeuser:somepass@10.167.116.142:80
set https_proxy=http://somedomainsomeuser:somepass@10.167.116.142:80
set http_proxy=http://somedomainsomeuser:somepass@10.167.116.142:80

然后我尝试克隆并获取.

I then try and clone and get.

$ git clone https://ProggerPete@github.com/project/JavaScript-Maven-Plugin.git
Cloning into JavaScript-Maven-Plugin...
Password:
error: The requested URL returned error: 407 while accessing https://ProggerPet
@github.com/project/JavaScript-Maven-Plugin.git/info/refs

fatal: HTTP request failed

在我看来,我的代理身份验证失败了.但是,我使用的是通过 cURL 用于 FTP 的相同登录名和密码.

This looks to me like I'm failing authentication with the proxy. However I'm using the same login and pass that works for FTP via cURL.

如何连接?

推荐答案

经过一番折腾,我终于偶然发现了 http://cntlm.sourceforge.net/.是理解ntlm认证的proxy代理.

After much head bashing I finally stumbled across http://cntlm.sourceforge.net/. It's a proxy proxy that understands ntlm authentication.

我安装了它并告诉它有关 http 代理的信息.然后将 git 指向 CNTLM,一切都开始工作了.

I installed it and told it about the http proxy. Then pointed git at CNTLM and it all started working.

我发现这让我非常沮丧,所以希望这能帮助处于相同情况的其他人.

I found getting this going very frustrating so hopefully this will help someone else in the same situation.

这篇关于如何设置 Git 通过代理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-18 08:01
查看更多