# New to ansible, trying to get ping to work but getting Paramiko/SSH errors

**URL:** <https://forum.ansible.com/t/new-to-ansible-trying-to-get-ping-to-work-but-getting-paramiko-ssh-errors/20118>\
**Category:** Ansible Project\
**Created:** [January 4, 2016, 3:56pm UTC](https://forum.ansible.com/t/new-to-ansible-trying-to-get-ping-to-work-but-getting-paramiko-ssh-errors/20118 "2016-01-04T15:56:02Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ravi\_B](https://avatars.discourse-cdn.com/v4/letter/r/278dde/32.png) [@Ravi\_B](https://forum.ansible.com/u/Ravi_B)\
**Post date:** [January 4, 2016, 3:56pm UTC](https://forum.ansible.com/t/new-to-ansible-trying-to-get-ping-to-work-but-getting-paramiko-ssh-errors/20118/1 "2016-01-04T15:56:02Z")

</div>

Hi everyone,  
I’m new to ansible and trying to get the basing ping working on local host (127.0.0.1 in the $ANSIBLE\_HOSTS file) but keep running into problems.I thought the problem was python3 that was installed on the machine, but I uninstalled python3 (deleted the python3 binaries and reinstalled ansible from source). I’m still getting the same error with ansible (see the error below in red).  
The command “ansible all -m ping” is not working.

# python -V

Python 2.7.11

# pip install --upgrade paramiko

Requirement already up-to-date: paramiko in /usr/local/lib/python2.7/site-packages/paramiko-1.16.0-py2.7.egg  
Requirement already up-to-date: pycrypto!=2.4,\>=2.1 in /usr/local/lib/python2.7/site-packages/pycrypto-2.6.1-py2.7-linux-x86\_64.egg (from paramiko)  
Requirement already up-to-date: ecdsa\>=0.11 in /usr/local/lib/python2.7/site-packages/ecdsa-0.13-py2.7.egg (from paramiko)

# cat $ANSIBLE\_HOSTS

127.0.0.1

# ansible --version

ansible 1.9.4  
configured module search path = None

**# ansible all -m ping**  
**No handlers could be found for logger “paramiko.transport”**  
**127.0.0.1 | FAILED =\> FAILED: Error reading SSH protocol banner[Errno 104] Connection reset by peer**

**I’m getting the same error with ansible 2 also**

# ansible --version

ansible 2.1.0  
config file =  
configured module search path = Default w/o overrides

# ansible all -m ping

No handlers could be found for logger “paramiko.transport”  
127.0.0.1 | UNREACHABLE! =\> {  
“changed”: false,  
“msg”: “ERROR! Error reading SSH protocol banner[Errno 104] Connection reset by peer”,  
“unreachable”: true  
}

---

<div class="post-metadata">

**Author:** ![Chun-Hung\_Huang](https://avatars.discourse-cdn.com/v4/letter/c/c89c15/32.png) [@Chun-Hung\_Huang](https://forum.ansible.com/u/Chun-Hung_Huang)\
**Post date:** [January 5, 2016, 12:12am UTC](https://forum.ansible.com/t/new-to-ansible-trying-to-get-ping-to-work-but-getting-paramiko-ssh-errors/20118/2 "2016-01-05T00:12:24Z")

</div>

Any firewall rule with your local machine?  
— in linux try to check your firewall  
$ sudo iptables -L

Check /etc/hosts.allow and /etc/hosts.deny

Does port 22 open in your local machine?  
$ netstat -tupln

^^

Ravi B於 2016年1月5日星期二 UTC+8上午12時27分04秒寫道：

---

<div class="post-metadata">

**Author:** ![Ravi\_B](https://avatars.discourse-cdn.com/v4/letter/r/278dde/32.png) [@Ravi\_B](https://forum.ansible.com/u/Ravi_B)\
**Post date:** [January 5, 2016, 2:28am UTC](https://forum.ansible.com/t/new-to-ansible-trying-to-get-ping-to-work-but-getting-paramiko-ssh-errors/20118/3 "2016-01-05T02:28:30Z")

</div>

There are no firewall rules that I can see. All installations of ansible was done by ssh-ing to that host, so ssh port is definitely open.

**# sudo iptables -L**  
Chain INPUT (policy ACCEPT)  
target prot opt source destination

Chain FORWARD (policy ACCEPT)  
target prot opt source destination

Chain OUTPUT (policy ACCEPT)  
target prot opt source destination

**# netstat -tupln | grep ":22 "**  
tcp 0 0 0.0.0.0:22 0.0.0.0:\* LISTEN 8969/sshd  
tcp 0 0 :::22 :::\* LISTEN 8969/sshd

---

<div class="post-metadata">

**Author:** ![Toshio\_Kuratomi](https://avatars.discourse-cdn.com/v4/letter/t/41988e/32.png) [@Toshio\_Kuratomi](https://forum.ansible.com/u/Toshio_Kuratomi)\
**Post date:** [January 5, 2016, 2:47pm UTC](https://forum.ansible.com/t/new-to-ansible-trying-to-get-ping-to-work-but-getting-paramiko-ssh-errors/20118/4 "2016-01-05T14:47:07Z")

</div>

Ssh 127.0.0.1 works?  
Does ansible all -m ping -c ssh work ?

-Toshio

---

<div class="post-metadata">

**Author:** ![Ravi\_B](https://avatars.discourse-cdn.com/v4/letter/r/278dde/32.png) [@Ravi\_B](https://forum.ansible.com/u/Ravi_B)\
**Post date:** [January 5, 2016, 5:20pm UTC](https://forum.ansible.com/t/new-to-ansible-trying-to-get-ping-to-work-but-getting-paramiko-ssh-errors/20118/5 "2016-01-05T17:20:55Z")

</div>

Hi Toshio,  
You’re right!! I was not able to ssh to 127.0.0.1.

$ ssh 127.0.0.1  
ssh\_exchange\_identification: Connection closed by remote host

Then I replaced 127.0.0.1 with the fully qualified hostname. After that it worked ( I had to give the --ask-pass option to the command)

$ ansible all -m ping --ask-pass  
SSH password:  
\<host.ip.address.here\> | SUCCESS =\> {  
“changed”: false,  
“ping”: “pong”  
}

Thank you Toshio and Chun-Hung for all your help! I can’t thank you enough as it solved my headache.

---

<div class="post-metadata">

**Author:** ![Mini](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@Mini](https://forum.ansible.com/u/Mini)\
**Post date:** [April 25, 2017, 8:11pm UTC](https://forum.ansible.com/t/new-to-ansible-trying-to-get-ping-to-work-but-getting-paramiko-ssh-errors/20118/6 "2017-04-25T20:11:21Z")

</div>

Hi Ravi,

Could you please tell how you made it work. what does this mean " fully qualified hostname" ?  
I am able to ssh using username@ip address but unable to ping it.

I am using CentOS 7 and the host machine is a Cisco IOS router.

Thanks!!

---

<div class="post-metadata">

**Author:** ![Dick\_Davies](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@Dick\_Davies](https://forum.ansible.com/u/Dick_Davies)\
**Post date:** [April 26, 2017, 7:39pm UTC](https://forum.ansible.com/t/new-to-ansible-trying-to-get-ping-to-work-but-getting-paramiko-ssh-errors/20118/7 "2017-04-26T19:39:21Z")

</div>

An 'Ansible ping' checks that Python is on the remote host - cisco iOS  
probably doesn't  
have that, so you'd manage it with ansible modules running on your ansible host.
