I recently found myself having to push code to multiple repos. Surprisingly, nobody at work knew how to do this or had any experience with it so I took it upon myself to...search Google.
First, let's open up your flavor of Terminal and create a series of ssh keys. Use a naming scheme that makes them easy to understand and make sure each file uses a different name.
ssh-keygen -t rsa -f ~/.ssh/id_rsa.bitbucket.work -C "email@example.com" ssh-keygen -t rsa -f ~/.ssh/id_rsa.github.home -C "firstname.lastname@example.org"
You now need to create a ssh config file to store these references:
touch ~/.ssh/config chmod 600 ~/.ssh/config echo 'IdentityFile ~/.ssh/id_rsa.bitbucket.work" >> ~/.ssh/config echo 'IdentityFile ~/.ssh/id_rsa.github.home" >> ~/.ssh/config
Copy your ssh key to clipboard. Change the key filename accordingly.
pbcopy < ~/.ssh/id_rsa.bitbucket.work.pub
sudo apt-get install xclip
xclip -sel clip < ~/.ssh/id_rsa.bitbucket.work.pub
clip < ~/.ssh/id_rsa.bitbucket.work.pub
Hop on over to Github/Bitbucket/whatever and add your new ssh key. That's it!
Original credit on how to do this: