title: How to Run Ansible Playbook using a public ssh key
body: <p>I'm trying to run my Ansible playbook on a remote server using a provided ssh key. </p>
  
  <p>I have added the following configuration to my inventory file:</p>
  
  <pre><code>all:
    hosts:
      server1:
        ansible_host: sample.server@noname.com
        dest_dir: /root
        sample_tree: sample_tree.txt
        private_key_file: ../config/id_rsa_tf
  </code></pre>
  
  <p>I have referenced it in my playbook using the following:</p>
  
  <pre><code>- name: "Nightly Deploy"
    hosts: server1
    remote_user: sysuser
    tasks:
      - name: Copy test from local to remote
        tags:
          - copy
          - all
        copy:
          src: "test.tgz"
          dest: "{{ dest_dir }}/test.tgz"
  
  </code></pre>
  
  <p>I am running the playbook with the following command: </p>
  
  <p><code>ansible-playbook --tags="copy" -v -i inventories/nightly-build.yaml  playbooks/nightly-build.yaml</code></p>
  
  <p>The error I'm getting is the following:</p>
  
  <blockquote>
    <p>fatal: [server1]: UNREACHABLE! => {"changed": false, "msg": "Failed to<br>
    connect to the host via ssh: Permission denied (publickey,gssapi-  keyex,gssapi-with-mic,password).", "unreachable": true}</p>
  </blockquote>
  
  <p>Is my <code>private_key_file</code> wrong in my inventory file or am I calling it wrong? and help would be great </p>