Answer the question
In order to leave comments, you need to log in
Ansible: Can't copy ssh key from one host to another?
Hello! I installed Ansible on Centos 7, generated an ssh key, I try to copy it to a remote host (Ubuntu) but it says access is denied.
ssh-copy-id [email protected]###
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/ bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
[email protected]###'s password:
Permission denied, please try again.
Maybe something needs to be corrected in the configs of the remote host?
Answer the question
In order to leave comments, you need to log in
On a remote system, remote access by root is simply prohibited.
This is usually not required.
Add a key so that the ansible goes as a regular user and specify in the playbook that it elevate privileges on the remote host (roughly speaking, the ansible will execute commands via sudo there).
ansible-playbook -i inventory.txt your-role.yml -b -K
this "-b" option become , and -K will tell ansible to ask you for your password for privilege escalation.
It is possible to set
PermitRootLogin yes
in /etc/ssh/sshd_config. After copying the key, you can set
PermitRootLogin prohibit-password
Permission denied, please try again.
most likely the possibility of root authorization via ssh is closed
Somehow you strangely copy it, get it through stdout and then put the action through the locale
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question