SSH Permission Denied when connecting to Centos 7 through Ansible

Sharing an experience where i spent sometime to figure out the exact issue when connecting to Centos 7 from ubuntu 18.04 through Ansible and the SSH along with private key is working in terminal, but only when executing the ansible getting the below error.

Based on the error message, it is a kind of permission issue, but after tailing the /var/log/secure observed that this caused by ownership mode for the file authorized_keys.

Then updated the permission to 600 means “chmod 600 authorized_keys”. even after that got the below logs.

Then updated the permission of .ssh folder to 700 means “chmod 700 .ssh”. After that only able to connect through ansible.

Hope this helps someone to reduce the time of investigation…

Senior Tech Lead — Enterprise Integration | WSO2 Certified Solution Architect | https://ajanthane.blogspot.com/

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store