Authentication failed to bitbucket
Asked Answered
B

36

142

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 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.

Brewing answered 6/1, 2014 at 16:1 Comment(6)
Change remote origin address from https ( ie: https://<username>@bitbucket.org/<username>/<repo>.git ) to ssh ( ie: [email protected]:<user>/<repo>.git ). You will find these addresses on the right side of your repository page. ( git remote set-url origin [email protected]:<user>/<repo>.git )Overcareful
This should be marked as answer.Cogitate
No solutions yet? (I am assuming by looking there is no accepted answer)Ishmaelite
Delete the default user names and saved passwords, It worked for me with a similar issue. Tools > Options > AuthenticationRoussel
This happened to me when the remote authentication server went down. If that's the case, nothing can be done about it aside from committing locally and being patient.Natation
I had the same issue and this solution fixed it C:\Users\USERNAME\AppData\Local\Atlassian\SourceTree and removing the passwd fileQuickie
F
150

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.

Fauch answered 11/2, 2014 at 20:26 Comment(11)
Although this would be a completely reasonable comment to the original question, the user is asking now about SSH setup so answers should handle that.Bread
Err... My answer wasn't random. As I'd the same problem and wanted to switch to SSH protocol, but you don't have to in order to make it work. Directly specify password can make the https auth method works. Just sayin'.Fauch
I realize it's not random, but it does not answer the question. If you modify your answer to also address SSH authentication then I'd be happy to remove my downvote :)Bread
Undoing the down vote. This solved my problem. I didn't want an ssh solution. Stack overflow questions don't live in a vacuum. A useful answer is a useful answer.Manilla
Also noting the specific command I used was git remote set-url origin https://<username>:<password>@bitbucket.org/<username>/<repo>.git.Manilla
@Manilla I tried what you stated and it's not working. Is there a way to undo this?Thickhead
@TomDoe Sure you can change the remotes however you want at any time. (remove, add, rename, set-url.) You can use set-url again to change it back.Manilla
You don't need to change the URL in console. You simply must to change the destination URL from Repository-> Repository settings-> EditTalkie
This puts your password in clear text in your .git/config fileSonny
This worked for me , with a a slight change git remote set-url origin https://<username>:<password>@bitbucket.org/<username>/<repo>.git did not work as there was a single single sign on , with redirection.....I changed it to git remote set-url origin https://<username>:<password>@bitbucket.org/<repo>.git ..any everything worked fine for mePlankton
Another option is to remove the :<password> portion (using https://<username>@bitbucket.....). In Windows using GitBash you will be prompted for your password. I would hope this password prompt means the password isn't saved in plain text, as this solution, as @ChristopherPickslay indicates, does.Abnormity
P
53

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.

Perpetrate answered 18/3, 2015 at 21:2 Comment(4)
I am using SourceTree + Bitbucket but not in a corporate environment (i.e. specific Bitbucket credentials) and changing the password via the suggested method worked. Thanks :)Phlox
I can't find anything like 'Tools', 'Options', 'Authentication' or 'Edit password' on SourceTree.. I'm on a Mac though.Baiss
@Baiss Mac users need to go to Preferences under SourceTree menu (instead of Tools/Options menu).Deventer
For Mac users: Go to SourceTree -> Preferences -> Accounts, select account, click Edit, then click Connect Account and login with your Atlassian account there.Touch
C
47

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/

Cutpurse answered 6/3, 2018 at 7:50 Comment(4)
To be specific for Windows 10: Control Panel -> User Account -> Credential Manager -> Manage Windows CredentialsEmporium
Finally it is very basic solution and it's works !!! Thank youMadea
It worked for me thanks, previously popup will come automatically to enter credentials but not came this timeTricolor
Normally it worked for me too before, but this time wasn't work. So I went to Generic Credential settings and delete my profile. Then went to the git command line and try again. Command-line trigger credential pop-up UI and filled again the same credential then worked! Just want to add more information for public benefit :)Madea
F
35

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

