assh icon indicating copy to clipboard operation
assh copied to clipboard

How to SSH by given name key and hostname IP address

Open josh1703658784 opened this issue 2 years ago • 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)?

josh1703658784 avatar Apr 07 '22 21:04 josh1703658784

hosts:
  192.168.1.12:
     Aliases: my_server
     Inherits: a_cool_template

I think this should work, havent tested it though

ashish1099 avatar Dec 20 '22 05:12 ashish1099