User Profile SSH Config File

Background

I hadn’t used a ~/.ssh/config since I’m such a curmudgeon. However, as I’m managing hosts on more and diverse networks from a single machine, I needed a way to make everything gel.

  1. The first of these networks require kerberized logins. There’s a fallback password prompt, but I always want to make use of my TGT. This Kerberos Identity is also not my default identity.
  2. The second network uses key-based authentication. To prevent this from conflicting with my default key, I set the key to be used. The saves me from having to use an -i flag.
  3. I also have a machine in EC2 that has a different key.

Solution

Host <alias>
    hostname <host.domain.tld>
    user <username>
    GSSAPIClientIdentity <username@DOMAIN.TLD>
    PasswordAuthentication no

Host <alias>
    hostname <host.domain.tld>
    IdentityFile ~/.ssh/<id_file>
    port <port number>

Host <alias>
    hostname <host.domain.tld>
    user <username>
    IdentityFile ~/.ssh/<other_id_file>

Now when I go to ssh, I just type

ssh <alias>

and I’m in. No more flags!

References