Firebreak answered 21/8, 2017 at 9:25 Comment(2)
'SourceTree > Preferences > Git ' on OSX.Dante
Thank you! worked. tools -> options -> git -> click systeam button under git versionDilan
R
19

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.

Repercussion answered 2/12, 2019 at 5:47 Comment(2)
This was the solution in my case. I'm running Windows-7 and had a recent password change. The cached credentials for the bitbucket server were out of date in Credentials Manager.Wira
True, Windows credential manager store passwords and details. Problem is due to cache. So always check for the password in credential manager.Repercussion
H
18

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.

Henson answered 16/2, 2017 at 10:45 Comment(2)
Deleting that keychain helped me because it caused source tree to ask for new password.Gonadotropin
On MacOS 10.13 (High Sierra) it is very important to reboot the machine (or maybe at least logout/login) for this to work after you deleted the keychain entries. Otherwise the new password could not be stored in the keychain by Sourcetree and every git operation causes many password prompts.Boomer
F
13

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.

Frenulum answered 16/4, 2021 at 13:56 Comment(1)
This has fixed the issue on several different occasions for me. Thanks!Rooftop
H
11

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!)
Homeopathist answered 8/6, 2015 at 9:39 Comment(2)
Similarly, I needed to change my username to something without an underscore in it.Dimorph
Wow. that is beyond criminally stupid. Looks like we know what all Atlasian bitbucket account passwords have no symbols in them. Ughhh.Ketose
R
8

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...

Rosemare answered 7/8, 2018 at 8:43 Comment(2)
Thank you so much! This worked, i had to enter indeed in the popup not only my username but: [email protected]Anglian
(Using Bitbucket) this was the solution in my case. But I just want to add that this is only valid if you are the owner of the repository -as the question point-. In my case I had the both case: I was the owner of the repo and can't push (question) but also no one else could push with the same error, but in case of the other users -no owners- you should just grant access to the repo (read and write or admin), AND here you have to pay to Atlassian if you have more than 5 users. Thanks for this answer.Dewie
I
7

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.

Iq answered 10/1, 2018 at 23:49 Comment(1)
Can anyone can provide details as to why this works?Bellbella
P
6

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

Pintle answered 15/3, 2022 at 6:49 Comment(1)
Genated app password and given as account pass in console and it workedIreneirenic
E
6

When I moved to a Linux Machine, I kept providing the atlassion/bitbucket account password but it kept saying that my password was wrong. I then went to https://bitbucket.org/account/settings/app-passwords/ and created a new app password, this password was the one required.

P.S: No, it's not SSH mess.

Erzurum answered 31/5, 2023 at 12:40 Comment(0)
R
4

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'

Rancidity answered 18/8, 2017 at 13:51 Comment(0)
P
3

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

Practiced answered 8/3, 2017 at 0:20 Comment(0)
T
3

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.
Terrill answered 21/7, 2017 at 7:45 Comment(0)
H
3

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.

Hypostasize answered 19/9, 2018 at 7:16 Comment(0)
S
3

1.update git if necessary
2. add app password in bitbucket
https://bitbucket.org/account/settings/app-passwords/new
3. use this app password instead your account password to login

Simulacrum answered 23/3, 2022 at 7:55 Comment(1)
I was struggling with this then I created an account password MYACCOUNTPASSWORD and used it like this git push https://myusername:[email protected]/myusername/myrepo.gitTriable
Y
2

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// 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.

Yeanling answered 2/5, 2016 at 15:52 Comment(0)
A
2

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

Abrogate answered 30/6, 2018 at 15:40 Comment(0)
D
2

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

Discriminate answered 21/2, 2020 at 4:41 Comment(1)
I would just flag it is possible to delete an entry (userId and base64 string) from the passwd file, rather than delete the file.Curium
W
2

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

Winder answered 27/8, 2020 at 9:24 Comment(1)
Refreshing the OAuth worked for me.Memorize
S
2

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

Sundberg answered 2/5, 2022 at 6:2 Comment(0)
R
1

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.

