Skip to content

Instantly share code, notes, and snippets.

@dotherightthing
Last active August 15, 2019 14:21
Show Gist options
  • Select an option

  • Save dotherightthing/57054428f02859575a051a7b6fe32fa5 to your computer and use it in GitHub Desktop.

Select an option

Save dotherightthing/57054428f02859575a051a7b6fe32fa5 to your computer and use it in GitHub Desktop.
[Bitbucket Password Required] #git #bitbucket

Bitbucket Password Required

Created: 2017.07.04

When attempting to clone a website, the SSH passphrase is requested and rejected three times.

SourceTree Password Required prompt.

Password Required.

This occurs with all of the following:

  1. SourceTree application - "Password Required. For user git on host bitbucket.org."
  2. Bitbucket SSH clone via SourceTree
  3. git clone [email protected]:dotherightthing/repo.git

The error message varies depending on the application:

  1. SourceTree - invalid URL
  2. Bitbucket SSH clone via SourceTree - invalid URL
  3. Invalid passphrase

Data security

Bitbucket offers multiple levels of security:

  1. OAuth account access
  2. SSH
  3. Two Step Authentication

OAuth

Connecting accounting via SSH in SourceTree.

Connecting a Bitbucket account.

SourceTree > Preferences > Do The Right Thing > Edit > Connect Account

After clicking Connect Account and entering the 6 digit Authy number string, nothing happens. The button still reads ‘Connect Account’.

SSH

SSH keys are stored in the parent account, not in website repos:

# View rsa public key and the associated email address:
cat ~/.ssh/id_rsa.pub

# Copy rsa public key to clipboard
pbcopy < ~/.ssh/id_rsa.pub

Two Step Authentication

https://bitbucket.org/account/user/dotherightthing/two-step-verification/manage

I use the Authy Android App to generate six digit pass codes on demand.

Recovering a lost SSH passphrase

MacOS Keychain Access.

Keychain Access.

Viewing SSH passphrase in MacOS Keychain Access.

SSH Passphrase in Keychain Access.

MacOS > Search > Keychain Access

Troubleshooting passphrase not accepted

https://help.github.com/articles/adding-a-new-ssh-key-to-your-github-account/

I found that I had no private key:

https://help.github.com/articles/error-permission-denied-publickey/#make-sure-you-have-a-key-that-is-being-used

Generating a new SSH key

Email confirming that an SSH key has been added to my account.

SSH Key added.

The solution for me was to generate a new SSH key. I’ve no idea why the last key was missing private key info, and why it worked for a while in spite of this. The only difference is that I am now logging in from a new IP address (Christchurch, July 2017).

https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/:

ssh-keygen -t rsa -b 4096 -C "[email protected]"
Passphrase: ...
eval "$(ssh-agent -s)"
Agent pid 12345
ssh-add -K ~/.ssh/id_rsa

Testing SSH access

Test that the correct SSH key is associated with your account.

Bitbucket

ssh -T [email protected]

If you are prompted for your passphrase, enter it. It should be remembered for next time.

You should see something like:

logged in as username.

You can use git or hg to connect to Bitbucket. Shell access is disabled.

Github

ssh -T [email protected]

You should see something like:

Hi username! You've successfully authenticated, but GitHub does not provide shell access.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment