# Can't connect to remote host

**URL:** <https://forum.ansible.com/t/cant-connect-to-remote-host/24869>\
**Category:** Ansible Project\
**Created:** [July 1, 2017, 11:57am UTC](https://forum.ansible.com/t/cant-connect-to-remote-host/24869 "2017-07-01T11:57:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rusty\_Roy](https://avatars.discourse-cdn.com/v4/letter/r/4491bb/32.png) [@Rusty\_Roy](https://forum.ansible.com/u/Rusty_Roy)\
**Post date:** [July 1, 2017, 11:57am UTC](https://forum.ansible.com/t/cant-connect-to-remote-host/24869/1 "2017-07-01T11:57:22Z")

</div>

I can connect to the remote host via ssh, but ansible fails to connect. I’m loading the key using ssh.

If I run:

`  
ansible vm-to-deploy-to -m ping -e “ansible\_ssh\_port=15674” -e “ansible\_ssh\_user=djeyewater”

`

Result is:

`

192.168.127.28 | UNREACHABLE! =\> {  
“changed”: false,  
“msg”: “Authentication or permission failure. In some cases, you may have been able to authenticate and did not have permissions on the remote directory. Consider changing the remote temp path in ansible.cfg to a path rooted in "/tmp". Failed command was: ( umask 77 && mkdir -p "`echo /tmp/provision/ansible-tmp-1498908230.64-195102459534727`" && echo ansible-tmp-1498908230.64-195102459534727="`echo /tmp/provision/ansible-tmp-1498908230.64-195102459534727`" ), exited with result 1”,  
“unreachable”: true  
}

`

But if I connect manually:

`  
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=/home/vagrant/.ansible/cp/ansible-ssh-%h-%p-%r [djeyewater@192.168.127.28](mailto:djeyewater@192.168.127.28) -p 15674

`

and run that failed command, all is OK:

`

$ umask 77 && mkdir -p "`echo /tmp/provision/ansible-tmp-1498908230.64-195102459534727`" && echo ansible-tmp-1498908230.64-195102459534727="`echo /tmp/provision/ansible-tmp-1498908230.64-195102459534727`"  
ansible-tmp-1498908230.64-195102459534727=“/tmp/provision/ansible-tmp-1498908230.64-195102459534727”  
$ echo $?  
0

`

So not sure what’s going wrong when I try to connect using ansible?

---

<div class="post-metadata">

**Author:** ![Rusty\_Roy](https://avatars.discourse-cdn.com/v4/letter/r/4491bb/32.png) [@Rusty\_Roy](https://forum.ansible.com/u/Rusty_Roy)\
**Post date:** [July 2, 2017, 3:47pm UTC](https://forum.ansible.com/t/cant-connect-to-remote-host/24869/2 "2017-07-02T15:47:34Z")

</div>

Don’t know what the problem was, but restarting both local and remote machines seems to have fixed it.