Reams answered 5/7, 2017 at 21:13 Comment(0)
L
1

I Reverted to sourcetree 2.0

This solved the bug for me.

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

Linc answered 16/8, 2017 at 8:10 Comment(0)
S
1

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.

Slipover answered 2/12, 2020 at 16:43 Comment(0)
B
1

To use SSH instead of HTTPS, do the following

  1. Generate your ssh keys locally then setup your BitBucke account to include the public SSH key. Those details of how to do that are described here

  2. Change the config file of your repository. To do that, edit the file /path/to/repo/.git/config and then change the remote origin url from HTTPS to SSH. In other words, change it from https://<username>@bitbucket.org/<username>/<repo>.git to [email protected]:<user>/<repo>.git. Grab the exact SSH address from your BitBucket repository web page.

Now you can commit without a problem.


NOTE

If your are using VS Code to commit and push your code, you might get an ssh_askpass error. To fix this, follow the steps here

Boracite answered 8/9, 2022 at 16:34 Comment(0)
W
1

open url https://bitbucket.org/account/settings/app-passwords/ click "Create app password" will password show used this password for git

Wail answered 24/1, 2023 at 21:9 Comment(0)
V
1

Use app passwords for authentication. App passwords allow users to access their Bitbucket account through apps such as Sourcetree.

Create a token with correct permissions and use the token instead of the password

https://bitbucket.org/account/settings/app-passwords/

Valeryvalerye answered 4/5, 2023 at 7:38 Comment(0)
D
0

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.

Drawl answered 3/4, 2017 at 9:51 Comment(0)
L
0

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]/...

Logway answered 26/2, 2019 at 11:35 Comment(0)
G
0

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.

Galyak answered 29/3, 2019 at 15:32 Comment(0)
C
0

In windows this worked for me

git config --global http.sslVerify false

Collaborate answered 19/6, 2019 at 16:25 Comment(0)
S
0

There's been a change since March 2022 when using SourceTree for Windows to require an Atlassian password

  • Upgrade to the latest version of SourceTree.

  • In SourceTree select Tools -> Options -> Authentication, delete all your accounts, then shut down SourceTree.

  • Go to the Atlassian web site, create an application password and save it somewhere (https://support.atlassian.com/bitbucket-cloud/docs/app-passwords/).

  • In Windows, go to Control Panel -> User Accounts -> Credential Manager -> Manage Windows Credentials and delete any and all credentials related to BitBucket.

  • In Windows explorer, navigate to C:\Users\your_user_name\AppData\Local\Atlassian\SourceTree and delete the 'passwd' file (the purpose of this and the previous step is to delete any existing cached credential.

  • Launch SourceTree again, open the resource settings for your repo and make sure it's set to use your bitbucket user name and not an email address.

  • Fetch the repo and when prompted, enter the application password you generated in step 3.

  • Adding password to SourceTree: https://support.atlassian.com/bitbucket-cloud/docs/add-an-app-password-to-sourcetree-or-another-application/


Previously I fixed 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

Sarcasm answered 21/3, 2022 at 22:45 Comment(0)
T
0

In IntelliJ IDEA, click Git menu at the top & click on Fetch option which should prompt for the Git credentials dialog box where we can enter our username & the new password to resolve this issue. Easy!

Tani answered 21/6, 2022 at 7:57 Comment(0)
S
0

Last friday Github and Bitbucket worked i could push and pull.

Today (Monday) authentication failed. Every single time. I tried creating new app passwords, but i couldn't access GitHub or Bitbucket.

I then tried on another computer, and it worked. This indicated that the problem was my system.

I renamed the ~/.gitconfig file to something else, and commits push / pulls to github and bitbucket immediately started working again.

I saw that git had been updated on that machine. I suspect that the new git version didn't like the .gitconfig file. I can't prove it though, however renaming that file fixed it for me.

Subtend answered 7/11, 2022 at 12:28 Comment(0)
A
-1

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
Avouch answered 11/4, 2019 at 14:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.