# Cant SSH / PING to Network Devices

**URL:** <https://forum.ansible.com/t/cant-ssh-ping-to-network-devices/31861>\
**Category:** Ansible Project\
**Created:** [December 21, 2019, 2:57pm UTC](https://forum.ansible.com/t/cant-ssh-ping-to-network-devices/31861 "2019-12-21T14:57:59Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nirmal\_Gauda](https://avatars.discourse-cdn.com/v4/letter/n/bbce88/32.png) [@Nirmal\_Gauda](https://forum.ansible.com/u/Nirmal_Gauda)\
**Post date:** [December 21, 2019, 2:57pm UTC](https://forum.ansible.com/t/cant-ssh-ping-to-network-devices/31861/1 "2019-12-21T14:57:59Z")

</div>

I am a Newbie to Ansible , writing my first playbook.

I can not SSH / PING to network Devices.

`  
leaf-1 | UNREACHABLE! =\> {  
“changed”: false,  
“msg”: “Authentication failure.”,  
“unreachable”: true  
}  
leaf-2 | UNREACHABLE! =\> {  
“changed”: false,  
“msg”: “Authentication failure.”,  
“unreachable”: true  
}

i can PING / SSH to network devices from Ansible server but when i run the playbook , it fails.

No idea if i have to add something in playbook or ansible.cfg . Any Suggestion please ?

`

---

<div class="post-metadata">

**Author:** ![Jonathan\_Lozada\_De\_L](https://avatars.discourse-cdn.com/v4/letter/j/eb8c5e/32.png) [@Jonathan\_Lozada\_De\_L](https://forum.ansible.com/u/Jonathan_Lozada_De_L)\
**Post date:** [December 21, 2019, 3:02pm UTC](https://forum.ansible.com/t/cant-ssh-ping-to-network-devices/31861/2 "2019-12-21T15:02:46Z")

</div>

can you ssh without ansible into those hosts?

---

<div class="post-metadata">

**Author:** ![Nirmal\_Gauda](https://avatars.discourse-cdn.com/v4/letter/n/bbce88/32.png) [@Nirmal\_Gauda](https://forum.ansible.com/u/Nirmal_Gauda)\
**Post date:** [December 21, 2019, 3:07pm UTC](https://forum.ansible.com/t/cant-ssh-ping-to-network-devices/31861/3 "2019-12-21T15:07:49Z")

</div>

yes i can SSH from Ansible Server , via putty as well

---

<div class="post-metadata">

**Author:** ![Jonathan\_Lozada\_De\_L](https://avatars.discourse-cdn.com/v4/letter/j/eb8c5e/32.png) [@Jonathan\_Lozada\_De\_L](https://forum.ansible.com/u/Jonathan_Lozada_De_L)\
**Post date:** [December 21, 2019, 3:14pm UTC](https://forum.ansible.com/t/cant-ssh-ping-to-network-devices/31861/4 "2019-12-21T15:14:49Z")

</div>

show how you you ssh in with ansible and without ansible. Your plsybook and cfg file.

---

<div class="post-metadata">

**Author:** ![Nirmal\_Gauda](https://avatars.discourse-cdn.com/v4/letter/n/bbce88/32.png) [@Nirmal\_Gauda](https://forum.ansible.com/u/Nirmal_Gauda)\
**Post date:** [December 21, 2019, 3:29pm UTC](https://forum.ansible.com/t/cant-ssh-ping-to-network-devices/31861/5 "2019-12-21T15:29:01Z")

</div>

`  
ansible.cfg :

[defaults]  
inventory = ./inventories/

`

`  
Inventories :

[leaf]

leaf-1  
leaf-2

`

playbook :

```auto
- hosts: all
  remote_user: admin
  vars:
    authorized_key_list:
      - name: admin
        authorized_keys:
         - key: "{{ lookup('file', '~/.ssh/id_rsa.pub') }}"
           state: present
  roles:
    - { role: GROG.authorized-key }

```

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [December 21, 2019, 4:17pm UTC](https://forum.ansible.com/t/cant-ssh-ping-to-network-devices/31861/6 "2019-12-21T16:17:53Z")

</div>

First make sure ansible can actually sign in to the target hosts before trying to use roles. I’m guessing here but that role name indicates something related which might impact the connection.

So best to start here:

[https://docs.ansible.com/ansible/latest/user\_guide/intro\_getting\_started.html#connecting-to-remote-nodes](https://docs.ansible.com/ansible/latest/user_guide/intro_getting_started.html#connecting-to-remote-nodes)

And then try something simple such as the a file or copy task.  
Once that works move on to more complicated things like roles.

Dick

---

<div class="post-metadata">

**Author:** ![Nirmal\_Gauda](https://avatars.discourse-cdn.com/v4/letter/n/bbce88/32.png) [@Nirmal\_Gauda](https://forum.ansible.com/u/Nirmal_Gauda)\
**Post date:** [December 21, 2019, 4:40pm UTC](https://forum.ansible.com/t/cant-ssh-ping-to-network-devices/31861/7 "2019-12-21T16:40:25Z")

</div>

`[root@ansible01 test]# ping leaf-1 PING leaf-1.lab.com (192.168.7.1) 56(84) bytes of data. 64 bytes from testing_1F.lab.com (192.168.7.1): icmp_seq=1 ttl=253 time=0.701 ms 64 bytes from testing_1F.lab.com (192.168.7.1): icmp_seq=2 ttl=253 time=0.623 ms 64 bytes from testing_1F.lab.com (192.168.7.1): icmp_seq=3 ttl=253 time=0.736 ms`

`[root@ansible01 test]# ansible leaf-1 -m ping /usr/lib/python2.7/site-packages/requests/ __init__.py:80: RequestsDependencyWarning: urllib3 (1.22) or chardet (2.2.1) doesn't match a supported version! RequestsDependencyWarning) leaf-1 | UNREACHABLE! => { "changed": false, "msg": "Failed to connect to the host via ssh:`

---

<div class="post-metadata">

**Author:** ![Nirmal\_Gauda](https://avatars.discourse-cdn.com/v4/letter/n/bbce88/32.png) [@Nirmal\_Gauda](https://forum.ansible.com/u/Nirmal_Gauda)\
**Post date:** [December 22, 2019, 4:51am UTC](https://forum.ansible.com/t/cant-ssh-ping-to-network-devices/31861/8 "2019-12-22T04:51:19Z")

</div>

on more thing : i have logged in to ansible server as “root” but my username to log in to network device is “admin” … do i have to define that somewhere ?

---

<div class="post-metadata">

**Author:** ![racke](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/racke/32/4767_2.png) [@racke](https://forum.ansible.com/u/racke)\
**Post date:** [December 22, 2019, 7:35am UTC](https://forum.ansible.com/t/cant-ssh-ping-to-network-devices/31861/9 "2019-12-22T07:35:24Z")

</div>

> on more thing : i have logged in to ansible server as "root" but my username to log in to network device is "admin" ...  
> do i have to define that somewhere ?

Use the ansible\_user variable.

Further information:  
[https://docs.ansible.com/ansible/latest/user\_guide/intro\_inventory.html#connecting-to-hosts-behavioral-inventory-parameters](https://docs.ansible.com/ansible/latest/user_guide/intro_inventory.html#connecting-to-hosts-behavioral-inventory-parameters)

Regards  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Racke

---

<div class="post-metadata">

**Author:** ![Nirmal\_Gauda](https://avatars.discourse-cdn.com/v4/letter/n/bbce88/32.png) [@Nirmal\_Gauda](https://forum.ansible.com/u/Nirmal_Gauda)\
**Post date:** [December 30, 2019, 11:00am UTC](https://forum.ansible.com/t/cant-ssh-ping-to-network-devices/31861/10 "2019-12-30T11:00:33Z")

</div>

i added below in INVENTORY file … no luck …

**leaf-1 ansible\_ssh\_pass=XXXXX ansible\_ssh\_user=XXXX**

Thanks  
NIrmal
