D
D
Digsecman2019-07-10 11:46:14
SSH
Digsecman, 2019-07-10 11:46:14

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

4 answer(s)
D
Dmitry, 2019-07-10
@q2digger

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.

P
polar_yogi, 2019-07-10
@polar_yogi

It is possible to set
PermitRootLogin yes
in /etc/ssh/sshd_config. After copying the key, you can set
PermitRootLogin prohibit-password

V
Vladimir, 2019-07-10
@mole2

Permission denied, please try again.
most likely the possibility of root authorization via ssh is closed

P
Puma Thailand, 2019-07-10
@opium

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 question

Ask a Question

731 491 924 answers to any question