Working with multiple GIT accounts

If You need to authenticate on GIT server with multiple SSH keys You can simplify this with GIT configuration. Create new id_rsa key files:

ssh-keygen -f ~/.ssh/id_rsa_demo_one
ssh-keygen -f ~/.ssh/id_rsa_demo_two

Then setup those files in ~/.ssh/config file:

Host demo_one.bitbucket.org
  HostName bitbucket.org
  User YOUR_BITBUCKET_USER_2
  IdentityFile ~/.ssh/id_rsa_demo_one
  IdentitiesOnly yes
Host demo_two.bitbucket.org
  HostName bitbucket.org
  User YOUR_BITBUCKET_USER_2
  IdentityFile ~/.ssh/id_rsa_demo_two
  IdentitiesOnly yes

Now when You want to clone from repository bitbucket.org/example/example You need to specify host in clone command:

git clone git@demo_one.bitbucket.org.org:example/example.git

or

git clone git@demo_two.bitbucket.org.org:example/example.git

Same trick works with any GIT server.

Enjoy 🙂