`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.
More on Connection and SSH Failures
`UNREACHABLE! => {"msg": "Failed to connect to the host via ssh: Permission denied (publickey,password)."}`Beginner`UNREACHABLE! => {"msg": "Failed to connect to the host via ssh: ssh: connect to host 10.0.1.15 port 22: Connection timed out"}`Beginner`UNREACHABLE! => {"msg": "Failed to connect to the host via ssh: ssh: connect to host web01 port 22: Connection refused"}`Beginner`Host key verification failed.` after rebuilding a serverBeginnerThe playbook hangs for ever at "Gathering Facts" on one hostIntermediate`Failed to connect to the host via ssh: Too many authentication failures`Intermediate