# Authentication issue between Router and ansible "ad-hoc"

**URL:** <https://forum.ansible.com/t/authentication-issue-between-router-and-ansible-ad-hoc/3080>\
**Category:** Get Help\
**Tags:** ansible, network\
**Created:** [December 27, 2023, 8:59pm UTC](https://forum.ansible.com/t/authentication-issue-between-router-and-ansible-ad-hoc/3080 "2023-12-27T20:59:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mo.mostafa](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/mo.mostafa/32/1872_2.png) [@mo.mostafa](https://forum.ansible.com/u/mo.mostafa)\
**Post date:** [December 27, 2023, 8:59pm UTC](https://forum.ansible.com/t/authentication-issue-between-router-and-ansible-ad-hoc/3080/1 "2023-12-27T20:59:50Z")

</div>

hello dears ,

## 1-i have issue when i need to use ios\_ping , i got this message

## [mohamed@localhost proj]$ ansible -m ios\_ping 192.168.1.101 -a “dest=192.168.1.101” [WARNING]: ansible-pylibssh not installed, falling back to paramiko 192.168.1.101 | FAILED! =\> { “changed”: false, “msg”: “Failed to authenticate: Authentication failed: transport shut down or saw EOF”

## 2-i can ping this ip and ssh from ansible linux

## 3-this is my config file [defaults] inventory = cisco ask\_pass = false gathering = explicit interpreter\_python = /usr/bin/python [persistent\_connection] command\_timeout = 200 connect\_timeout = 200 connect\_retry\_timeout = 100 this is the inventory group\_varr file

4-device configuration

hostname R1  
vrf definition MGMT  
address-family ipv4  
exit  
no ip domain lookup  
ip domain name [cisco.com](http://cisco.com)  
ip ssh version 2  
crypto key generate rsa modulus 1024  
username root password admin  
interface Ethernet0/0  
vrf forwarding MGMT  
ip address 192.168.1.101 255.255.255.0  
no shutdown  
exit

## line vty 0 4 login local transport input all transport output all exit

5-inventory  
[all]  
192.168.1.101=R1  
192.168.1.102=R2  
192.168.1.103=R3

[usa]  
192.168.1.101=R1  
192.168.1.102=R2

## [uk] 192.168.1.103=R3

6-groub\_var “usa.yaml”

ansible\_connection: ansible.netcommon.network\_cli  
ansible\_network\_os: cisco.ios.ios  
ansible\_user: root  
ansible\_password: admin

---

<div class="post-metadata">

**Author:** ![akira6592](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/akira6592/32/222_2.png) [@akira6592](https://forum.ansible.com/u/akira6592)\
**Post date:** [December 28, 2023, 12:38pm UTC](https://forum.ansible.com/t/authentication-issue-between-router-and-ansible-ad-hoc/3080/2 "2023-12-28T12:38:43Z")

</div>

Hello @mo.mostafa

Does `~/.ssh/id_rsa` exist?  
If it exists, could you try adding the following settings to ansible.cfg?

```ini
[paramiko_connection]
look_for_keys = False

```

I also have experienced authentication errors even though the password is correct. The following blog is about my experiences. (Japanese)  
[https://tekunabe.hatenablog.jp/entry/2022/11/01/162600](https://tekunabe.hatenablog.jp/entry/2022/11/01/162600)

---

<div class="post-metadata">

**Author:** ![akira6592](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/akira6592/32/222_2.png) [@akira6592](https://forum.ansible.com/u/akira6592)\
**Post date:** [December 28, 2023, 12:47pm UTC](https://forum.ansible.com/t/authentication-issue-between-router-and-ansible-ad-hoc/3080/3 "2023-12-28T12:47:34Z")

</div>

One other thing I noticed is that the format of the inventory file does not appear to be correct.

To make it correct, first amend the inventory file as follows.

```ini
[all]
192.168.1.101
192.168.1.102
192.168.1.103

[usa]
192.168.1.101
192.168.1.102

[uk]
192.168.1.103

```

Then run `ansible-inventory -i <inventory-file-name> --list` and check that the correct `ansible_user` and `ansible_password` are assigned to host `192.168.1.101`.

---

<div class="post-metadata">

**Author:** ![mo.mostafa](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/mo.mostafa/32/1872_2.png) [@mo.mostafa](https://forum.ansible.com/u/mo.mostafa)\
**Post date:** [December 29, 2023, 10:01am UTC](https://forum.ansible.com/t/authentication-issue-between-router-and-ansible-ad-hoc/3080/4 "2023-12-29T10:01:52Z")

</div>

Thanks, i will try this solution and feedback

---

<div class="post-metadata">

**Author:** ![sushil-bhattacharjee](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sushil-bhattacharjee/32/2976_2.png) [@sushil-bhattacharjee](https://forum.ansible.com/u/sushil-bhattacharjee)\
**Post date:** [April 23, 2024, 4:23pm UTC](https://forum.ansible.com/t/authentication-issue-between-router-and-ansible-ad-hoc/3080/5 "2024-04-23T16:23:49Z")

</div>

I had the same issue, and your post just solved my problem. I have spent more than 20 hours trying to resolve this problem, but I couldn’t. And I just saw your post and solved my problem. If you are around Sydney, I would buy a coffee. Now, I am very thankful and grateful to you.
