Reputation: 1549
I cannot clone a simple repository from Azure DevOps. OS: Ubuntu 18.10
I do this:
git clone https://myorganization.visualstudio.com/myproject/_git/myrepo/
I keep getting this message from Git:
fatal: Authentication failed for 'https://myorganization.visualstudio.com/myproject/_git/myrepo/'
I was reading the solutions of other people but none worked for me. I also tried this:
Authorization: Basic Base64Encoded(uname:PAT)
Authorization: Bearer PAT
Any clue why this is not working?
Upvotes: 44
Views: 79409
Reputation: 2412
I have had success using PAT like this;
git clone https://<domain>.visualstudio.com/<domain>/_git/<repository>
git clone https://<PAT>@<domain>.visualstudio.com/<domain>/_git/<repository>
No Username nor password should be required as the PAT should suffice.
Upvotes: 50
Reputation: 119
Upvotes: 0
Reputation: 291
This official guide procedure worked for me, but with one important point. When base64-encoding, one must put attention to non-printable characters.
The guide says:
MY_PAT=yourPAT # replace "yourPAT" with your actual PAT
B64_PAT=$(printf ":$MY_PAT" | base64)
git -c http.extraHeader="Authorization: Basic ${B64_PAT}" clone
https://dev.azure.com/yourOrgName/yourProjectName/_git/yourRepoName
Using "echo" instead of "printf" would insert a newline char, changing the base64 string (probably would work also with "echo -n" but I haven't tried). Also, do not include the username, as per the snippet above.
Used git 2.17.1 on Ubuntu 18.04.
Upvotes: 16
Reputation: 3
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.
Upvotes: -3
Reputation: 3341
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://[email protected]/my-org/my-proj/_git/my-repo'
Note that Azure DevOps job authorization scope may affect this
Upvotes: 2
Reputation: 2870
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 [email protected], 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.
Upvotes: 4
Reputation: 13
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
Upvotes: 1
Reputation: 443
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!
Upvotes: 30
Reputation: 1879
Try : First delete the git credentials from Credential manager. Try Generating a new personal access token to resolve this error
Go to security ->Personal access token->Add Give Description, select All scopes, click Create Token.
Copy the token and store it for later use. This token can now be used in place of password for the git user.
Upvotes: -4