# Ansible bastion host unreachable?

**URL:** <https://forum.ansible.com/t/ansible-bastion-host-unreachable/21834>\
**Category:** Ansible Project\
**Tags:** ubuntu\
**Created:** [June 22, 2016, 1:31pm UTC](https://forum.ansible.com/t/ansible-bastion-host-unreachable/21834 "2016-06-22T13:31:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anthony\_Cheng](https://avatars.discourse-cdn.com/v4/letter/a/c57346/32.png) [@Anthony\_Cheng](https://forum.ansible.com/u/Anthony_Cheng)\
**Post date:** [June 22, 2016, 1:31pm UTC](https://forum.ansible.com/t/ansible-bastion-host-unreachable/21834/1 "2016-06-22T13:31:26Z")

</div>

I am trying to access an EC2 instance with Ansible installed on another EC2 instance; my hosts are setup with a bastion host. I have been following this post [http://blog.scottlowe.org/2015/12/24/running-ansible-through-ssh-bastion-host/](http://blog.scottlowe.org/2015/12/24/running-ansible-through-ssh-bastion-host/) which seems fairly straight forward.

I can ssh directly and ping from this host to the IP given from dynamic inventory (an public IP); but why is a simple ansible ping failing when actual ssh works and pingable?

root@ip-host:/etc/ansible# ansible -i /etc/ansible/inventory/ec2.py tag\_managed\_ansible -m ping -vvvv  
Using /etc/ansible/ansible.cfg as config file  
Loaded callback minimal of type stdout, v2.0  
\<x.x.x.x\> ESTABLISH SSH CONNECTION FOR USER: ubuntu  
\<x.x.x.x\> SSH: EXEC ssh -C -vvv -F /root/.ssh/config -o ControlMaster=auto -o ControlPersist=10m -o ‘IdentityFile=“/home/ubuntu/.ssh/asdev.pem”’ -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ubuntu -o ConnectTimeout=10 -o ‘ControlPath=~/.ssh/ansible-%r@%h:%p’ x.x.x.x ‘/bin/sh -c ‘"’"’( umask 77 && mkdir -p “`echo $HOME/.ansible/tmp/ansible-tmp-1466601336.03-126192442556847`” && echo ansible-tmp-1466601336.03-126192442556847=“`echo $HOME/.ansible/tmp/ansible-tmp-1466601336.03-126192442556847`” ) && sleep 0’“'”‘’  
x.x.x.x | UNREACHABLE! =\> {  
“changed”: false,  
“msg”: “Failed to connect to the host via ssh.”,  
“unreachable”: true  
}

Debug from direct ssh which works (via proxy command setup in /root/.ssh/config)

root@ip-host:/etc/ansible# ssh devtest3 -v  
OpenSSH\_6.6.1, OpenSSL 1.0.1f 6 Jan 2014  
debug1: Reading configuration data /root/.ssh/config  
debug1: /root/.ssh/config line 1: Applying options for \*  
debug1: /root/.ssh/config line 769: Applying options for devtest3  
debug1: Reading configuration data /etc/ssh/ssh\_config  
debug1: /etc/ssh/ssh\_config line 1: Applying options for \*  
debug1: /etc/ssh/ssh\_config line 769: Applying options for devtest3  
debug1: Hostname has changed; re-reading configuration  
debug1: Reading configuration data /root/.ssh/config  
debug1: /root/.ssh/config line 1: Applying options for \*  
debug1: Reading configuration data /etc/ssh/ssh\_config  
debug1: /etc/ssh/ssh\_config line 1: Applying options for \*  
debug1: auto-mux: Trying existing master  
debug1: multiplexing control connection  
debug2: fd 6 setting O\_NONBLOCK  
debug3: fd 6 is O\_NONBLOCK  
debug1: channel 1: new [mux-control]  
debug3: channel\_post\_mux\_listener: new mux channel 1 fd 6  
debug3: mux\_master\_read\_cb: channel 1: hello sent  
debug2: set\_control\_persist\_exit\_time: cancel scheduled exit  
debug3: mux\_master\_read\_cb: channel 1 packet type 0x00000001 len 4  
debug2: process\_mux\_master\_hello: channel 1 slave version 4  
debug3: mux\_master\_read\_cb: channel 1 packet type 0x10000004 len 4  
debug2: process\_mux\_alive\_check: channel 1: alive check  
debug3: mux\_master\_read\_cb: channel 1 packet type 0x10000002 len 50  
debug2: process\_mux\_new\_session: channel 1: request tty 1, X 1, agent 0, subsys 0, term “xterm-256color”, cmd “”, env 0  
debug3: mm\_receive\_fd: recvmsg: Resource temporarily unavailable  
debug3: mm\_receive\_fd: recvmsg: Resource temporarily unavailable  
debug3: mm\_receive\_fd: recvmsg: Resource temporarily unavailable  
debug3: process\_mux\_new\_session: got fds stdin 7, stdout 8, stderr 9  
debug1: channel 2: new [client-session]  
debug2: process\_mux\_new\_session: channel\_new: 2 linked to control channel 1  
debug2: channel 2: send open  
debug2: callback start  
debug2: client\_session2\_setup: id 2  
debug2: channel 2: request pty-req confirm 1  
debug2: channel 2: request shell confirm 1  
debug3: mux\_session\_confirm: sending success reply  
debug2: callback done  
debug2: channel 2: open confirm rwindow 0 rmax 32768  
debug1: mux\_client\_request\_session: master session id: 2  
debug2: channel\_input\_status\_confirm: type 99 id 2  
debug2: PTY allocation request accepted on channel 2  
debug2: channel 2: rcvd adjust 2097152  
debug2: channel\_input\_status\_confirm: type 99 id 2  
debug2: shell request accepted on channel 2  
Last login: Wed Jun 22 13:20:11 2016 from  
ubuntu@ip-host:~$

Here’s ssh setting of the ansible.cfg:

[ssh\_connection]  
ssh\_args = -F /root/.ssh/config -o ControlMaster=auto -o ControlPersist=10m  
control\_path = ~/.ssh/ansible-%%r@%%h:%%p

---

<div class="post-metadata">

**Author:** ![Chris\_Shultz](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/chris_shultz/32/5176_2.png) [@Chris\_Shultz](https://forum.ansible.com/u/Chris_Shultz)\
**Post date:** [June 24, 2016, 5:53pm UTC](https://forum.ansible.com/t/ansible-bastion-host-unreachable/21834/2 "2016-06-24T17:53:47Z")

</div>

Is the host you are attempting to reach set up as the ip that ec2.py returns (x.x.x.x in your pasted output) in your ~/.ssh/config or as the devtest3 hostname you connected to in your SSH debug output?

---

<div class="post-metadata">

**Author:** ![Anthony\_Cheng](https://avatars.discourse-cdn.com/v4/letter/a/c57346/32.png) [@Anthony\_Cheng](https://forum.ansible.com/u/Anthony_Cheng)\
**Post date:** [June 24, 2016, 6:35pm UTC](https://forum.ansible.com/t/ansible-bastion-host-unreachable/21834/3 "2016-06-24T18:35:00Z")

</div>

Actually I figured it shortly after but you are spot on as the dynamic inventory reference by IP whereas in my .ssh/config it originally had host entry. Solution was to define wildcard IP in .ssh/config.
