3

I'm having a problem very similar to the one described here. However, the difference is that I'm trying to use Pageant as my agent instead of OpenSSH. I've found that when I have the SSH keys for two different Bitbucket accounts loaded in Pageant that one of the two repos will always run Git commands and the other will fail. The repo that works depends on which SSH key is sorted first in the Pageant key list.

By "fail", I mean that the following error is returnded from the Git command:

git -c diff.mnemonicprefix=false -c core.quotepath=false --no-optional-locks fetch origin
Forbidden
fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.

Completed with errors, see above.

I don't know if this is a PuTTY/Pageant, a SourceTree, or a Bitbucket problem. I suspect it is a Bitbucket issue since I found that if I remove Key A from Bitbucket Account A and then try to fetch on Repository B, then the command will succeed, even when Keys A and B are both loaded in Pageant. In other words, when a key is not attached to any Bitbucket account, then Bitbucket doesn't seem to have an issue with it.

Has anyone gotten Pageant to work with keys loaded simultaneously for multiple Bitbucket repos?

1
  • I assume that Bitbucket uses PuTTY plink under the hood. With plink, if you specify the key using -i switch and the key is loaded to Pagent, the plink will try to authenticate only using that specific key (and won't try the other keys loaded to Pageant), and it won't prompt for passphrase. This is equivalent of the ~/.ssh/config solution for OpenSSH in the question you have linked too. But I do not know if Bitbucket allows you to customize plink. Commented Nov 19, 2020 at 8:13

1 Answer 1

0

I found an answer in this blog that worked for me: craigtp.co.uk

For your first account and key, just set it up normally.

For the second account,

  1. Start PuTTY
  2. In Host Name, type in the real address (e.g. github.com)
  3. Go to Connection > SSH > Auth and load your second private key under Private Key File for Authentication
  4. Go to Session, and type a name with no spaces in Saved Sessions, and click Save. That will be your alias.

For instance, if you named your alias github-second, then when you clone your repository for your second account, use the alias. E.g.

git clone git@github-second:blah/blahblah.git

For what you are saying, it seems you have already cloned the repository at some point in time. In which case, simply update the remote.

Check your current remote. It should look like this,

git remote -v
origin  [email protected]:blah/blahblah.git 

Then, update the remote with this command:

git remote set-url origin git@github-second:blah/blahblah.git

That should work.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.