Today I learned how to use multiple SSH keys on one computer.
At work, all projects are hosted on our company’s internal git server running GitLab CE. while I put all my personal projects on GitHub.
I wanted to use different keys for GitLab and GitHub. So that I can have different passphrases for each SSH key, making it a bit more secure.
Or even different SSH key type on GitHub and GitLab. From the docs, GitHub uses RSA key while GitLab recommends ED25519 over RSA.
I use RSA key for both services for now.
Generating SSH Keys
I generated 2 SSH key pairs. The default one is for company’s work at GitLab.
$ ssh-keygen -t rsa -b 4096 -C "firstname.lastname@example.org"
and another pair for GitHub stored at
$ ssh-key -t rsa -b 4096 -C "email@example.com" -f ~/.ssh/github
~/.ssh/ folder, I have 2 pairs of SSH keys.
$ ls -1 ~/.ssh
Update SSH Config File
Now I have to tell SSH client to use the different private key for GitHub.
~/.ssh/config file, add a new configuration for GitHub.com:
This means every time it has to make a connection to
use another private key at
~/.ssh/github instead of the default one.
This includes git as well.
I added the public key
~/.ssh/github.pub to my GitHub account settings page.
and make a test connection to verify that it works.
$ ssh -T firstname.lastname@example.org
Hi armno! You've successfully authenticated, but GitHub does not provide shell access.