To check if you can ssh :
# Connection Test 1: basic connection
ansible staging -m raw <span class="hljs-_">-a</span> whoami -u root
# Connection Test 2: force choice of private ssh key
ansible staging -m raw <span class="hljs-_">-a</span> whoami -u root --private-key=~.ssh/id_rsa
If test 2 is working then ansible is confused which key to use. To solve this specify it in your hosts/staging (staging is just an example this applies to production environment as well) file
like this:
# hosts/staging example.com ansible_host=123.456.789 ansible_ssh_private_key_file='~.ssh/id_rsa' [staging] example.com [web] example.com