Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use two bitbucket accounts (with seperate ssh keys) on one PC with TortoiseHg?

I have a BB (BitBucket) account for work and a BB account for my self and want to be able to access them both from one PC using TortoiseHg with SSH.

When you add the two keys to Pageant and then try to push to a repo that uses one of the accounts Pageant will pass the first SSH to BB and if it's a BB account SSH BB will accept it log the user in with the account related to that SSH key.

Now if that first SSH key is for the account that has access to the repo that's fine BUT IF that first SSH key was for the other account you will get an authorisation error.

There seems no way to pass the correct key to BB using TortoiseHg at all. And therefore I am constantly swapping SSH out of Pageant which clearly isn't ideal and I might as well drop SSH and use passwords. :(

Does anyone know of a way to get TortoiseHg to pass the correct SSH for that account?

like image 826
GazB Avatar asked May 11 '13 15:05

GazB


1 Answers

As I was writing this question I happened to come across a solution! Now the reason I hadn't come across it before is it was for Git not Mecurial so I think that it's still worth posting this question and this solution to allow others in the same boat to easily find the solution. :)

The solution was from here: https://answers.atlassian.com/questions/150285/only-the-top-listed-private-key-in-pageant-is-used-offered-by-git-sourcetree-tortoisegit

Here is the important part:

One way to resolve this is to perform the same configuration in PuTTY too to disambiguate what key to send (and therefore which user to authenticate as).

  1. Start PuTTY (download it from putty.org if you don't have it)
  2. Type 'bitbucket.org' in the host name field
  3. Go to Connection > SSH > Auth in the tree
  4. Specify the key to use for the BB user
  5. Go back to 'Session' in the tree
  6. Type an alias name underneath 'Saved Sessions' (e.g. bb-user1) and Save
  7. Repeat 2-6 for each BB user and save as a different session name

Then in your remote URLs, replace 'bitbucket.org' with the session name (e.g. bb-user1) to disambiguate what SSH key to send first. This is identical to using IdentityFile in OpenSSH.

like image 90
GazB Avatar answered Oct 23 '22 16:10

GazB