Using an SSH Config File
You can 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
You can create an alias for a remote host using the Host directive. This allows you 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
You can 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, you can connect with the much simpler command:
ssh webserver
Wildcards
You can 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
Please note that 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 can be useful for organizing your configurations.
For example:
Include config.d/*.conf
Include config.d/cloud/*.conf
This will include all .conf files from the .ssh/config.d/ and .ssh/config.d/cloud/ directories.