Tonkon
Tonkon

Reputation: 41

Git clone from TFS error: RPC failed; result=22, HTTP code = 401

I'm currently trying to clone a repository from TFS on my Mac but got below error:

$ git clone https://tfs.xx.com/yy/_git/Mobile
Cloning into 'Mobile'...
Username for 'https://tfs.xx.com': xxx
Password for 'https://[email protected]': 
error: RPC failed; result=22, HTTP code = 401
fatal: The remote end hung up unexpectedly

Environment:

Googled several possible solutions but all failed.

  1. increase http post buffer

    git config --global http.postBuffer 524288000

  2. cache credentials in the secure keychain

    git config --global credential.helper osxkeychain

  3. upgrade git to the latest version v2.6.4 (uninstalled after failed)

I suspect that the root case might be the authentication config on the TFS server. TFS server block access which is not based on NTLM of window. Saying so, my evidence is that when I run git with GIT_CURL_VERBOSE=1. It showed more details and at the end of the log. There's message:

* NTLM handshake rejected
* Authentication problem. Ignoring this.

A part of detail log on Mac:

$ GIT_CURL_VERBOSE=1 git clone https://tfs.xx.com/yy/_git/Mobile
Cloning into 'Mobile'...
...................
* upload completely sent off: 154 out of 154 bytes
< HTTP/1.1 401 Unauthorized
< Content-Type: text/html
< Server: Microsoft-IIS/8.0
< X-TFS-ProcessId: f00df4b5-6907-4ccd-818c-773f01ee3961
< X-FRAME-OPTIONS: SAMEORIGIN
< Access-Control-Allow-Origin: *
< Access-Control-Max-Age: 3600
< Access-Control-Allow-Methods: OPTIONS,GET,POST,PATCH,PUT,DELETE
< Access-Control-Expose-Headers: ActivityId,X-TFS-Session
< Access-Control-Allow-Headers: authorization
< Set-Cookie: Tfs-SessionId=d13bcac7-856f-4435-b94b-b2f2d24b2dd1; path=/
< Set-Cookie: Tfs-SessionActive=2016-01-13T06:01:32; path=/
* NTLM handshake rejected
* Authentication problem. Ignoring this.
< WWW-Authenticate: NTLM
< X-Powered-By: ASP.NET
< P3P: CP="CAO DSP COR ADMa DEV CONo TELo CUR PSA PSD TAI IVDo OUR SAMi BUS DEM NAV STA UNI COM INT PHY ONL FIN PUR LOC CNT"
< X-Content-Type-Options: nosniff
< Date: Wed, 13 Jan 2016 06:01:31 GMT
< Content-Length: 842
< Vary: Accept-Encoding
< Content-Encoding: gzip
< Age: 1
< Connection: keep-alive
< Via: 1.1 akamai (ACE 5.4.0/5.4.0)
* The requested URL returned error: 401
* Closing connection 1
error: RPC failed; result=22, HTTP code = 401
fatal: The remote end hung up unexpectedly

Well, when I called same command on Windows. It executed correctly. The difference is that windows showed:

* NTLM auth restarted

and continued. While Mac responded:

* NTLM handshake rejected
* Authentication problem. Ignoring this

and then stopped.

A part of detail log on windows

$ GIT_CURL_VERBOSE=1 git clone https://tfs.xx.com/yy/_git/Mobile
Cloning into 'Mobile'...
...................
* upload completely sent off: 154 out of 154 bytes
< HTTP/1.1 401 Unauthorized
< Content-Type: text/html
< Server: Microsoft-IIS/8.0
< X-TFS-ProcessId: f00df4b5-6907-4ccd-818c-773f01ee3961
< X-FRAME-OPTIONS: SAMEORIGIN
< Access-Control-Allow-Origin: *
< Access-Control-Max-Age: 3600
< Access-Control-Allow-Methods: OPTIONS,GET,POST,PATCH,PUT,DELETE
< Access-Control-Expose-Headers: ActivityId,X-TFS-Session
< Access-Control-Allow-Headers: authorization
< Set-Cookie: Tfs-SessionId=544cda47-3165-4087-ac40-324936afcb41; path=/
< Set-Cookie: Tfs-SessionActive=2016-01-13T07:30:30; path=/
* NTLM auth restarted
< WWW-Authenticate: NTLM
< X-Powered-By: ASP.NET
< P3P: CP="CAO DSP COR ADMa DEV CONo TELo CUR PSA PSD TAI IVDo OUR SAMi BUS DEM NAV STA UNI COM INT PHY ONL FIN PUR LOC CNT"
< X-Content-Type-Options: nosniff
< Date: Wed, 13 Jan 2016 07:30:30 GMT
< Content-Length: 842
< Vary: Accept-Encoding
< Content-Encoding: gzip
< Age: 0
< Connection: keep-alive
< Via: 1.1 akamai (ACE 5.4.0/5.4.0)
<
* Ignoring the response-body
* Connection #1 to host tfs.xx.com left intact
* Issue another request to this URL: 'https://tfs.xx.com/yy/_git/Mobile/git-upload-pack'
* Couldn't find host tfs.xx.com in the _netrc file; using defaults
* Found bundle for host tfs.xx.com: 0x5a0b70
* Re-using existing connection! (#1) with host tfs.xx.com
* Connected to tfs.xx.com (199.6.147.240) port 443 (#1)
* Server auth using NTLM with user 'szhao8'
> POST /yy/_git/Mobile/git-upload-pack HTTP/1.1
Host: tfs.xx.com
Authorization: NTLM *************************************************==
User-Agent: git/2.6.4.windows.1
Accept-Encoding: gzip
Content-Type: application/x-git-upload-pack-request
Accept: application/x-git-upload-pack-result
Content-Length: 0
...................
<
remote:
remote:                    fTfs
remote:                  fSSSSSSSs
remote:                fSSSSSSSSSS
remote: TSSf         fSSSSSSSSSSSS
remote: SSSSSF     fSSSSSSST SSSSS
remote: SSfSSSSSsfSSSSSSSt   SSSSS
remote: SS  tSSSSSSSSSs      SSSSS
remote: SS   fSSSSSSST       SSSSS
remote: SS fSSSSSFSSSSSSf    SSSSS
remote: SSSSSST    FSSSSSSFt SSSSS
remote: SSSSt        FSSSSSSSSSSSS
remote:                FSSSSSSSSSS
remote:                  FSSSSSSs
remote:                    FSFs    (TM)
remote:
remote:  Microsoft (R) Visual Studio (R) Team Foundation Server
remote:
* Connection #1 to host tfs.xx.com left intact| 5.52 MiB/s
Receiving objects: 100% (5768/5768), 31.25 MiB | 5.98 MiB/s, done.
Resolving deltas: 100% (3937/3937), done.
Checking connectivity... done.
Checking out files: 100% (1005/1005), done.

Is there anyone meet this problem before? Appreciate your feedback!

Upvotes: 0

Views: 1188

Answers (1)

anand mishra
anand mishra

Reputation: 900

Some time this problem occur due to slow network speed.Try to clone repository on a better network speed.

Upvotes: 1

Related Questions