SSH config for simplify connection to many similar hosts

Updated . Posted . Visible to the public. Repeats.

Suppose you have three hosts (host.one.domain.name, host.two.domain.name host.three.domain.name) with the same credentials, with access by ssh key, then any time when you need to connect to host you must type something like this:

ssh user@host.one.domain.name -i path/to/key_file

^
ssh user@host.one.domain.name -i path/to/key_file

You can simplify your life by creating file ~/.ssh/config, with content:

Host one two three
  HostName host.%h.domain.name
  User user
  IdentityFile path/to/key_file

And now you can connect to any of this items just by typing the following:

ssh one #or ssh two, or ssh three
konjoot
Last edit
konjoot
Keywords
ssh, config, key
Posted by konjoot to wiki (2014-11-13 13:11)