# Via Jenkins, I'm trying to run ansible playbook.yml, but its failing due to below error

**URL:** <https://forum.ansible.com/t/via-jenkins-im-trying-to-run-ansible-playbook-yml-but-its-failing-due-to-below-error/28085>\
**Category:** Ansible Project\
**Created:** [July 18, 2018, 8:39pm UTC](https://forum.ansible.com/t/via-jenkins-im-trying-to-run-ansible-playbook-yml-but-its-failing-due-to-below-error/28085 "2018-07-18T20:39:03Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Deepan\_M](https://avatars.discourse-cdn.com/v4/letter/d/f19dbf/32.png) [@Deepan\_M](https://forum.ansible.com/u/Deepan_M)\
**Post date:** [July 18, 2018, 8:39pm UTC](https://forum.ansible.com/t/via-jenkins-im-trying-to-run-ansible-playbook-yml-but-its-failing-due-to-below-error/28085/1 "2018-07-18T20:39:03Z")

</div>

# UNREACHABLE! =\> {“changed”: false, “msg”: “Failed to connect to the host via ssh: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).\r\n”, “unreachable”: true}

I have added the key, even though its say ssh fail to connect.

can you please share the exact steps to fix!

---

<div class="post-metadata">

**Author:** ![Sunil\_bansal](https://avatars.discourse-cdn.com/v4/letter/s/bbe5ce/32.png) [@Sunil\_bansal](https://forum.ansible.com/u/Sunil_bansal)\
**Post date:** [July 18, 2018, 8:56pm UTC](https://forum.ansible.com/t/via-jenkins-im-trying-to-run-ansible-playbook-yml-but-its-failing-due-to-below-error/28085/2 "2018-07-18T20:56:30Z")

</div>

Hi,  
Please check if you are able to do ssh connection to that host directly without entering any password.

Regards,  
Sunil Bansal

---

<div class="post-metadata">

**Author:** ![Deepan\_M](https://avatars.discourse-cdn.com/v4/letter/d/f19dbf/32.png) [@Deepan\_M](https://forum.ansible.com/u/Deepan_M)\
**Post date:** [July 18, 2018, 9:39pm UTC](https://forum.ansible.com/t/via-jenkins-im-trying-to-run-ansible-playbook-yml-but-its-failing-due-to-below-error/28085/3 "2018-07-18T21:39:03Z")

</div>

Hi,

Thank you for response …

Yes I have added the keys on .ssh… Passwordless is working

Thanks,  
Deepan

---

<div class="post-metadata">

**Author:** ![Deepan\_M](https://avatars.discourse-cdn.com/v4/letter/d/f19dbf/32.png) [@Deepan\_M](https://forum.ansible.com/u/Deepan_M)\
**Post date:** [July 19, 2018, 10:52am UTC](https://forum.ansible.com/t/via-jenkins-im-trying-to-run-ansible-playbook-yml-but-its-failing-due-to-below-error/28085/4 "2018-07-19T10:52:58Z")

</div>

Hi,

Password less ssh enabled and i can able to run palybook from terminal, but when i try the same playbook via jenkins, its throwing an error like

# Failed to connect to the host via ssh: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).\r\n", “unreachable”: true}.

FYI… Using Ldap user for ansible play.

can some one please suggest!

Thanks,

Deepan M

---

<div class="post-metadata">

**Author:** ![Arbab\_Nazar1](https://avatars.discourse-cdn.com/v4/letter/a/3e96dc/32.png) [@Arbab\_Nazar1](https://forum.ansible.com/u/Arbab_Nazar1)\
**Post date:** [July 19, 2018, 1:58pm UTC](https://forum.ansible.com/t/via-jenkins-im-trying-to-run-ansible-playbook-yml-but-its-failing-due-to-below-error/28085/5 "2018-07-19T13:58:54Z")

</div>

when you run the playbook through jenkins, it run as jenkins user, did you add the ssh key under the jenkins’s user (/var/lib/jenkins/.ssh/) authorize key and also mentioned the user that you want to connect to remote server over ssh.

---

<div class="post-metadata">

**Author:** ![Deepan\_M](https://avatars.discourse-cdn.com/v4/letter/d/f19dbf/32.png) [@Deepan\_M](https://forum.ansible.com/u/Deepan_M)\
**Post date:** [July 19, 2018, 6:57pm UTC](https://forum.ansible.com/t/via-jenkins-im-trying-to-run-ansible-playbook-yml-but-its-failing-due-to-below-error/28085/6 "2018-07-19T18:57:20Z")

</div>

Problem fixed by adding ansible\_user=username on extra variables on jenkins build.

---

<div class="post-metadata">

**Author:** ![Wendell\_MacKenzie](https://avatars.discourse-cdn.com/v4/letter/w/c77e96/32.png) [@Wendell\_MacKenzie](https://forum.ansible.com/u/Wendell_MacKenzie)\
**Post date:** [July 19, 2018, 7:01pm UTC](https://forum.ansible.com/t/via-jenkins-im-trying-to-run-ansible-playbook-yml-but-its-failing-due-to-below-error/28085/7 "2018-07-19T19:01:26Z")

</div>

turn on debug on the ssh daemon on the target host and see why it’s complaining. perms maybe on the home dir or .ssh dir of the user you are  
attempting to run the playbook as?

---

<div class="post-metadata">

**Author:** ![Deepan\_M](https://avatars.discourse-cdn.com/v4/letter/d/f19dbf/32.png) [@Deepan\_M](https://forum.ansible.com/u/Deepan_M)\
**Post date:** [July 19, 2018, 7:06pm UTC](https://forum.ansible.com/t/via-jenkins-im-trying-to-run-ansible-playbook-yml-but-its-failing-due-to-below-error/28085/8 "2018-07-19T19:06:37Z")

</div>

Password less has been enabled, even though its failed because of permission denied, so after adding key ansible\_user value username on extra variables, now its fixed.
