Cannot clone git from Azure DevOps using PAT

后端 未结 8 1733
礼貌的吻别
礼貌的吻别 2020-12-15 07:11

I cannot clone a simple repository from Azure DevOps. OS: Ubuntu 18.10

I do this:

  • Got to Azure DevOps
  • Click on the top right corner on my use
相关标签:
8条回答
  • 2020-12-15 07:26

    I've experienced the same issue, and spent quite a while searching for a solution. I finally came across this post which contained a solution in the comments section by Martinius79.

    In short, it was required to pass the username and PAT, encoded as base64, through git http.extraheaders in order for it to authenticate.

    100% Credit to the original author, just including it here to assist others in locating it:

    Example: git -c http.extraheader="AUTHORIZATION: Basic TXlHaXRTeW5jVXNlcjo2bHFqNXJkcHEzdXBxZWVmd2o3bDduZXN5NTR3d3gxNHFobDVlanl5NTVkb2g0M3d4YzRh" clone https://tfs.address/tfs/Collection/Project/_git/RepoName

    Used basic token BASE64 encoded: TXlHaXRTeW5jVXNlcjo2bHFqNXJkcHEzdXBxZWVmd2o3bDduZXN5NTR3d3gxNHFobDVlanl5NTVkb2g0M3d4YzRh

    Basic Token BASE64 decoded: MyGitSyncUser:6lqj5rdpq3upqeefwj7l7nesy54wwx14qhl5ejyy55doh43wxc4a

    Token is constructed from : In this example: Fictional user name: MyGitSyncUser Used PAT: 6lqj5rdpq3upqeefwj7l7nesy54wwx14qhl5ejyy55doh43wxc4a

    I hope this helps!

    0 讨论(0)
  • 2020-12-15 07:26

    I was having the same problem and got it solved using HTTPS only.

    I figured out that I had to use the terminal only rather than using any "GUI shortcuts" dev.azure provides since they are meant for a git-credential-manager which works fine on windows but is broken for Ubuntu.

    Apparently, the dev.azure git repository has a different credentials (which you need to set up) rather than your Microsoft account credential.

    Let's say my Microsoft account username is johndoe@outlook.com, with its password Jd1986

    This credential will NOT work if you try for git cloning, as you need to generate git credential for your project and then use it.

    You can generate git credential from here,

    After this, Save it and use the set credential.

    Go to your terminal, and use the HTTP url for git clone and enter the given credential. This worked for me.

    0 讨论(0)
  • 2020-12-15 07:27

    Git http.extraheader & bearer

    YAML style Pipelines can use the preset variable System.AccessToken. After examining the formal 'Checkout ...' step at the beginning of the Pipeline I found this step to work in my script:

    - task: PowerShell@2
      inputs:
        targetType: 'inline'
        script: 'git -c http.extraheader="AUTHORIZATION: bearer $(System.AccessToken)" clone --depth 1 https://my-org@dev.azure.com/my-org/my-proj/_git/my-repo'
    

    Note that Azure DevOps job authorization scope may affect this

    0 讨论(0)
  • 2020-12-15 07:32

    Ensure you are a member of the Contributor group and that your permissions are not limited for your user or group on the azure repo.

    Azure Contributor group has per default permission to clone, fetch, and explore the contents of a repository; also, can create, comment on, vote, and contribute to pull requests.

    Any of this permissions can be edited by members of the Project Administrator Group or those having Manage permissions set to Allow for Git repositories as described here.

    If your group or user does not have the permission to clone the repository, you will get the behaviour described by the question.

    0 讨论(0)
  • 2020-12-15 07:35

    I have had success using PAT like this;

    1. copy clone url for your repository e.g. git clone https://<domain>.visualstudio.com/<domain>/_git/<domain>
    2. After you have copied you PAT use as;

    git clone https://<PAT>@<domain>.visualstudio.com/<domain>/_git/<domain>

    Username nor password should be required as the PAT should suffice.

    0 讨论(0)
  • 2020-12-15 07:42

    This is a known regression in curl 7.61.0, which ships with Ubuntu 18.10. The regression was fixed in curl 7.61.1, but Ubuntu 18.10 doesn't have this fix yet. See (and upvote) https://bugs.launchpad.net/ubuntu/+source/curl/+bug/1805203

    0 讨论(0)
提交回复
热议问题