fbpx

How to set Bitbucket for Multiple Accounts

August 13, 2012

How to set Bitbucket for Multiple Accounts

Just found the solution for adding multiple accounts to Bitbucket. The reason why it is not so straight forward is because one SSH key only can link up to one account. So if there is more than one account the method will be slightly different.
Here is how the step to resolve it.
After id_rsa and id_rsa.pub is used to assigned account A. For account B, I need to create another set of public and private key.
1 $ssh-keygen -t dsa -f ~/.ssh/newaccB -C ""
2 $chmod 600 ~/.ssh/newaccB*
3 $ssh-add ~/.ssh/newaccB
After that you need to go to ~/.ssh/config to give ssh client further instruction when connect to the same bitbucket.org server but knowing when to use which private key.
1 Host bitbucket.org
2     Hostname bitbucket.org
3     User git
4     IdentityFile /Users//.ssh/id_rsa
5
6 Host bitbucket-accountB
7     Hostname bitbucket.org
8     User git
9     IdentityFile /Users//.ssh/newaccB
So, after setting up when you want to use the account B key, you need to change the url to something such as below:
1 $git clone git@bitbucket-accountB:/.git

So now if we wanted to clone a Git repo from BitBucket using our Work account we use this:
git clone git@bitbucket.org:MY_WORK_USER_NAME/MY_WORK_REPO_NAME.git

And now, I want to clone a repo from my personal BitBucket account…
git clone git@bitbucket-personal:MY_PERSONAL_USER_NAME/MY_PERSONAL_REPO_NAME.git

For account A, you still can use the original ssh url to do so.
If you are using SmartGit, better to choose the System SSH in your preference. If not, you will still getting error.
PS: ssh-add ~/.ssh/newaccB might be adding behind after modify ~/.ssh/config
avatar
Gonzalo Escribano

Ver entradas

Most Recent

June 9, 2022

¿Qué son las DAO y cuáles son sus beneficios?

Es común en la historia contemporánea que haya cambios a partir de los avances en el campo de la...

Read More

June 2, 2022

¿Qué son las DeFi y por qué son el futuro de las finanzas?

Es común en la historia contemporánea que haya cambios a partir de los avances en el campo de la...

Read More

May 27, 2022

How to start a successful product build from scratch?

Creating a product from scratch could be a huge challenge. To achieve your business goals it’s important to develop...

Read More