Using an SSH Config File
Simplify your SSH workflow by defining connection parameters in a configuration file at ~/.ssh/config. These settings are also used by other commands like scp and sftp.
Host Aliases
Create an alias for a remote host using the Host directive to specify connection parameters like the hostname, username, and identity file.
For example, instead of typing:
ssh -i /home/user/.ssh/my-key.pem YOUR_USERNAME@webserver.mpcdf.mpg.de
Add the following to your ~/.ssh/config file:
Host webserver
Hostname webserver.mpcdf.mpg.de
User YOUR_USERNAME
IdentityFile /home/user/.ssh/my-key.pem
Now, connect with the much simpler command:
ssh webserver
Wildcards
Use wildcards to apply settings to multiple hosts. For example, to set a default username for all MPCDF systems:
Host *.mpcdf.mpg.de
User YOUR_USERNAME
Note: Wildcards are not supported in the Windows ssh client.
Including Other Config Files
Since OpenSSH 7.3, you can include other configuration files using the Include directive. This is useful for organizing your configurations.
For example:
Include config.d/*.conf
Include config.d/cloud/*.conf
This includes all .conf files from the .ssh/config.d/ and .ssh/config.d/cloud/ directories.