The multiple ssh keys for bitbucket and github
Create two keys for bitbucket and github
mkdir sshkey
ssh-keygen -t rsa -C "company" -f "company"
ssh-keygen -t rsa -C "JTNOMONEY" -f "JTNOMONEY"
Clear cached key
ssh-add -D
Add two keys and check afterwards
ssh-add ~/sshkey/company
ssh-add ~/sshkey/JTNOMONEY
ssh-add -l
If ssh-add
is not working, try
eval "$(ssh-agent)"
Add a config files ./ssh/config
#--Company's bitbucket
Host bitbucket.company.com.tw
HostName bitbucket.company.com.tw
IdentityFile ~/.ssh/company
#--JTNOMONEY github
Host github.com
HostName github.com
IdentityFile ~/.ssh/JTNOMONEY
Set an example of default name/email using git config
and check settings
#--Company's bitbucket
git config --global user.name "company_name"
git config --global user.email "company_name@company.com"
git config --list
Add your ssh public keys on github/bitbucket, then test github account for example:
git clone git@github.com:JTNOMONEY/jtnomoney.github.io.git
jtnomoney.github.io$ git config user.name "jtnomoney"
jtnomoney.github.io$ git config user.email "jtnomoney@gmail.com"