# ansible-playbook command, remote host unreachable, but ssh is fine

**URL:** <https://forum.ansible.com/t/ansible-playbook-command-remote-host-unreachable-but-ssh-is-fine/22363>\
**Category:** Ansible Project\
**Tags:** ubuntu, aws\
**Created:** [August 23, 2016, 11:01pm UTC](https://forum.ansible.com/t/ansible-playbook-command-remote-host-unreachable-but-ssh-is-fine/22363 "2016-08-23T23:01:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jguillette](https://avatars.discourse-cdn.com/v4/letter/j/bb73d2/32.png) [@jguillette](https://forum.ansible.com/u/jguillette)\
**Post date:** [August 23, 2016, 11:01pm UTC](https://forum.ansible.com/t/ansible-playbook-command-remote-host-unreachable-but-ssh-is-fine/22363/1 "2016-08-23T23:01:23Z")

</div>

Hi there,

I’m new to Ansible, and jumping into it for a project at work. Right now I’m trying to update our AWS instance machine using ansible-playbook. More specifically, I’m running  
`ansible-playbook --private-key ~/keys/OasSDev.pem --sudo linux-toolbox.yml -vvv`

What I’m getting is that this (with IP edited out):

`  
ansible-playbook --private-key ~/path/to/key.pem linux-toolbox.yml -vvv

No config file found; using defaults  
[DEPRECATION WARNING]: Instead of sudo/sudo\_user, use become/become\_user and make sure  
become\_method is ‘sudo’ (default).  
This feature will be removed in a future release.  
Deprecation warnings can be disabled by setting deprecation\_warnings=False in ansible.cfg.  
Loaded callback default of type stdout, v2.0

PLAYBOOK: linux-toolbox.yml \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
1 plays in linux-toolbox.yml

PLAY [linux-toolbox] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

TASK [setup] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
[ubuntu@my.ip.goes.here](mailto:ubuntu@my.ip.goes.here) ESTABLISH SSH CONNECTION FOR USER: ubuntu  
[ubuntu@my.ip.goes.here](mailto:ubuntu@my.ip.goes.here) SSH: EXEC ssh -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o ‘IdentityFile=“/Users/jguillette/keys/OasSDev.pem”’ -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ubuntu -o ConnectTimeout=10 -o ControlPath=/Users/jguillette/.ansible/cp/ansible-ssh-%h-%p-%r ubuntu@my.ip.goes.here ‘/bin/sh -c ‘"’"’( umask 77 && mkdir -p “`echo $HOME/.ansible/tmp/ansible-tmp-1471991079.97-57666739369328`” && echo ansible-tmp-1471991079.97-57666739369328=“`echo $HOME/.ansible/tmp/ansible-tmp-1471991079.97-57666739369328`” ) && sleep 0’“'”‘’  
[ubuntu@my.ip.goes.here](mailto:ubuntu@my.ip.goes.here) PUT /var/folders/k8/g7tw63ps1xx8dl39rs6p6nfh91wzbh/T/tmpgow\_gt TO /home/ubuntu/.ansible/tmp/ansible-tmp-1471991079.97-57666739369328/setup  
[ubuntu@my.ip.goes.here](mailto:ubuntu@my.ip.goes.here) SSH: EXEC sftp -b - -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o ‘IdentityFile=“/Users/jguillette/keys/OasSDev.pem”’ -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ubuntu -o ConnectTimeout=10 -o ControlPath=/Users/jguillette/.ansible/cp/ansible-ssh-%h-%p-%r ‘[ubuntu@my.ip.goes.here]’  
fatal: [ubuntu@my.ip.goes.here]: UNREACHABLE! =\> {“changed”: false, “msg”: “SSH Error: data could not be sent to the remote host. Make sure this host can be reached over ssh”, “unreachable”: true}  
[WARNING]: Could not create retry file ‘linux-toolbox.retry’. [Errno 2] No such file  
or directory: ‘’

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ubuntu@my.ip.goes.here : ok=0 changed=0 unreachable=1 failed=0  
`

I’m able to ssh into the remote machine, and I’m able to connect with sftp via this command:  
`

sftp -vvv -o ControlMaster=auto -o ControlPersist=60s -o ‘IdentityFile=“/Users/jguillette/keys/OasSDev.pem”’ -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ubuntu -o ConnectTimeout=10 -o ControlPath=/Users/jguillette/.ansible/cp/ansible-ssh-%h-%p-%r ‘ubuntu@my.ip.goes.here’  
`

Original for comparison, removed the flags -b - -C and the brackets around the user@ip:

`sftp -b - -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o 'IdentityFile="/Users/jguillette/keys/OasSDev.pem"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ubuntu -o ConnectTimeout=10 -o ControlPath=/Users/jguillette/.ansible/cp/ansible-ssh-%h-%p-%r '[ubuntu@my.ip.goes.here]'`

I’m not sure if I need to make some edits to my local Ansible configuration, or if there are some issues on the remote. I found an [issue on GitHub](https://github.com/ansible/ansible/issues/16066) that sounds like what I’m seeing, but I haven’t been able to turn that into a working solution. I did look at /etc/ssh/sshd\_config and didn’t find anything related to sftp. That seems like a problem, but I also haven’t done sftp setup before, so I don’t know for sure.

Any help or insight would be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![jguillette](https://avatars.discourse-cdn.com/v4/letter/j/bb73d2/32.png) [@jguillette](https://forum.ansible.com/u/jguillette)\
**Post date:** [August 24, 2016, 2:11pm UTC](https://forum.ansible.com/t/ansible-playbook-command-remote-host-unreachable-but-ssh-is-fine/22363/2 "2016-08-24T14:11:23Z")

</div>

With fresh eyes on the problem today, the last response in the GitHub issue clicked for me. I was defining “user@ip” in my ansible hosts file, instead of declaring the user with the `--user=` flag in the playbook command. Solved my own problem, hopefully this helps someone else.
