Ansible unable to SSH

Hi All,

I have set up passwordless authentication on my AWS instance running on RHEL 9. After restarting my machine I could see that adhoc commands
are not able to ping the remote hosts.

Below things I tried to check (if they changed after boot),

  1. Modified the public IP addresses of the instances in /etc/ansible/hosts file.
  2. Modified the public IP addresses of the instances in /etc/hosts file.
  3. Tried to restart sshd service on remote hosts.
  4. Checked the sudo’ers file, if user/s changed.
  5. AWS Security groups have necessary permissions to allow SSH traffic.
  6. Checked if 600 and 700 permissions are on .ssh & authorized keys.

As per the below snip, something broke after restart, can anyone suggest over it ?


1 Like

It looks to me as though Ansible is using an incorrect SSH private key to login. Find your private key file and attempt a login manually:

$ ssh -i privatekeyfilename -l ansible <IP-of-target>

Adding -v if required to see a bit more of what’s going on. If that works then you’ll be on the right track.

Then, with your ansible ad-hoc try adding four Vs -vvvv to see the SSH command it’s using.


In my case it was the user which I was not correct. But thanks for this information as well !


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.