Solution for add keys mutual

13 views
Skip to first unread message

Henrik Schuetze

unread,
Aug 21, 2018, 8:39:30 AM8/21/18
to Ansible Project
Hi,

i want to enable ssh between two linux hosts.
i generate the ssh key on both hosts.
and then i need to add the keys on the other servers respectively

Does anyone has a ready solution for that?


greetings
Henrik

Jonathan Lozada De La Matta

unread,
Aug 21, 2018, 8:57:30 AM8/21/18
to ansible...@googlegroups.com

--
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/ee33b3bc-5588-40b9-a3e3-ad1fe5ecacb4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--

Jonathan lozada de la matta

AUTOMATION CONSULTANT - AUTOMATION PRACTICE

Red Hat Consulting Services

jloz...@redhat.com   



 

S C Rigler

unread,
Aug 21, 2018, 8:59:45 AM8/21/18
to ansible...@googlegroups.com
Look at ssh-copy-id

--

Henrik Schuetze

unread,
Aug 21, 2018, 9:13:31 AM8/21/18
to Ansible Project
thanx. but i need to address the other host. And i dont want to hard code the ip adress in this task

Jonathan Lozada De La Matta

unread,
Aug 21, 2018, 9:15:29 AM8/21/18
to ansible...@googlegroups.com
what do you mean? hard code what exactly?

--
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.

For more options, visit https://groups.google.com/d/optout.

Henrik Schuetze

unread,
Aug 21, 2018, 9:24:39 AM8/21/18
to Ansible Project
the syntax for ssh-copy-id is: ssh-copy-id -i ~/.ssh/mykey user@host

And i want:   from Host1 to Host2
              and from host2 to host1

I don't know how to specify the other host in a such a scenario

Jonathan Lozada De La Matta

unread,
Aug 21, 2018, 9:29:00 AM8/21/18
to ansible...@googlegroups.com
Do one host first then the other if you are doing this manually. If you are trying to use ansible to exactly do this steps then use the user module and authorized_key


For more options, visit https://groups.google.com/d/optout.

Henrik Schuetze

unread,
Aug 21, 2018, 1:44:22 PM8/21/18
to Ansible Project
I found a solution:

In my inventory files i put the remote IP and the remote ssh key.
In my task main.yml i use:

- name:  copy the ssh key
  authorized_key:
   user: root
   state: present
   key: "{{ remote_key }}"

that solve my problem. 

Thanx for the help
Reply all
Reply to author
Forward
0 new messages