【问题标题】:Corporate Proxy Azure Devops with Git使用 Git 的企业代理 Azure Devops
【发布时间】:2019-05-05 04:03:33
【问题描述】:

我在 Azure Dev-Ops 中创建了一个项目和存储库。 我们坐在公司代理后面,想从这个项目中克隆。

我已将环境变量 http_proxy、https_proxy、HTTP_PROXY、HTTPS_PROXY、git config --global https.proxy、git config --global http.proxy 设置为以下匹配的 http 或 https 版本 http://domain\username:password@ProxAddr:Proxy 要么 https://domain\username:password@ProxAddr:Proxy

当我运行 git clone https://username:pwd@dev.azure.com/username/ProjectName/_git/RepoName 时,我收到以下错误。

Cloning into 'ProjectName'...
* Couldn't find host dev.azure.com in the .netrc file; using defaults
*   Trying {proxyip} ...
* Connected to {proxyip} ({proxyip}) port {proxyport} (#0)
* Establish HTTP proxy tunnel to dev.azure.com:443
> CONNECT dev.azure.com:443 HTTP/1.1
Host: dev.azure.com:443
User-Agent: git/2.7.4
Proxy-Connection: Keep-Alive

< HTTP/1.1 407 Proxy Authentication Required
< Proxy-Authenticate: NEGOTIATE
< Proxy-Authenticate: NTLM
< Proxy-Authenticate: BASIC realm="{CORPRELM}"
< Cache-Control: no-cache
< Pragma: no-cache
< Content-Type: text/html; charset=utf-8
< Proxy-Connection: close
< Connection: close
< Content-Length: 849
<
* Ignore 849 bytes of response-body
* Connect me again please
* found 148 certificates in /etc/ssl/certs/ca-certificates.crt
* found 592 certificates in /etc/ssl/certs
* ALPN, offering http/1.1
* gnutls_handshake() failed: Error in the push function.
* Closing connection 0
* Couldn't find host dev.azure.com in the .netrc file; using defaults
* Hostname {proxyip} was found in DNS cache
*   Trying {proxyip}...
* Connected to {proxyip} ({proxyip}) port {proxyport}(#1)
* Establish HTTP proxy tunnel to dev.azure.com:443
> CONNECT dev.azure.com:443 HTTP/1.1
Host: dev.azure.com:443
User-Agent: git/2.7.4
Proxy-Connection: Keep-Alive

< HTTP/1.1 407 Proxy Authentication Required
< Proxy-Authenticate: NEGOTIATE
* gss_init_sec_context() failed: : SPNEGO cannot find mechanisms to negotiate
< Proxy-Authenticate: NTLM
< Proxy-Authenticate: BASIC realm="{CORPREALM}"
< Cache-Control: no-cache
< Pragma: no-cache
< Content-Type: text/html; charset=utf-8
< Proxy-Connection: close
< Connection: close
< Content-Length: 849
<
* Received HTTP code 407 from proxy after CONNECT
* Closing connection 1
fatal: unable to access 'https://username:devopspwdF@dev.azure.com/username/DevOpsProject/_git/DevOpsRepo/': gnutls_handshake() failed: Error in the push function.

错误似乎是这样的?

< Proxy-Authenticate: NEGOTIATE
* gss_init_sec_context() failed: : SPNEGO cannot find mechanisms to negotiate

我需要明确说明什么吗?

【问题讨论】:

    标签: git azure-devops


    【解决方案1】:

    您的代理似乎配置错​​误,并且提供了它无法支持的身份验证机制(在本例中为协商)。您可以通过将http.proxyAuthMethod 选项设置为合适的值来解决此问题。根据输出,您可能希望使用ntlmbasic

    此外,您可以对主机名与*.azure.com 匹配的所有HTTPS URL 使用git config http.https://*.azure.com/.proxyAuthMethod ntlm 之类的内容,以基于每个URL 或模式进行设置。

    【讨论】:

    • 谢谢,这有助于走得更远。我设置了参数,尽管阅读文档表明它会产生影响,但它没有影响。我直接运行 curl(由 git 封装)并在握手时发送以下被 git 省略的行。 'Proxy auth using Basic with user '{domain}}\{username}' 和 'Server auth using Basic with user '{username}'' 这些在运行 git 时被省略。
    • 这可能是因为您使用的 Git 版本太旧。您需要 Git 2.8.0 才能使配置中存在该选项。看起来您使用的是 2.7.4。
    【解决方案2】:

    更新到较新版本的 git 可以解决此问题。

    【讨论】:

      猜你喜欢
      • 2015-11-18
      • 1970-01-01
      • 2017-08-02
      • 2019-06-10
      • 2020-04-30
      • 2019-11-02
      • 2021-05-13
      • 1970-01-01
      • 2021-07-07
      相关资源
      最近更新 更多