With multiple, git hosting repositories available and lots of coding being done, you end in situations like the subject of this email. Say, for example you have 2 accounts on BitBucket, you would not be allowed to use the same ssh key across both the accounts. The idea is to have
- Multiple SSH keys, and
- Mapping those keys to individual accounts
Let us see how you would be able to go about it
Now, in your /home/vikas/.ssh folder, you would get 2 keys, one called some-temp.pub(which is the public key) and the private key some-temp. The idea is to show that you can generate multiple ssh keys depending on your need.
Next, you would create a “config” file, which would map your alias with the right username and the ssh key. For example, if I have 2 accounts on BitBucket and 1 on GitHub then my config file would look something like this
Once, we have the config file in place, the system understands which key is assigned to which account. So in my config file example above, user “vhazrati” on BitBucket has the “~/.ssh/bitbucket_id_rsa” mapped to it and user “vikashazrati” on BitBucket has the “~/.ssh/id_rsa” key mapped to it.
Now if you want to clone a repository with user “vhazrati”, you would do
and to clone from the other account, you would do
Enjoy!