Allow ssh ssh permission

I generated an ssh key and copied it to a remote server. When I try ssh on this server, everything works fine:

ssh user@ip _address 

The user is not root. If I try to hide ssh, follow these steps:

 ansible-playbook -i hosts playbook.yml 

with playbook available:

 --- - hosts: web remote_user: user tasks: - name: test connection ping: 

and hosts file:

 [web] 192.168.0.103 

I got an error:

 ... Permission denied (publickey,password) 

What is the problem?

+6
source share
3 answers

Ansible uses a different key than what you use to connect to this "web machine".

You can explicitly configure the ability to use a specific private key with

 private_key_file=/path/to/key_rsa 

as indicated in the docs . Make sure that you allow this key to be used for the remote user on the remote computer using ssh-copy-id -i /path/to/key_rsa.pub user@webmachine _ip_address

+9
source

In my case, I got a similar error when starting a downloadable book when the host changed its fingerprint. I found this while trying to establish an ssh connection from the command line. So, after running ssh-keygen -f "/root/.ssh/known_hosts" -R my_ip this problem has been resolved.

+1
source

Hi Launch the game as shown below. by default, ansible plays using root. Ansible-playbook -i hosts playbook.yml -u. If the error still appears, run below and paste the output here. Ansible-playbook -i hosts playbook.yml -u -vvv

0
source

Source: https://habr.com/ru/post/985033/


All Articles