First, make sure you have a default account setup through a tutorial like this one on bitbucket.
For the second account:
For the second account:
- Create a new ssh key using the below command :
ssh-keygen -f ~/.ssh/<second_account_name>
- Copy the second account public key and then add that key to the bitbucket account. To open the second account public key use the below command :
cat ~/.ssh/second_account_name.pub
- Now create a new config file under .ssh folder :
nano ~/.ssh/config
- Add the following to your ~/.ssh/config file. The first sets the default key for bitbucket.org. The second sets your second key to an alias bitbucket-second-account for bitbucket.org :
Host bitbucket.org Hostname bitbucket.org IdentityFile ~/.ssh/id_rsa Host bitbucket-second-account Hostname bitbucket.org PreferredAuthentications publickey IdentityFile ~/.ssh/second_account_name
- You can now clone projects with your default account the same way as you was doing before :
git clone git@bitbucket.org:bitbucket-username/project.git
- To clone a project with the second identity, replace bitbucket.org with the Host that you specified in the ~/.ssh/config file :
git clone git@bitbucket-second-account:bitbucket-username/project.git
- Now it's done but by any chance if you are getting any error like this :
Agent admitted failure to sign using the key
- Just use the below command to fix the above problem :
ssh-add ~/.ssh/second_account_name
wooooow bitbucket... so tasty <3
ReplyDeleteyou are so talented... pls marry me :3
my name is vanita valsala... follow me on twitter pls
Nitesh chetta I ❤ u
ReplyDeleteback off... nitesh chetta is mine... only mineeeee
Delete