On using tls certificates and .ssh/config.

On using tls certificates and .ssh/config.

Photo by Markus Winkler on Unsplash

Just a quick note here on TLS certificates. Because I had to look it up and figure it out. Again!

It is possible to define several keys for a site and login as different users using each certificate.

I found myself needing to do just that for github.com, as my employer has private repositories there that I need to access.

Adding something like this to $HOME/.ssh/config

Host github-personal
    HostName github.com
    IdentityFile ~/.ssh/id_rsa_personal

Host github-edb
    HostName github.com
    IdentityFile ~/.ssh/id_rsa_edb

Host gitlab-personal
    HostName gitlab.com
    IdentityFile ~/.ssh/id_rsa_personal

So instead of

git clone git@github.com:EnterpriseDB/somerepo.git

I’ll write:

$ git clone git@github-edb:EnterpriseDB/somerepo.git

or

$ git clone git@github-personal:michaelwiller/somerepo.git

… and the correct certificate will be applied to log me in.

The same can be used for ssh shortcut names for servers and users. See this post as a reference.

Photo by Markus Winkler on Unsplash