Authentication issue between Router and ansible "ad-hoc"

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
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

Hello @mo.mostafa

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

[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

3 Likes

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.

[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.

2 Likes

Thanks, i will try this solution and feedback

1 Like

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.

1 Like