Authentication failed to bitbucket

BitbucketAtlassian Sourcetree

Bitbucket Problem Overview


I'm trying to push my project via the https protocol on bitbucket using sourcetree.
But I can't connect to bitbucket with my login and password (which work on the website), I have a fatal error : "Authentication failed".

I read on other posts I can work around the problem using the ssh protocol instead of the https one, so I set up a ssh key following instructions on the http://www.sourcetreeapp.com/faq">source tree faq. But now I don't know how I can change to the ssh protocol when I want to push my code. Someone know how I can do this ? Thank you.

Bitbucket Solutions


Solution 1 - Bitbucket

If you got authentication issues with the GIT console, you can try to switch your configuration to HTTPS and specify user & password with the following command :

https://<username>:<password>@bitbucket.org/<username>/<repo>.git

BUT CAREFUL: Coming back to this answer that I made a very long time ago, I want to give credits to @ChristopherPickslay for pointing out that the password is stored as clear text in the .git/config file.

If you want to roll with HTTPS, you can securely store your password with Git credential manager

But personnally, I now always use SSH authentification, as it seems to be a better practice, because you use a personal pair of public/private keys that will prevent your password to be stored outside. Apart from the fact you can put a passphrase on your key, and then you also need to store the password on a credential manager or ssh-agent.

Solution 2 - Bitbucket

I recently had a similar issue with SourceTree: any time I tried to push/pull/fetch to/from the remote origin I would get an authentication error (using SourceTree with Stash). Sometimes I would be challenge in Stash with a CAPTCHA but it never made a difference if I provided the correct information or not.

For me, we're using SourceTree and Stash in a corporate environment; user accounts are based on network credentials. Part of our network security requires us to change those passwords on a regular basis.

I was operating under the assumption that SourceTree/Stash was "aware" of any change made to my network password. But apparently -- at least in this instance -- it was not.

To fix, all I needed to do was:

Tools > Options > Authentication > Edit (Edit Password)

I set the password to match my current network password and everything began working as expected.

Not sure if this helps the OP but I hope it may help someone else looking for answers to a similar issue.

Solution 3 - Bitbucket

I tried everything else and found helpless but this indeed worked for me "To update your credentials, go to Control Panel -> Credential Manager -> Generic Credentials. Find the credentials related to your git account and edit them to use the updated passwords".

Above Solution found in this link: https://cmatskas.com/how-to-update-your-git-credentials-on-windows/

Solution 4 - Bitbucket

Tools -> options -> git and selecting 'use system git' did the magic for me.

Solution 5 - Bitbucket

I solved the issue by editing the stored value in the OS X Keychain: I looked for "bitbucket" (as Application password) and changed the value.

Then on Sourcetree, when I tried to push, I directly had to re-enter my new password.

Solution 6 - Bitbucket

Windows start up menu,Search for windows credential manager. Search for bitbucket url, Try updating password there.. and do git operation again. It should work.

Solution 7 - Bitbucket

