Goal
Use different ssh keys for different hosts in git.
Steps
Generate the keys.
1
ssh-keygen -t rsa -C "your_email@youremail.com"
Specify the new
id_rsa
path.1
Enter file in which to save the key (/Users/user/.ssh/id_rsa): /Users/user/.ssh/id_rsa_company
Evict the oudated Identity cache.
1
ssh-add -D
Add ssh key
1
2ssh-add ~/.ssh/id_rsa
ssh-add ~/.ssh/id_rsa_companyCreate ssh config.
1
2cd ~/.ssh
touch configModify config.
1
2
3
4
5
6
7
8
9
10
11# Company
Host Company
HostName github.company.io
User yourName
IdentityFile ~/.ssh/id_rsa_company
# Myself
Host Myself
HostName github.com
User opsmilesum
IdentityFile ~/.ssh/id_rsa