登录失败,在 Azure DevOps 中使用 ctrl + c 取消 Git 的基本凭证提示

当在 Azure Repos 中成功克隆一个 git 存储库到我的本地机器克隆中时,我得到一行代码说:

Logon failed, use ctrl+c to cancel basic credential prompt

不知道这是什么意思,有什么想法吗?

我使用 PAT 令牌来验证我的克隆人,命令是:

git clone https://*************PAT*************@dev.azure.com/orgname/projectname/_git/reponame
111652 次浏览

It looks like in this case you actually have two sets of credentials that are in use, and Git has tried one and failed, and fallen back to the other one. This prompt comes up when the credential manager is invoked on Windows in case a prompt is displayed and you need to enter some credentials.

When you put a PAT in the URL like in this case, you need to put the PAT as the password. That means you need to specify a username, so your URL should start with something like https://username:password@dev.azure.com/. It isn't clear from your post whether you have the username: portion, so if you don't be sure to add one (it can be anything in this case; token and your username are common).

If you don't have a URL of that form, your PAT isn't being used, and you're likely falling back to whatever is in your credential manager, which is correct. Otherwise, it's possible that Git is preferring something in your credential manager which isn't correct, and falling back to something that is. Either way, you should inspect the credentials in Windows Credential Manager and delete any that are incorrect.

Just need to create the credentials from the azure. click on clone->click git credentials-> it will create the user name and password . use this password in jenkins job. It will work

I think that the problem is that you did not allowed your Agent job to acces the Auth token. Try to check this option for the agent job: enter image description here

Git http.extraheader & bearer

Manual 's answer helped put me on the right track.

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

Our company has 2 domains that we access DevOps:

https://vso[companyname].visualstudio.com

and

https://dev.azure.com/vso[companyname]

In the repos .gitsubmodule file I changed the URL from one to the other, and the build magically started working.

If you are using github repositories, you might need to check that you have not removed the rights of Azure Pipelines in your github Applications settings:

  • In your github profile settings, Applications, Azure Pipelines, Configure
  • Then in Repository Access, check that all repositories with pipelines are selected.

I've encountered a similar issue when using git repos on my local machine which are cloned from an Azure DevOps repository.

The initial clone works, I can pull/push without issue until I have to re-authenticate with azuread/adfs as the session eventually expires. Git will correctly prompt with the azure login page, and I can successfully authenticate against our tenancy, but Git will error with the basic credential prompt and "Logon failed, use ctrl+c to cancel basic credential prompt" appearing.

The only way I have found to get around this is to login to Azure DevOps via the browser (where my session will have also expired), then do the authentication with git again, which somehow allows it to work.

It happens if the git is not updated to the latest version.

Please update the git and you are good to go.

To update the git, just follow the below command depending on the type of OS you are using:

windows: git update-git-for-windows

Linux/Unix: git update

or follow the below link to get the latest copy of the git client for your OS

https://git-scm.com/downloads

You just need to update your git. open terminal and type IN WINDOWS

git update-git-for-windows

IN OTHER

git update

You can try 3 things to resolve this issue

  1. try with Administrator mode of visual studio.
  2. download latest git credentials manager
  3. add //.vs//DesignTimeBuild/.dtbcache.v2 to git ignore

If you are still getting this error for BitBucket & Visual Studio 2019 then please use app password instead of your regular BitBucket login password as of Mar 1 2022 BitBucket stopped using regular password for API based authentication. See reference

https://community.atlassian.com/t5/Bitbucket-articles/Announcement-Bitbucket-Cloud-account-password-usage-for-Git-over/ba-p/1948231