Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to SSH by given name key and hostname IP address #505

Open
josh1703658784 opened this issue Apr 7, 2022 · 1 comment
Open

How to SSH by given name key and hostname IP address #505

josh1703658784 opened this issue Apr 7, 2022 · 1 comment

Comments

@josh1703658784
Copy link

josh1703658784 commented Apr 7, 2022

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)?

@ashish1099
Copy link

ashish1099 commented Dec 20, 2022

hosts:
  192.168.1.12:
     Aliases: my_server
     Inherits: a_cool_template

I think this should work, havent tested it though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants