# SSH Error: data could not be sent to the remote host. Make sure this host can be reached over ssh

**URL:** <https://forum.ansible.com/t/ssh-error-data-could-not-be-sent-to-the-remote-host-make-sure-this-host-can-be-reached-over-ssh/19906>\
**Category:** Ansible Project\
**Created:** [November 30, 2015, 11:10pm UTC](https://forum.ansible.com/t/ssh-error-data-could-not-be-sent-to-the-remote-host-make-sure-this-host-can-be-reached-over-ssh/19906 "2015-11-30T23:10:25Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![theyuseus](https://avatars.discourse-cdn.com/v4/letter/t/ecd19e/32.png) [@theyuseus](https://forum.ansible.com/u/theyuseus)\
**Post date:** [November 30, 2015, 11:10pm UTC](https://forum.ansible.com/t/ssh-error-data-could-not-be-sent-to-the-remote-host-make-sure-this-host-can-be-reached-over-ssh/19906/1 "2015-11-30T23:10:25Z")

</div>

I’m trying to use private keys. I’ve got it all setup and it works when I use this command.

ssh -C [james@172.30.129.174](mailto:james@172.30.129.174) some command

It works when I use the command as formatted by Ansible too.

ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath=“/Users/james/.ansible/cp/ansible-ssh-%h-%p-%r” -o IdentityFile=“/Users/james/.ssh/id\_rsa” -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=james -o ConnectTimeout=10 172.30.129.174 some command

When I use Ansible it doesn’t work.

ansible -vvvv 172.30.129.174 -m raw -a "show switch”

\<172.30.129.174\> ESTABLISH CONNECTION FOR USER: james  
\<172.30.129.174\> EXEC ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath=“/Users/james  
/.ansible/cp/ansible-ssh-%h-%p-%r” -o IdentityFile=“/Users/james/.ssh/id\_rsa” -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=james -o ConnectTimeout=10 172.30.129.174 show switch  
sw\_b2-1 | FAILED =\> SSH Error: data could not be sent to the remote host. Make sure this host can be reached over ssh

Does anyone have any ideas why I can’t get private keys to work?

James

---

<div class="post-metadata">

**Author:** ![theyuseus](https://avatars.discourse-cdn.com/v4/letter/t/ecd19e/32.png) [@theyuseus](https://forum.ansible.com/u/theyuseus)\
**Post date:** [November 30, 2015, 11:17pm UTC](https://forum.ansible.com/t/ssh-error-data-could-not-be-sent-to-the-remote-host-make-sure-this-host-can-be-reached-over-ssh/19906/2 "2015-11-30T23:17:05Z")

</div>

One more comment, if I add --ask-pass to the Ansible command it works. I just can’t get the private keys to work.

---

<div class="post-metadata">

**Author:** ![theyuseus](https://avatars.discourse-cdn.com/v4/letter/t/ecd19e/32.png) [@theyuseus](https://forum.ansible.com/u/theyuseus)\
**Post date:** [December 1, 2015, 5:30pm UTC](https://forum.ansible.com/t/ssh-error-data-could-not-be-sent-to-the-remote-host-make-sure-this-host-can-be-reached-over-ssh/19906/3 "2015-12-01T17:30:17Z")

</div>

Am I missing a flag or setting? I’ve got “ansible\_ssh\_private\_key\_file” set to the full path to my id\_rsa file. Is that all it takes to get Ansible to use private keys?

---

<div class="post-metadata">

**Author:** ![theyuseus](https://avatars.discourse-cdn.com/v4/letter/t/ecd19e/32.png) [@theyuseus](https://forum.ansible.com/u/theyuseus)\
**Post date:** [December 1, 2015, 5:43pm UTC](https://forum.ansible.com/t/ssh-error-data-could-not-be-sent-to-the-remote-host-make-sure-this-host-can-be-reached-over-ssh/19906/4 "2015-12-01T17:43:54Z")

</div>

Well, I just tried anything and everything I could and it looks like adding “-c paramiko” fixed it.

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [December 1, 2015, 5:46pm UTC](https://forum.ansible.com/t/ssh-error-data-could-not-be-sent-to-the-remote-host-make-sure-this-host-can-be-reached-over-ssh/19906/5 "2015-12-01T17:46:15Z")

</div>

this is probably a control persist issue, try disabling those options  
(empty ssh\_args in ansible.cfg) and see if that also fixes the  
problem.

if so, you can switch to paramiko (its faster than ssh w/o control  
persist) or play with the timeout settings (default 60s). In some  
cases it has to do with older Openssh versions not behaving well or  
using different ssh server software.

---

<div class="post-metadata">

**Author:** ![theyuseus](https://avatars.discourse-cdn.com/v4/letter/t/ecd19e/32.png) [@theyuseus](https://forum.ansible.com/u/theyuseus)\
**Post date:** [December 1, 2015, 6:23pm UTC](https://forum.ansible.com/t/ssh-error-data-could-not-be-sent-to-the-remote-host-make-sure-this-host-can-be-reached-over-ssh/19906/6 "2015-12-01T18:23:49Z")

</div>

The version on my master computer is: OpenSSL 0.9.8zc 15 Oct 2014. I can’t seem to find the version on the the clients, which are switches.

What I don’t get is why --ask-pass works with OpenSSH but private keys don’t.

I added this to my ansible.cfg and it made no difference but I’m not sure if this is what you meant by “empty ssh\_args”.

[ssh\_connection]  
ssh\_args =

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [December 1, 2015, 7:23pm UTC](https://forum.ansible.com/t/ssh-error-data-could-not-be-sent-to-the-remote-host-make-sure-this-host-can-be-reached-over-ssh/19906/7 "2015-12-01T19:23:23Z")

</div>

i'm going with 'custom ssh server' that is probably the issue with  
most switches.
