# Unable to ssh to ansible server from jenkins server

**URL:** <https://community.jenkins.io/t/unable-to-ssh-to-ansible-server-from-jenkins-server/6080>\
**Category:** Using Jenkins\
**Created:** [March 2, 2023, 6:44pm UTC](https://community.jenkins.io/t/unable-to-ssh-to-ansible-server-from-jenkins-server/6080 "2023-03-02T18:44:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sunil](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/sunil/32/3529_2.png) [@Sunil](https://community.jenkins.io/u/Sunil)\
**Post date:** [March 2, 2023, 6:44pm UTC](https://community.jenkins.io/t/unable-to-ssh-to-ansible-server-from-jenkins-server/6080/1 "2023-03-02T18:44:58Z")

</div>

While connecting through ssh to ansible server from jenkins, its showing:  
“error: exception when publishing, exception message [failed to connect and initialize ssh connection. message: [failed to connect session for config [ansible]. message [auth fail]]] build step ‘send build artifacts over ssh’ changed build result to unstable”.  
I have already added and copied ssh keys to ansible server and also changed remotelogin in sshd config of ansible server.  
Would any help me reach out this??

---

<div class="post-metadata">

**Author:** ![halkeye](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/halkeye/32/8_2.png) [@halkeye](https://community.jenkins.io/u/halkeye)\
**Post date:** [March 2, 2023, 7:01pm UTC](https://community.jenkins.io/t/unable-to-ssh-to-ansible-server-from-jenkins-server/6080/2 "2023-03-02T19:01:13Z")

</div>

I would recommend wrapping your ansible stuff using [SSH Agent](https://plugins.jenkins.io/ssh-agent/) that way you don’t need to copy random ssh keys onto servers in the right directories and stuff, you can just use ssh-agent and jenkins credentials
