title: Ansible - Failed to connect to the host via ssh: Permission denied (publickey,...password)
body: <p>I'm trying to get Ansible to connect to remote hosts but it fails with the following:</p>
  
  <pre><code>fatal: [prod-k8s-worker02]: UNREACHABLE! =&gt; {"changed": false, "msg": "Failed to connect to the host via ssh: deploy@xx.xx.xx.223: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).", "unreachable": true}
  fatal: [prod-k8s-worker01]: UNREACHABLE! =&gt; {"changed": false, "msg": "Failed to connect to the host via ssh: deploy@xx.xx.xx.222: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).", "unreachable": true}
  fatal: [prod-k8s-worker03test]: UNREACHABLE! =&gt; {"changed": false, "msg": "Failed to connect to the host via ssh: deploy@xx.xx.xx.224: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).", "unreachable": true}
  fatal: [prod-k8s-master01]: UNREACHABLE! =&gt; {"changed": false, "msg": "Failed to connect to the host via ssh: deploy@xx.xx.xx.221: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).", "unreachable": true}
  </code></pre>
  
  <p>I can successfully <code>ssh</code> without the need of a password using the same, to all of the above hosts.</p>
  
  <p>I've tried the following.</p>
  
  <p>Add the following the inventory file:</p>
  
  <pre><code>[all:vars]
  ansible_connection=ssh
  ansible_user=deploy
  ansible_sudo=true
  ansible_become=true
  ansible_ssh_common_args='-o StrictHostKeyChecking=no'
  </code></pre>
  
  <p>Added the following the <code>ansible.cfg</code> file:</p>
  
  <pre><code>[defaults]
  host_key_checking = False
  host_key_check = False
  </code></pre>
  
  <p>Also added the following the <code>ansible.cfg</code> file:</p>
  
  <pre><code>[ssh_connection]
  # ssh arguments to use
  ssh_args = -o StrictHostKeyChecking=no
  </code></pre>
  
  <p><strong>Verbose</strong></p>
  
  <p>When I run in the playbook using <code>-vvvv</code> I get the following:</p>
  
  <pre><code>
  fatal: [prod-k8s-worker01]: UNREACHABLE! =&gt; {
      "changed": false, 
      "msg": "Failed to connect to the host via ssh: deploy@xx.xx.xx.222: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).", 
      "unreachable": true
  }
  &lt;xx.xx.xx.223&gt; (255, '', 'deploy@xx.xx.xx.223: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).\r\n')
  fatal: [prod-k8s-worker02]: UNREACHABLE! =&gt; {
      "changed": false, 
      "msg": "Failed to connect to the host via ssh: deploy@xx.xx.xx.223: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).", 
      "unreachable": true
  }
  &lt;xx.xx.xx.224&gt; (255, '', 'deploy@xx.xx.xx.224: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).\r\n')
  fatal: [prod-k8s-worker03test]: UNREACHABLE! =&gt; {
      "changed": false, 
      "msg": "Failed to connect to the host via ssh: deploy@xx.xx.xx.224: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).", 
      "unreachable": true
  }
  &lt;xx.xx.xx.221&gt; (255, '', 'deploy@xx.xx.xx.221: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).\r\n')
  fatal: [prod-k8s-master01]: UNREACHABLE! =&gt; {
      "changed": false, 
      "msg": "Failed to connect to the host via ssh: deploy@xx.xx.xx.221: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).", 
      "unreachable": true
  }
  </code></pre>