Last active
October 12, 2020 16:18
-
-
Save peterkowalski/2208fe081181fca991c8831ee113d1b2 to your computer and use it in GitHub Desktop.
[Add public SSH key for different user with Ansible] This snippet adds SSH public key for other user using root account on the remote host and password authentication (-k). #ansible #adhoc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Required by sshpass | |
export ANSIBLE_HOST_KEY_CHECKING=False | |
ansible all -i "192.168.1.1," -m authorized_key -a "user=other-user state=present key=\"{{ lookup('file', 'other-public-key.pub') }}\"" -u root -k #-CD (check and show diff) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment