Remote Authentication Failed
Asked by Maxwell Cohen:

Hi y'all,

When attempting to push from my local to remote repo, I receive an error message:  

remote: Invalid username or password  
fatal: Authentication failed for '<https://bitbucket.org/myuser/my-repo.git/>'

The usual password prompt never even shows up, just goes straight to the error message.  

I have already tried resetting my password, changing the git config (so that the url has my email), and unsetting the credential helper. If anyone can help please please let me know.


Answers:
author: Daniel Rosenberg
body: Not sure why it changed, but it seems like password login is not allowed anymore even though the email warning about it stated 1st of March 2022 (unless I misread). You will need to set up SSH instead, follow this tutorial:

[Set Up SSH](https://support.atlassian.com/bitbucket-cloud/docs/set-up-an-ssh-key/)

And then change your repository's origin URL (or whatever remote you have, origin is just the default) using the following:

\`**git remote -v**\`

- to see the old one, it will likely be in this format:

- https://\<username\>@bitbucket.org/\<organisation\>/\<project-name\>.git

and needs to be changed using this command:

\`**git remote set-url origin \<new-url\>**\`

- with the following URL format:

- ssh://git@bitbucket.org/\<organisation\>/\<project-name\>.git

Note the ending part of the URL, you can copy it from the original format to the new one, the username is no longer going to be there and instead of https://, it's ssh://


author: Terence-Dev-345
body: Well, I had the exact same issue with VS code, it works ok when I run everything in a terminal. I hope this can help you narrow down the issue. VS Code may have something different to the system terminal


author: Caroline R
body: Hi, [@Maxwell Cohen](/t5/user/viewprofilepage/user-id/4634312)! Welcome to the community!

Since you are using HTTPS, I suggest you try using an **App Password** to authenticate with git. These are substitute passwords for a user account, designed to be used for a single purpose with limited permissions. App passwords can be used to run Git commands over HTTPS to a user's Bitbucket account and to integrate Bitbucket with other tools like Sourcetree and Bamboo.

You can follow the next steps to create an App password:

1. From your avatar in the bottom left, click **Personal Settings**;

2. Click **App passwords** under Access management;

3. Click **Create app password**;

4. Give the app password a name related to the application that will use the password;

5. Select the specific access and permissions you want this application password to have;

6. Copy the generated password and either record or paste it into the application you want to give access to.

7. **The password is only displayed this one time**.

After you create this App Password, you can use it to authenticate to Bitbucket in replacement of your account password. You can change the URL of your local repo by following the next command:

    git remote set-url origin https://<Bitbucket_Username>:<App Password>@bitbucket.org/<workspace>/<repository>.git

If you would like to read more about App Passwords you can access this documentation: [App passwords](https://support.atlassian.com/bitbucket-cloud/docs/app-passwords/)

Please let us know how it goes and in case you need any help with this process, we'll be glad to assist you!

Kind regards,  
Caroline


Tags: bitbucket-cloud

cloud