The issue was solved for me after changing the repository password, using no special characters (!"§$%&&).

Obviously, win-credential-store and git and bitbucket's web interface use different character encodings.

complete procedure:

D:\shared\Project> cd /path/to/your/project
D:\shared\Project> git init
D:\shared\Project> git remote add origin https://bitbucket.org/USERNAME/project.git
D:\shared\Project> git-credential-winstore.exe

then

D:\shared\Project> git push
Failed to erase credential: Element not found
fatal: Authentication failed for 'https://bitbucket.org/USERNAME/project.git/'

After changing the passphrase:

D:\shared\Project> git push
Counting objects: 102, done.
Delta compression using up to 8 threads.
... etc. ...

Settings in Windows tresory:

address: git:bitbucket.org (remeber the preceding "git:")
user: USERNAME
pass: old incl!"§§$%&, new without!"§$%%&/( (your passphrase!)

Solution 8 - Bitbucket

Deleting the Sourcetree password cache file worked for me. Navigate to C:\Users\USERNAME\AppData\Local\Atlassian\SourceTree and delete (or rename) the file named passwd. Restart SourceTree and execute a command (e.g. Pull, Push, etc..) that requires authentication. SourceTree will then prompt you for your password, rewriting the cached credentials.

Solution 9 - Bitbucket

I Reverted to sourcetree 2.0

This solved the bug for me.

https://www.sourcetreeapp.com/download-archives

Solution 10 - Bitbucket

Tools > Options > Use System Git , then select the git.exe file

enter image description here

The credentials will be required again, and the problem will be solved.

Solution 11 - Bitbucket

After fighting with this for a long time, it looks like I found something that seems to work. I was optimizing the urls to not include the username (keep it as generic as possible), but the authentication dialog kept popping up:

enter image description here

I tried everything that came into mind, such as:

  1. Enable and disable MFA (Multi Factor Authentication)
  2. Create app passwords (again, with and without MFA enabled)

No matter what tools I used (including SourceTree), nothing worked. The server kept returning: "Create an app password"

Basically you must

  1. Use the url including the username (e.g. https://[email protected]/...)
  2. Use an app password created in bitbucket

Would be so nice if the server would have returned this in the response instead of suggesting to use an app password...

Solution 12 - Bitbucket

I had the same problem. It has something to do with a bug in Git for Windows. For me it was enough to change Git used in SourceTree to the embedded one:

Tools -> Options -> Git and click button 'Use Embedded Git'

Solution 13 - Bitbucket

Inside company though it should work anywhere.

  • Logout from Bitbucket ( in case you are using)
  • Login with your credential
  • Go back to console
  • Fire the same command
  • It will ask for password - Provide it.
  • You are good to go.

Solution 14 - Bitbucket

For Mac Users. There was a default account set on the Source tree which does not allow me to clone the URL because my current URL was of different bitbucket account. So, It shows the invalid source path and I then click on Advance Options and found Authentication failed to your_clone_url. So, follow these steps

  1. Select Source Tree. Go to SourceTree menu -> Select Preferences.
  2. It will show Accounts window. Then Choose Accounts enter image description here

Here it will show list of your added accounts. Just click on Add button from the bottom and add your new bitbucket account details. It will list you account under Accounts tab. You can also set default account by clicking on Set Default .. button from bottom. Now all is done.

Solution 15 - Bitbucket

In the latest update you can set an app password from the bitbucket's settings page. Then when you will push or pull something type that password and it will workenter image description here

Solution 16 - Bitbucket

If you made an account using google/ other oauth, then you need to set a bitbucket password for your account first. The URL for that is : https://bitbucket.org/account/user/<your-user-name>/ or look for Bitbucket settings under the menu.

Then can login from git (I tried via command line). I use the built in manager for credentials :

> credential.helper=manager

Now, after I set the password on the bitbucket site (email verified too), and tried to push again, it prompted me for the password, then pushed the code.

Menu location image on bitbucket web page -> http://ctrlv.in/747291 as of May 2016.

Solution 17 - Bitbucket

I had the same problem. You need to go and add an app password for sourcetree in your bitbucket settings. Click "Bitbucket settings" in menu, App passwords, create app password. Then go to SourceTree and edit your saved password

Solution 18 - Bitbucket

OBSOLETE ANSWER - VERIFIED NOVEMBER 17, 2020


On Mac, I needed to go to Preferences > Accounts, then add a new account as Bitbucket Server and enter my company's bitbucket server URL. Then I had to choose HTTPS as the protocol and enter my username (without @email) and password.

Also I set this new account as the default account by clicking the Set Default... button in the bottom of the Preferences > Account page.

Solution 19 - Bitbucket

This problem occurs because the password of your git account and your PC might be different. So include your user name as shown in the below example:

https://[email protected]/...

https: //[email protected]/...

Solution 20 - Bitbucket

I got the same issue when password reset has happend for the domain. I tried almost all the steps in
(Tools > Options > Authentication). But nothing worked. At last i got below answer from atlassian community page and it worked.

The only thing that worked for me was navigating to C:\Users\USERNAME\AppData\Local\Atlassian\SourceTree and removing the passwd file

Once that file was deleted, I just did a "Push" and it finally asked for my password

https://community.atlassian.com/t5/SourceTree-questions/How-to-update-HTTP-S-credentials-in-sourcetree/qaq-p/297564

https://community.atlassian.com/t5/Sourcetree-questions/Getting-quot-fatal-Authentication-failed-for-quot-error/qaq-p/624663

Solution 21 - Bitbucket

I got this error using Azure DevOps even though I had added a Personal Access Tokens as the example shown.

enter image description here

Solved it by running git pull -v from Sourcetree terminal and adding the Personal Access Tokens again through there.

enter image description here

Solution 22 - Bitbucket

I was trying the git push --all bitbucket call and it was throwing back the "fatal: Authentication failed for 'https://..." response. The solution that worked for me was to change the command to:

git push --all https://{username}@{url}

On Windows, this popped up a dialog that allowed me to enter my password and the push worked.

Solution 23 - Bitbucket

1.update git if necessary
2. add app password in bitbucket
https://bitbucket.org/account/settings/app-passwords/new<br/>

  1. use this app password instead your account password to login

Solution 24 - Bitbucket

For this issue you can use bitbucket's app password feature. This also works for github client/desktop authentication or any other app that requires you to connect bitbucket account. On bitbucket click on your avatar on top right then go to : personal settings -> app password and select 'create password'. Then a dialog box will appear asking you access permission you want to give to the app. mark the boxes and click on create, a password will appear in the box, copy that password and use it to authenticate your app. enter image description here

Solution 25 - Bitbucket

None of the above worked for me - the problem lay in my Sourcetree Preferences. In the Network tab, I had a setting there for 'Default usernames for URLs which do not include one:'. The username was incorrect where I had entered it incorrectly previously - I had set it to my email rather than username. I highlighted the entries and clicked Remove for both. Then I returned to my repository page and clicked Push again. On pushing, it asked me for full username and password, which I was able to enter correctly - the push then finally worked.

Solution 26 - Bitbucket

The issue for me was that I did not have an account added to Sourcetree.

Adding an account allowed me to push to my repo:

Tools > Options > Authentication > Add > Refresh OAuth Token

enter image description here

Solution 27 - Bitbucket

I tried almost all the solution given here.

Which worked for me is I opened the GIT GUI and in that tried to Push. Which ask for the credentials, enter correct userid and password it will start working again.

Solution 28 - Bitbucket

I was using below command

git clone -b branch-name https://<username>@bitbucket.org/<repository>.git

Issue got resolved after adding password with username (see below command):

git clone -b branch-name https://<username>:<password>@bitbucket.org/<repository>.git

Solution 29 - Bitbucket

In windows this worked for me

git config --global http.sslVerify false

Solution 30 - Bitbucket

I had a similar issue when trying to check out via SourceTree. I changed my Bitbucket password by following the 'can't log in' link in the BitBucket login modal:

enter image description here

Then in SourceTree I did Tools > Options > Authentication > Select my account > Edit > Refresh Oauth Token until it says Authentication OK

enter image description here

When I then try an operation in SourceTree (in my case a branch checkout), I get an OpenSSH prompt and I enter the new password:

enter image description here

The checkout via SourceTree then succeeds

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJulien NavarreView Question on Stackoverflow
Solution 1 - BitbucketAlexView Answer on Stackoverflow
Solution 2 - BitbucketBobView Answer on Stackoverflow
Solution 3 - Bitbucketdeepak mishraView Answer on Stackoverflow
Solution 4 - BitbucketIshwar RimalView Answer on Stackoverflow
Solution 5 - BitbucketTibView Answer on Stackoverflow
Solution 6 - BitbucketPankaj ChauhanView Answer on Stackoverflow
Solution 7 - BitbucketMaxView Answer on Stackoverflow
Solution 8 - BitbucketJoshView Answer on Stackoverflow
Solution 9 - Bitbucket2slothView Answer on Stackoverflow
Solution 10 - BitbucketJorgesysView Answer on Stackoverflow
Solution 11 - BitbucketGeert van HorrikView Answer on Stackoverflow
Solution 12 - BitbucketPati KView Answer on Stackoverflow
Solution 13 - BitbucketfiberairView Answer on Stackoverflow
Solution 14 - BitbucketGurjinder SinghView Answer on Stackoverflow
Solution 15 - BitbucketAbdul BasitView Answer on Stackoverflow
Solution 16 - BitbuckettgkprogView Answer on Stackoverflow
Solution 17 - BitbucketTed DuongView Answer on Stackoverflow
Solution 18 - BitbucketAdam JohnsView Answer on Stackoverflow
Solution 19 - BitbucketDevi AchsahView Answer on Stackoverflow
Solution 20 - BitbucketNidhinSPradeepView Answer on Stackoverflow
Solution 21 - BitbucketOgglasView Answer on Stackoverflow
Solution 22 - Bitbucketdbrouwer2View Answer on Stackoverflow
Solution 23 - BitbucketMarcin ŻurekView Answer on Stackoverflow
Solution 24 - BitbucketJunaid ShaikhView Answer on Stackoverflow
Solution 25 - BitbucketLuke SmithView Answer on Stackoverflow
Solution 26 - BitbucketFelixView Answer on Stackoverflow
Solution 27 - BitbucketJaydeep ShilView Answer on Stackoverflow
Solution 28 - BitbucketS'chn T'gai SpockView Answer on Stackoverflow
Solution 29 - Bitbucketjames murphyView Answer on Stackoverflow
Solution 30 - BitbucketChris HalcrowView Answer on Stackoverflow