# ssh-key exchange and root password set

**URL:** <https://forum.ansible.com/t/ssh-key-exchange-and-root-password-set/37824>\
**Category:** Ansible Project\
**Created:** [March 29, 2023, 10:56am UTC](https://forum.ansible.com/t/ssh-key-exchange-and-root-password-set/37824 "2023-03-29T10:56:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Prady\_A](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/prady_a/32/4792_2.png) [@Prady\_A](https://forum.ansible.com/u/Prady_A)\
**Post date:** [March 29, 2023, 10:56am UTC](https://forum.ansible.com/t/ssh-key-exchange-and-root-password-set/37824/1 "2023-03-29T10:56:23Z")

</div>

Hello folks

As a new learner, I am trying to copy the ssh pub key to the managed node as below.

ssh\_install.yml

---

<div class="post-metadata">

**Author:** ![vbotka](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/vbotka/32/359_2.png) [@vbotka](https://forum.ansible.com/u/vbotka)\
**Post date:** [March 29, 2023, 12:02pm UTC](https://forum.ansible.com/t/ssh-key-exchange-and-root-password-set/37824/2 "2023-03-29T12:02:45Z")

</div>

> #ansible-playbook -i inventory ssh\_install.yml \*-k\*  
> ... avoid the -k option

Use \*ssh-agent\*.  
[https://www.ssh.com/academy/ssh/agent](https://www.ssh.com/academy/ssh/agent)

It is a bad practice to \*ssh\* to root. See  
[https://docs.ansible.com/ansible/latest/playbook\_guide/playbooks\_privilege\_escalation.html](https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_privilege_escalation.html)

> password: "{{ 'PLAIN\_PASSWORD' | password\_hash('sha512') }}"

See how to use Ansible vault  
[https://docs.ansible.com/ansible/latest/cli/ansible-vault.html](https://docs.ansible.com/ansible/latest/cli/ansible-vault.html)

The next option is \*passwordstore\*  
[https://www.passwordstore.org/](https://www.passwordstore.org/)

See the Ansible \*passwordstore\* lookup plugin  
[https://docs.ansible.com/ansible/latest/collections/community/general/passwordstore\_lookup.html](https://docs.ansible.com/ansible/latest/collections/community/general/passwordstore_lookup.html)
