Interview Prep/Ansible/Connection and SSH Failures

`Failed to connect to the host via ssh: ... Permission denied` only when the playbook runs from CI, not from my laptop

IntermediateTroubleshootingConnection and SSH Failures
Answer

Likely causes → CI runner lacks the key or ssh-agent, key file permissions are too open, or the user name differs.

Diagnose →

ls -l $KEY_FILE            # must be 600
ssh -i $KEY_FILE -o BatchMode=yes -vv user@host true

Fix → Write the key from a secret to a file with chmod 600, and pass --private-key. Set ANSIBLE_REMOTE_USER explicitly.

Prevent → Use the same container image locally and in CI.

All Ansible questions Roadmap: Ansible

More on Connection and SSH Failures