Issue #5890 invalid

one SSH Key for two accounts

Oliver Kriška
created an issue

I have two accounts. One account is for my firm's projects and next one is for my private projects. But I can not add SSH key from my macbook to my private account. Can I use one key for two accounts? It show me this error: Someone has already registered that SSH key.

Comments (15)

  1. Erik van Zijst staff

    I think you have already figured it out: you cannot share an SSH key across multiple accounts.

    The reason behind this is that when you use SSH, your key identifies which bitbucket account you authenticate as (and in turn, whether you have the required privileges to access the repo) and if your key were attached to more than one account, we wouldn't know who to authenticate as.

  2. Happily Coded

    Although I understand what Erik says, but it makes things difficult for me. I am part of two organizations at the same time, and both of them use BitBucket, and I have to commit code to both of them (at different times) from my same computer.

    I'll just check if I can have the already approved user (from the other firm) added in the other firm and get pushes working.

    Still not sure if both the organizations will be happy with this.

    Would be more than happy if you allow us to use one key for multiple accounts

  3. Daniele Segato

    I can't accept this being closed as Invalid.

    The same very issue happen in my company. We pay for Bitbucket OnDemand and have two different TEAM to restrict code access to different users.

    We use Jenkins for continous integration and it's public SSH key is used to access the repository. Now: we can't set that SSH key to the two team. This is an issue that should be adressed by Bitbucket.

    I may understand the technical issue behind, this doesn't make the bug not a bug.

  4. Sergey Rodovinsky

    We started to use Bitbucket recently, and love it. However we use Teams to separate projects logically, and the SSH issue gets in a way. I hope Bitbucket will come up with a reasonable solution.

  5. Victor Sotto

    I recommended bitbucket to the management because i like the way things are going, except this issue. never thought this will be problem. please bitbucket, do something...

  6. Christopher Beloch

    If you are part in 2 teams, than you add the SSH Key to YOUR account, so no issue there as you can access all the repos you can see on the site. Just use correct access rights

  7. Axel Mendoza

    This can be easily resolved, in fact ssh have support for this, I recently develop an SFTP server and have to deal with this and I think that what bitbucket is doing is not using correctly the ssh keys or in a better way of saying is using the ssh key for identify the user instead of using it for just authenticate the user that is requesting authentication. for example: If user john have the ssh key 1 registered and user doe have the same ssh key, when they tried to connect to bitbucket they send their username for the connection like: git remote add origin git@bitbucket.org:aekroft/repo.git git push origin master

    the git command will send the private key to bitbucket against the user account so they could authenticate ok the request. If and only if the public key have been registered in the user account then the user have been authorized to the use of that ssh key and there is no need to determine the user using the ssh key at least only to have a supersecurity but also droppin this useful feature

  8. Erik van Zijst staff

    I think the simplest way to address this is to not have everyone use git@bitbucket.org, but use your own username in the URL. We the use that for identification and use the pub key for that account for authentication.

    Anyway, such refactor is not currently planned.

  9. Ezequiel Bergamaschi

    I create an script to solve my problem...

    • !/bin/bash

    • declare HOME_DIR=~/.sshHome
    • declare SSH_DIR=~/.ssh
    • declare WORK_DIR=~/.sshWork

    • if [ -d "$HOME_DIR" ]; then

    • echo "Setting home as ssh dir"
    • mv $SSH_DIR $WORK_DIR
    • mv $HOME_DIR $SSH_DIR
    • else
    • echo "Setting work as ssh dir"
    • mv $SSH_DIR $HOME_DIR
    • mv $WORK_DIR $SSH_DIR
    • fi

    Enjoy!

  10. Log in to comment