Receiving an error message “Ansible ssh error permission denied (password)”? We can help you in fixing it.
Ansible is an open-source automation tool. It is simple to set up and a powerful tool.
At Bobcares, we often get requests to fix ansible ssh errors as a part of our Server Management Services.
Today, let’s see how our Support Engineers fix this error.
Root cause for the ansible permission denied error
We’ve seen many of our customers experiencing errors while executing ansible commands. One such error is permission denied error.
By default, ansible tries to connect to the remote server using key-based authentication. When the key-based authentication is not set up between the server the error will be displayed.
Let’s now discuss how our Support Engineers resolve it.
How we resolve “Ansible ssh error permission denied (password)”
To resolve the error we set up key-based authentication between the servers. There is also an alternative method. We can add an additional argument to execute it without error.
Setup key-based authentication
Let’s discuss how our Support Engineers set up key-based authentication between the two servers.
First, we generate a key in the server where ansible is configured. We use the below command to generate a key.
ssh-keygen -t rsa
Now we copy the key to the remote server using the command:
ssh-copy-id username@remote_server
Now we enter the password of the server. It will copy the key to the remote server.
Now we will be able to login to the server without using the password. Also will be able to execute the command without any error.
Prompt for a password
We can adjust the command to prompt for a password when executing the command. We use the below command to prompt for the login before execution.
ansible-playbook --ask-pass -i hosts playbook.yml
Now we enter the login. We will be able to execute the command successfully.
[Need any assistance with fixing Ansible errors? – We’ll help you]
Conclusion
In short, we have discussed the causes for the error “Ansible ssh error permission denied ( password)”. Also, we have discussed how our Support Engineers resolve it.
0 Comments