Search code examples
gitvisual-studio-codesshbitbucket

VS code unable to use SSH to push and pull from Bitbucket


Currently, I'm using source tree to push & pull from Bitbucket with SSH.

However, when I try to use VS Code to do the same thing, it ask for a password.

And I get the following error after entering my Bitbucket password:

remote: Invalid username or password
fatal: Authentication failed for 'https://bitbucket.org/repo/repo.git/'

I searched for a few articles, but nothing I tried seemed to be working.

I'm on an M1 Macbook - OS Big sur. This is for my professional Bitbucket account.

This was one of the docs I follow: https://support.atlassian.com/bitbucket-cloud/docs/set-up-an-ssh-key/


Solution

  • Try and switch to the command-line, and go to the root folder of your local repository.

    Check your remote URL with git remote -v: if it starts with https://, it won't use SSH. At all.

    Switch to ssh: git remote set-url origin [email protected]:<me>/<MyRepo> (<me> and <myRepo> are placeholder values for you to replace: don't use < and >)
    Test also your SSH key was correctly registered to your Bitbucket account: ssh -Tv [email protected].

    Then switch back to VSCode, and see if your issue persists.


    Jan. 2023: This is followed by microsoft/vscode issue 170436.

    Dec. 2023: that issue has been closed, since the issue does not seem to be present anymore.