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
.