moul/assh

How to SSH by given name key and hostname IP address

josh1703658784 opened this issue · 1 comments

I'm in a scenario where I need SSH configuration for Ansible (which relies on IP address in our case), but I also will need to periodically log into these servers with a human readable name to make my life easy. No hostname is associated with the IP addresses.

I have this config:

hosts:
  my_server:
     Hostname: 192.168.1.12
     Inherits: a_cool_template

I can successfully run ssh my_server however ssh 192.168.1.12 will fail. The only workaround I found is below, but I don't like needing to specify the same value/IP twice.

hosts:
  my_server:
     Hostname: 192.168.1.12
     Aliases: 192.168.1.12
     Inherits: a_cool_template

Is there a better way to write a config that allows SSH by the given name (my_server) and the hostname (192.168.1.12)?

hosts:
  192.168.1.12:
     Aliases: my_server
     Inherits: a_cool_template

I think this should work, havent tested it though