The openssh client has a configuration file which is handy for configuring things you would otherwise repeat over and over on the command line.
The user configuration file is located at:
An example for the configuration format:
# comment Host host1.example.tld User bob1967 Host * User bob
The configuration will be searched for each option from top to bottom and the first match wins. This means default options should always be added at the end and more specific options first.
You can find the full documentation of the configuration file
ssh_config(5) man page.
The configuration file can be used to define aliases:
Host staging Hostname bla-staging.zone-a.example.tld Host lab1 Hostname 10.0.18.67
Now you can just
ssh staging or
When using ssh keys to login password-less you may want to disable password authentication by default:
Host * PasswordAuthentication no
This will stop
ssh from prompting for password in case of
It can still be switched on for individual hosts or by
-o PasswordAuthentication=yes on the command line.
If you have problems with flappy connections or NAT gateways dropping your idle connections you can enable server alive messages:
Host * ServerAliveInterval 15 ServerAliveCountMax 3
In this case a alive message will be sent every 15 seconds over you ssh connection keeping it alive. Connection will be dropped after 3 failures (45 seconds).