I'm trying to configure my SSH config file to try several different keys and users for a domain. I was using a function in my dotfiles to do this originally but it's unwieldy, slow, and ugly.
My company has multiple servers with different private keys and users for SSH login. There are a plethora of hostnames, but the domain is always the same.
I could look up in our master record what key/username pair I need, but that's no fun.
This is part of my SSH config file:
Host *.companydomain.net
User ubuntu
PreferredAuthentications publickey
IdentityFile ~/.ssh/key_a.pem
Host *.companydomain.net
User ubuntu
PreferredAuthentications publickey
IdentityFile ~/.ssh/key_b
Host *.companydomain.net
User anotheruser
PreferredAuthentications publickey
IdentityFile ~/.ssh/key_c
So right now it seems like the first entry (using key_a.pem) is tried, then it fails and doesn't fall through. Ideally, I'd like this to fall through and try each of the three combinations until a log in succeeds.
I am running macOS running OpenSSH_7.6p1.
Thanks!