Different SSH keys for each host.

1,294 views
Skip to first unread message

junkmailt...@gmail.com

unread,
Jan 20, 2015, 4:36:04 PM1/20/15
to ansible...@googlegroups.com
I know it's possible to add --private-key=path/to/key to specify which ssh key you would like Ansible to use. However that assumes that each host requires the same key. Is it possible to specify that setting per host, perhaps in the inventory file or something?

Brian Coca

unread,
Jan 20, 2015, 4:37:44 PM1/20/15
to ansible...@googlegroups.com
set this as a host or group var:
ansible_ssh_private_key_file



--
Brian Coca

Matt Martz

unread,
Jan 20, 2015, 4:38:41 PM1/20/15
to ansible...@googlegroups.com
Via inventory you can set 'ansible_ssh_private_key_file' per host.  See http://docs.ansible.com/intro_inventory.html#list-of-behavioral-inventory-parameters

On Tue, Jan 20, 2015 at 3:36 PM, <junkmailt...@gmail.com> wrote:
I know it's possible to add --private-key=path/to/key to specify which ssh key you would like Ansible to use. However that assumes that each host requires the same key. Is it possible to specify that setting per host, perhaps in the inventory file or something?

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/304d0a52-53d0-4a52-836a-a4b44c4ca55b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Matt Martz
@sivel
sivel.net

junkmailt...@gmail.com

unread,
Jan 21, 2015, 7:38:50 AM1/21/15
to ansible...@googlegroups.com
Thanks!

Apparently I missed that when I was reading that list.

junkmailt...@gmail.com

unread,
Jan 21, 2015, 8:00:04 AM1/21/15
to ansible...@googlegroups.com
Also is there a way to do the same thing with host_key_checking? I'd like to turn that off but only for a certain set of hosts (eg. dev hosts generated on the fly).


On Tuesday, January 20, 2015 at 4:38:41 PM UTC-5, Matt Martz wrote:

Dan Vaida

unread,
Jan 21, 2015, 3:19:12 PM1/21/15
to ansible...@googlegroups.com
I don't believe it's possible to have that per host, via Ansible. But you could set it up in your ssh config. There were a few other threads in this mailing list about this topic. One would be: https://groups.google.com/d/msg/ansible-project/8p3XWlo83ho/Q1SflaZ9dyAJ
Reply all
Reply to author
Forward
0 new messages