IĀ used to use Text Expander to shortcut ssh hostnames, but as I setup a new laptop this last year, got into doing it all more “properly” with my ssh config file and wanted a fresh start.
If you’re unfamiliar with the practice, you can store an alias at ~/.ssh/config
, with an entry like this:
host <alias>
hostname <IP or FQDN>
user <user>
port <port>
IdentityFile <path/to/private/key/file.rsa>
I’d gotten into the bad habit of using “old” names for a couple of our StagingPilot instances, relying on the muscle memory of an old name, even as we had migrated workers and services to new servers with revised names, and just redirected those old names with Text Expander. I was excited to discover I could add multiple aliases for a host in my config file, meaning I could use either interchangeably.
host spapp spserver
hostname app.stagingpilot.com
user ptyler
IdentityFile ~/private/key/file
Now it no longer matters if I remember ssh spapp
or ssh spserver
, both resolve immediately.