Create ~/.ssh/github folder
ssh-keygen -t rsa -b 4096 -C '[email protected]' -f ~/.ssh/github/personal -q -N ''
ssh-keygen -t rsa -b 4096 -C '[email protected]' -f ~/.ssh/github/work -q -N ''
ssh-keygen -t rsa -b 4096 -C '[email protected]' -f ~/.ssh/github/freelance -q -N ''
ssh-add ~/.ssh/github/personal
ssh-add ~/.ssh/github/work
ssh-add ~/.ssh/github/freelance
then add this keys to appropriate bitbucket and github account
then create
touch ~/.ssh/config
and put this config
Host personal.com
HostName github.com
AddKeysToAgent yes
UseKeychain yes
User git
IdentityFile ~/.ssh/github/personal
Host work.com
HostName github.com
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/github/work
Host freelance.com
HostName github.com
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/github/freelance
then run this commands to check if keys are correct
ssh -T [email protected]
ssh -T [email protected]
ssh -T [email protected]
now if you want to clone which has access of personal account then use this
git clone [email protected]:<github account org| anything>/<repo>.git
now if you want to clone which has access of personal account then use this
git clone [email protected]:<github account org| anything>/<repo>.git
now if you want to clone which has access of personal account then use this
git clone [email protected]:<github account org| anything>/<repo>.git
Its cool to git clone from personal.com but actually its just config to use different ssh keys for different github | bitbucket account nothing else.
This method will support all the git servers mostly. may be creating ssh algorithm will change but other than that everything will be same. feel free to make comments if there is any mistake or method does not work.
dont forget to change git config for local repo don't configure git global
git config --list
git config --local
git config --local user.email [Email address you want to use]
git config --local user.name [User name you want to use]