在CONNECT之后,git从代理返回http错误407

时间:2014-07-23 09:45:32

标签: git github proxy

使用git连接到我的电脑上的github时遇到问题。 System Win 7。

我通过代理连接,所以我在git配置文件中指定了它(通常在git文件夹和git repo文件夹中)。为此,我进入了我的git bush的下一行:

$ git config --global http.proxy http://<username>:<userpsw>@<proxy>:<port>

它在其他程序上运行的方式(例如:maven)看起来像这样:

<username> - my login to our corp system
<userpsw> -my password to corporat system
<proxy> - 10.65.64.77
<port> - 3128

但是当我尝试推送或克隆我的回购时,我会收到

fatal: unable to access '<repo githup link>' Received HTTP code 407 from proxy after CONNECT

我尝试不仅输入我的用户名,还输入域名\用户名,在代码语言表出现问题时更改了我的密码。我甚至输入了错误的密码。错误保持不变。

当我进入&#39; 10.65.64.177.com&#39;并试图推销回购,我收到了:

fatal: unable to access '<repo github link>': Failed connect to github.com:3128; No error

只是不知道该尝试什么。

21 个答案:

答案 0 :(得分:68)

对我来说有用的东西类似于rohitmohta提出的建议;在常规的DOS命令提示符下(不是在git bash上):

第一

git config --global http.proxy http://username:password@proxiURL:proxiPort

在某些情况下还

git config --global https.proxy http://username:password@proxiURL:proxiPort

然后

git config --global http.sslVerify false

(我确认它是必要的:如果设置为true获得&#34; SSL证书问题:无法获得本地颁发者证书&#34;错误)

在我的情况下,不需要定义all_proxy变量

最后

git clone https://github.com/someUser/someRepo.git

答案 1 :(得分:31)

我必须在.gitconfig中使用

设置所有4件事
git config --global http.sslVerify false
git config --global https.sslVerify false
git config --global http.proxy http://user:pass@yourproxy:port
git config --global https.proxy http://user:pass@yourproxy:port

只有这样克隆才成功。

答案 2 :(得分:29)

也许您已经在使用系统代理设置 - 在这种情况下取消设置所有git代理将起作用:

git config --global --unset http.proxy
git config --global --unset https.proxy

答案 3 :(得分:19)

我在公司防火墙后面遇到过类似的问题。做了以下操作,并且能够使用运行Windows 7 SP1的系统中的git shell克隆存储库。

  1. 设置all_proxy&#39;您的用户的环境变量。 curl要求。

    export all_proxy=http://DOMAIN\proxyuser:proxypwd@proxy.server.com:8080
    
  2. 设置&#39; https_proxy&#39;您的用户的环境变量。 curl要求。

    export https_proxy=http://DOMAIN\proxyuser:proxypwd@proxy.server.com:8080
    
  3. 我不确定这是否有任何影响。但我做到了这一点并且有效:

    git config --global http.sslverify false
    
  4. 使用https://进行克隆

    git clone https://github.com/project/project.git
    
  5. 注1:请勿使用http://。使用它可以给出以下错误。可以使用https://。

    解决
     error: RPC failed; result=56, HTTP code = 301
    

    注2:避免在密码中使用@。可以使用$。

答案 4 :(得分:6)

我在Windows环境中遇到了同样的问题。

我刚刚解决了NTLM-APS(Windows NT身份验证代理服务器)

配置你的NTML代理并将Git设置为它:

git config --global http.proxy http://<username>:<userpsw>@localhost:<port>

答案 5 :(得分:6)

需要以下命令来强制git将凭据和身份验证方法发送到代理:

git config --global http.proxyAuthMethod 'basic'

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

答案 6 :(得分:3)

Android Studio出现407错误。尝试添加代理,但什么都没发生。发现它与公司证书有关,所以我从浏览器中导出了一个并将其添加到Git中。

从网络浏览器导出

互联网选项&gt;内容&gt;证书&gt;导出(关注向导,我选择格式&#34; Base 64编码X.509(.CER))

在Git Bash中

git config --global http.sslCAInfo c:\Utilities\Certificates\my_certificate

以下页面很有用 https://blogs.msdn.microsoft.com/phkelley/2014/01/20/adding-a-corporate-or-self-signed-certificate-authority-to-git-exes-store/

添加代理,就像我使用的其他线程一样

git config --global http.proxy proxy.company.net:8080
git config --global https.proxy proxy.company.net:8080

答案 7 :(得分:2)

仅供参考以供参考

这本来是解决以下错误的合适解决方案

Received HTTP code 407 from proxy after CONNECT

因此以下命令应该是必需的

git config --global http.proxyAuthMethod 'basic'
git config --global https.proxy http://user:pass@proxyserver:port

这将生成以下配置

$ cat ~/.gitconfig
[http]
        proxy = http://user:pass@proxyserver:port
        proxyAuthMethod = basic

答案 8 :(得分:1)

您的密码似乎不正确。重新检查您的凭据。

答案 9 :(得分:1)

我遇到了同样的问题,所以首先我检查了我的npm文件我设置了什么,我用这个命令检查了: -

npm config get proxy

我发现我设置了错误的代理,我设置了我的欲望代理如下:

npm config set proxy http://xxx.xxx.xxx.4:8080   
npm config set https-proxy http://xxx.xxx.xxx.4:8080

之后它对我有用

答案 10 :(得分:1)

我也遇到了同样的问题,并试图通过将http.proxyAuthMethod显式设置为basic来解决该问题。

在服务器和代理之间运行pcap跟踪后,我注意到“ 在git克隆期间发送到代理的“ HTTP CONNECT”请求仍然没有将“ Proxy-Authorization”标头设置为基本。这是由于我的git版本“ 1.8.3.1”不支持http.proxyAuthMethod。

在安装最新的git版本(2.16.6)之后,在此处使用{https://repo.ius.io/7/x86_64/packages/g/”的rpm软件包,将http.proxyAuthMethod设置为basic最终会影响git的行为,然后我的git克隆成功了。 / p>

我希望这会有所帮助

答案 11 :(得分:1)

我的组织遇到了同样的问题。

经过多次尝试,我找到了以下解决方案:

  1. 我向系统管理员申请将代理身份验证类型从Kerberos更改为NTLM。我不确定这是否是强制性的(我在这件事上是无知的),但我的申请获得批准。

  2. 之后我添加了Git设置

    git config --global http.proxyauthmethod ntlm

  3. 之后我才能克隆我的存储库

答案 12 :(得分:0)

我尝试了所有解决方案,但没有一个奏效。然后我看到了我的 .gitconfig 文件。它有多个重复条目,其中一些不正确(因为我尝试了多种解决方案)。最后,我删除了所有多余和不需要的设置,只保留了 Sairam Kukadala 在上面的回答中提到的四个设置,瞧!它奏效了。

答案 13 :(得分:0)

从密码中删除“ @”对我有用 无论如何都不要在密码中使用@ 它会给您Maven和进一步安装的问题

答案 14 :(得分:0)

使用Git Bash时遇到了相同的问题。当我在命令提示符中执行相同的操作时,它可以完美运行。

答案 15 :(得分:0)

使用sourcetree时遇到相同的问题 原因可能是在打开sourcetree时将系统代理从打开切换为关闭。 由于某种原因,它已写入项目的配置文件中。 可以通过“设置”->“编辑配置文件”在源树上轻松删除它。 只需在http

下将其删除即可

答案 16 :(得分:0)

此配置适用于我的设置:

[http]
    proxy = <your proxy>
[https] proxy = <your proxy>
[http]
    sslVerify = false
[https]
    sslVerify = false   
[credential]
    helper = wincred 

答案 17 :(得分:0)

我遇到了这个错误,因为我的公司网络在内部使用一个代理,而第二个(完全不同的)代理来自外部的VPN。我最初是为内部部署代理配置的,收到了错误,然后在其他地方工作时不得不更新我的配置以使用备用的,非现场的代理。

答案 18 :(得分:0)

这个问题几天前发生在我的Bitbucket存储库中。我能够通过将远程URL设置为http而不是https来修复它。

我也尝试在命令行和git config中设置https代理,但这没有用。

$ git pull
fatal: unable to access 'https://username@bitbucket.org/sacgf/x.git/': Received HTTP code 407 from proxy after CONNECT

请注意,我们使用的是https:

$ git remote -v
origin  https://username@bitbucket.org/sacgf/x.git (fetch)
origin  https://username@bitbucket.org/sacgf/x.git (push)

将https网址替换为http网址:

$ git remote set-url origin http://username@bitbucket.org/sacgf/x.git
$ git pull
Username for 'https://bitbucket.org': username
Password for 'https://username@bitbucket.org': 
remote: Counting objects: 43, done.
remote: Compressing objects: 100% (42/42), done.
remote: Total 43 (delta 31), reused 0 (delta 0)
Unpacking objects: 100% (43/43), done.
From http://bitbucket.org/sacgf/x
   a41eb87..ead1a92  master     -> origin/master
First, rewinding head to replay your work on top of it...
Fast-forwarded master to ead1a920caf60dd11e4d1a021157d3b9854a9374.
d

答案 19 :(得分:0)

我认为在你达到这一点后你应该集中精力:

fatal: unable to access '<repo githup link>' Received HTTP code 407 from proxy after CONNECT

这意味着您尚未使用代理进行适当的身份验证。您能否仔细检查您在此步骤中提供的密码是否正确?

git config --global http.proxy http://<username>:<userpsw>@<proxy>:<port>

答案 20 :(得分:-1)

我有类似的问题,我解决了以下步骤:

**在git **中添加代理详细信息

git config --global http.sslVerify false
git config --global https.sslVerify false
git config --global http.proxy http://user:pass@yourproxy:port
git config --global https.proxy http://user:pass@yourproxy:port