Configuration files in OpenSSH

OpenSSH lets you define connection parameters within a configuration file named config and located in $HOME/.ssh/. This configuration file can be used for other commands like scp or sftp.

Include other configurations

Since OpenSSH 7.3p1, separate configuration files can be included in the main config file via the include directive.

include config.d/*.conf
include config.d/cloud/*.conf

This includes all files ending with .conf in .ssh/config.d/ and .ssh/config.d/cloud/.

Each remote host can be defined with the Host directive. It introduces a block containing several connection options, like so:

Host webserver
  Hostname webserver.mpcdf.mpg.de
  User MPCDF_USER_NAME
  IdentityFile /home/user/.ssh/my-key.pem

This is equivalent to:

ssh -i /home/user/.ssh/my-key.pem mpcdf_user@webserver.mpcdf.mpg.de

Now, with the configuration block defined, we can simply connect to webserver with:

ssh webserver

Wildcards

If the same option is reused often, it can be defined separately in a wildcard block like so:

Host *.mpcdf.mpg.de
  User MPCDF_USER_NAME

This means that all connections will implicitely be as the user root.

Wildcards do not work in Windows.