Last Updated: February 25, 2016
·
1.131K
· alexdenisov

Different ssh keys for different hosts

Generate new ssh-key

$ ssh-keygen -t rsa -C "Some comment"

And add your hosts and the ssh keys to a ~/.ssh/config file like below

Host Github github.com
Hostname github.com
IdentityFile ~/.ssh/github_rsa
Host GitLab gitlab.example.com
Hostname gitlab.example.com
IdentityFile ~/.ssh/gitlab_rsa