0

For the 2 multiple projects, 2 multiple bitbucket developer accounts are used but in the same machine. SSH KEY is accepted for the one Bitbucket account.

When I add the same key to the other bit bucket accounts, It shows KEY already exists ?

How could I avoid this problem ? Is there a security reasons behind this ?

It accepts the same key in Gitlab Note: Currently we are using HTTPS connection for other accounts ?

Nandakumar
  • 1,071
  • 2
  • 11
  • 30
  • 1
    Multiple bitbucket accounts can't have the same SSH key - the authentication is done through the key and the assumption that it's unique to one user. Generate a second key for the other account. – wkl Sep 25 '15 at 02:48
  • @birryree You are right. But I am using the SSH key at the same machine. Did you mean that it takes the Individual accounts as unique ? I don't think so, because same key accepts in gitlab.. – Nandakumar Sep 25 '15 at 02:50
  • it will be better when i get a reason for the down votes. It might be the answer for someone... – Nandakumar Sep 25 '15 at 02:53
  • What does gitlab have anything to do with this? In Bitbucket, unique users have to have their own ssh keys. Imagine this basic security problem: user A has SSH key B and access to a bunch of private repos. User C is able to add SSH key B to his own account. User C now has access to those same private repos the other user does, even if there isn't any intention for that to happen. It doesn't matter if the users access the stuff from the same machine - to Bitbucket, you still are using distinct accounts if you both have accounts. – wkl Sep 25 '15 at 02:54
  • lol again - I'm pretty sure gitlab does not accept having the same key on multiple accounts. – Griwes Sep 25 '15 at 02:56
  • ok... then how come gitlab accepts the same key over there ? – Nandakumar Sep 25 '15 at 02:58
  • Like @griwes said, I'm pretty sure gitlab isn't allowing multiple accounts to use the same SSH key. Are you both just checking out with the same account? – wkl Sep 25 '15 at 03:00

1 Answers1

3

How could I avoid this problem ? Is there a security reasons behind this ?

Yes: if a public key is registered in a BitBucket account, that means any git operation using that ssh url would be associated to that account.

Registering the same public ssh key to a different account would mean having to chose between two Bitbucket users account. That is not possible.

What you can do is create a different public/private couple of ssh keys, and reference one or the other Bitbucket account, by declaring both sets of ssh keys in an ~/.ssh/config file.

See "How to use different keys for different Bitbucket repos in SmartGit?"

host bitbucket1
        user git
        hostname bitbucket.org
        port 22
        identityfile /C/path/to/.ssh/key1
host bitbucket2
        user git
        hostname bitbucket.org
        port 22
        identityfile /C/path/to/.ssh/key2

Then:

  • Pushing to bitbucket1:repoA will use the user1.
  • Pushing to same repo, but with bitbucket2:repoA will use the user2.
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Now I understood the real reason but I am just wondering about the words **the other through an ~/.ssh/config file** Can you please explain little bit ? And also generate a new ssh key without overriding the existing one with the new path... – Nandakumar Sep 25 '15 at 09:11
  • @NandaKumar the complete expression is "one or the other through an `~/.ssh/config` file": meaning reference one or the other account, by declaring two different sets of ssh keys in an `~/.ssh/config` file. – VonC Sep 25 '15 at 09:21
  • Superb. You rocks..I checked my .ssh key folder and can't able to find the config file. Do we need to create the file or it is missing in my machine ? – Nandakumar Sep 25 '15 at 09:28
  • @NandaKumar yes, you can create one ~/.ssh/config file: see a practical example in http://nerderati.com/2011/03/17/simplify-your-life-with-an-ssh-config-file/ for instance. – VonC Sep 25 '15 at 09:31
  • Nice one.. While ssh-keygen how could i change the destination path ? – Nandakumar Sep 25 '15 at 09:33
  • @NandaKumar use the `-f` option to specify another `file` (`file.pub`) for `ssh-keygen` to use when generating new private/public keys. See for example http://serverfault.com/a/323961/783. – VonC Sep 25 '15 at 09:39