# SSH not working to client machine (ssh from command line works) - Ansible 2.1.0

**URL:** <https://forum.ansible.com/t/ssh-not-working-to-client-machine-ssh-from-command-line-works-ansible-2-1-0/22373>\
**Category:** Ansible Project\
**Tags:** ubuntu\
**Created:** [August 24, 2016, 8:03pm UTC](https://forum.ansible.com/t/ssh-not-working-to-client-machine-ssh-from-command-line-works-ansible-2-1-0/22373 "2016-08-24T20:03:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anfield](https://avatars.discourse-cdn.com/v4/letter/a/dec6dc/32.png) [@Anfield](https://forum.ansible.com/u/Anfield)\
**Post date:** [August 24, 2016, 8:03pm UTC](https://forum.ansible.com/t/ssh-not-working-to-client-machine-ssh-from-command-line-works-ansible-2-1-0/22373/1 "2016-08-24T20:03:34Z")

</div>

When I run ansible all -m ping -vvvv from the controller to the client (ubuntu) I get the following -

Loaded callback minimal of type stdout, v2.0  
\<10.10.128.0\> ESTABLISH WINRM CONNECTION FOR USER: Administrator on PORT 5986 TO 10.10.128.0  
\<10.10.128.2\> ESTABLISH SSH CONNECTION FOR USER: None  
\<10.10.128.2\> SSH: EXEC ssh -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r 10.10.128.2 ‘/bin/sh -c ‘"’"’( umask 77 && mkdir -p “`echo $HOME/.ansible/tmp/ansible-tmp-1472067867.19-242906541295629`” && echo ansible-tmp-1472067867.19-242906541295629=“`echo $HOME/.ansible/tmp/ansible-tmp-1472067867.19-242906541295629`” ) && sleep 0’“'”‘’  
10.10.128.2 | UNREACHABLE! =\> {  
“changed”: false,  
“msg”: “Failed to connect to the host via ssh.”,  
“unreachable”: true

Verified that ssh works fine if i run it from command line on the controller.

Any ideas? I verified that the same user exists on both machines (admin). admin was used to setup ssh.

Ansible itself was installed by root on the controller.

Any ideas? Thanks

---

<div class="post-metadata">

**Author:** ![Anfield](https://avatars.discourse-cdn.com/v4/letter/a/dec6dc/32.png) [@Anfield](https://forum.ansible.com/u/Anfield)\
**Post date:** [August 25, 2016, 2:27pm UTC](https://forum.ansible.com/t/ssh-not-working-to-client-machine-ssh-from-command-line-works-ansible-2-1-0/22373/2 "2016-08-25T14:27:36Z")

</div>

Anyone?

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [August 25, 2016, 4:30pm UTC](https://forum.ansible.com/t/ssh-not-working-to-client-machine-ssh-from-command-line-works-ansible-2-1-0/22373/3 "2016-08-25T16:30:37Z")

</div>

> When I run ansible all -m ping -vvvv from the controller to the client  
> (ubuntu) I get the following -
> 
> Loaded callback minimal of type stdout, v2.0  
> \<10.10.128.0\> ESTABLISH WINRM CONNECTION FOR USER: Administrator on PORT  
> 5986 TO 10.10.128.0  
> \<10.10.128.2\> ESTABLISH SSH CONNECTION FOR USER: None

Since user is None, no user is specified, ten Ansible will use the user running ansible-playbook.

> \<10.10.128.2\> SSH: EXEC ssh -C -vvv -o ControlMaster=auto -o  
> ControlPersist=60s -o KbdInteractiveAuthentication=no -o  
> PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey  
> -o PasswordAuthentication=no -o ConnectTimeout=10 -o  
> ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r 10.10.128.2 '/bin/sh -c  
> '"'"'( umask 77 && mkdir -p "` echo  
> $HOME/.ansible/tmp/ansible-tmp-1472067867.19-242906541295629 `" && echo  
> ansible-tmp-1472067867.19-242906541295629="` echo  
> $HOME/.ansible/tmp/ansible-tmp-1472067867.19-242906541295629 `" ) && sleep  
> 0'"'"''  
> 10.10.128.2 | UNREACHABLE! =\> {  
> &nbsp;&nbsp;&nbsp;&nbsp;"changed": false,  
> &nbsp;&nbsp;&nbsp;&nbsp;"msg": "Failed to connect to the host via ssh.",  
> &nbsp;&nbsp;&nbsp;&nbsp;"unreachable": true
> 
> Verified that ssh works fine if i run it from command line on the  
> controller.
> 
> Any ideas? I verified that the same user exists on both machines (admin).  
> admin was used to setup ssh.

So you are logged inn as admin and running ansible-playbook and this user can login to the node 10.10.128.2?

---

<div class="post-metadata">

**Author:** ![Anfield](https://avatars.discourse-cdn.com/v4/letter/a/dec6dc/32.png) [@Anfield](https://forum.ansible.com/u/Anfield)\
**Post date:** [August 25, 2016, 6:37pm UTC](https://forum.ansible.com/t/ssh-not-working-to-client-machine-ssh-from-command-line-works-ansible-2-1-0/22373/4 "2016-08-25T18:37:20Z")

</div>

No - all I am doing here is a ping to validate that the controller and target can communicate. This should work before I setup playbooks.

Since I read somewhere that it makes sense to setup an ansible user on each machine for use with ansible I had the admin user on each server previously setup or it was setup with the OS install (I cant recall)

All I did was create the ssh keys on each box as the admin user and then copy them to the other VM.

Any ideas how to resolve?

---

<div class="post-metadata">

**Author:** ![Anfield](https://avatars.discourse-cdn.com/v4/letter/a/dec6dc/32.png) [@Anfield](https://forum.ansible.com/u/Anfield)\
**Post date:** [August 25, 2016, 6:57pm UTC](https://forum.ansible.com/t/ssh-not-working-to-client-machine-ssh-from-command-line-works-ansible-2-1-0/22373/5 "2016-08-25T18:57:20Z")

</div>

yes I am logged into the controller as admin and also yes I as admin I can run ssh 10.10.128.2 (Client IP) and connect just using command line…

---

<div class="post-metadata">

**Author:** ![Anfield](https://avatars.discourse-cdn.com/v4/letter/a/dec6dc/32.png) [@Anfield](https://forum.ansible.com/u/Anfield)\
**Post date:** [August 26, 2016, 6:07pm UTC](https://forum.ansible.com/t/ssh-not-working-to-client-machine-ssh-from-command-line-works-ansible-2-1-0/22373/6 "2016-08-26T18:07:49Z")

</div>

Used a brand new ubuntu 16 desktop vm and the ping works…issue resolved
