By ravi23sethi
e.g i create a user “student” on controller-node/master and i try this command “ansible all -m ping” its not working
i get this error:
node1 | UNREACHABLE! => { “changed”: false, “msg”: “Failed to connect to the host via ssh: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).”, “unreachable”: true }
node1 is target/slave machine
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Heya,
Just came across this answer and decided to write some general guidelines for anyone who comes across this in the future despite the old question.
The issue you’re facing seems to be related to SSH keys and permissions. When you use Ansible as a non-root user, like “student”, it uses that user’s SSH keys for connecting to the target machine.
If the user “student” does not have the right SSH key that allows access to the “node1” machine, you’ll see this Permission denied error. Check if the user “student” has the right SSH keys configured. If not, you should either add the required SSH keys for the user “student” or use the ansible_ssh_private_key_file variable in your Ansible playbook to specify the right key file.
Please make sure that the “student” user has the necessary permissions. Also, verify if the SSH authentication is configured correctly on your target machine.
For more information on how to manage SSH keys in Ansible, you can refer to the DigitalOcean tutorial.
Hope that this helps!
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.