DEV Community

Discussion on: How to Manage Multiple SSH Key Pairs

Collapse
 
armyofda12mnkeys profile image
armyofda12mnkeys • Edited

Note I have a personal github and a work github account... and I used something like this instead:

//personal account for github.com, note can also choose to leave this as 'Host github.com' if dont' have other keys and want this to be the default
Host github-my_personal_username
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa-github-my_personal_username
// IdentitiesOnly yes

//work account for github.com
Host github-my_work_username
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa-github-my_work_username
// IdentitiesOnly yes

and just change the clone url slight when needed:
$ git clone git@github-my_work_username:me/repo.git