The configuration file
It is possible to specify host configuration in .ssh/config
. This can be helpful in various situations, as it allows you to specify:
- Custom (friendly) names for hosts
- The default user to use
- The port
- Tunnels to open before connecting
- Identity files (keys)
Among many other things.
Note
If a server you connect to has a permanent IP address, it can make sense to specify it in your SSH config file to avoid relying on DNS or CDNs during a disaster recovery situation.
SSH configuration files aren’t particularly complicated, so we’ll show you an example here that uses many of the available features:
# Set Defaults for all hosts using the glob character (*)Host *
ServerAliveInterval 30 # Check if the connection is alive every 30 seconds
ForwardAgent yes # Forward SSH agent to the remote host
Compression yes # Enable compression
IdentityFile ~/.ssh...