I didn’t know about the
~/.ssh/config file until quite
recently and it’s really handy, so I thought I’d share.
~/.ssh/config lets you make what I think of as ssh
aliases. You can give connections short names and specify various
connection settings ‒ pretty much anything you can pass to
ssh’s CLI can
be configured here.
Here’s a simple example:
I am then able to do, for example, simply:
These settings apply from top to bottom, cumulatively. So you want to structure this file with specific rules above general rules, otherwise the general rules will override the specific, which is not what you want.
One nice benefit is that you’ll get autocompletion of hosts defined
~/.ssh/config when using
ssh under bash or
zsh (at least).
~/.ssh/config can also be used to shore up some of the
leaky parts of sshing, as described here
‒ the whole page, and other articles in the series (linked at the top)
are worth a read if you use ssh a decent amount.