# Getting authentication issue while connection to Cisco Switch

**URL:** <https://forum.ansible.com/t/getting-authentication-issue-while-connection-to-cisco-switch/39335>\
**Category:** Get Help\
**Tags:** cisco, ansible\
**Created:** [December 26, 2024, 1:32pm UTC](https://forum.ansible.com/t/getting-authentication-issue-while-connection-to-cisco-switch/39335 "2024-12-26T13:32:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![GowthamLok](https://avatars.discourse-cdn.com/v4/letter/g/eb8c5e/32.png) [@GowthamLok](https://forum.ansible.com/u/GowthamLok)\
**Post date:** [December 26, 2024, 1:32pm UTC](https://forum.ansible.com/t/getting-authentication-issue-while-connection-to-cisco-switch/39335/1 "2024-12-26T13:32:08Z")

</div>

I am trying to connect to a cisco switch using ansible creds(username and password that are being fetched from PAM) while trying to execute a command sh version, I’m getting authentication issue. Both user name and password are correct.

Below is the code and error:

* * *

- name: Playbook to check Nodedown details on Cisco\_devices  
tasks:

- name: Fetching credentials from PAM  
hosts: all  
gather\_facts: false  
tasks:

- name: Connecting to Network Device  
hosts: network\_devices  
gather\_facts: false  
ignore\_unreachable: true  
connection: network\_cli  
vars:  
ansible\_network\_os: ios  
ansible\_user: "{{ device\_username }} "  
ansible\_password: “{{ device\_password }}”  
ansible\_command\_timeout: 240  
ansible\_python\_interpreter: “/usr/libexec/platform-python”  
ansible\_become: yes  
ansible\_become\_method: enable  
tasks:

Error:

fatal: [[xx-xxxx-xx-xx-a01.domain.net](http://xx-xxxx-xx-xx-a01.domain.net)]: FAILED! =\> {  
“changed”: false,  
“invocation”: {  
“module\_args”: {  
“auth\_pass”: null,  
“authorize”: null,  
“commands”: [  
“show version”  
],  
“host”: null,  
“interval”: 1,  
“match”: “all”,  
“password”: null,  
“port”: null,  
“provider”: null,  
“retries”: 10,  
“ssh\_keyfile”: null,  
“timeout”: null,  
“username”: null,  
“wait\_for”: null  
}  
},  
“msg”: “Failed to authenticate: Authentication failed.”

---

<div class="post-metadata">

**Author:** ![motorbass](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@motorbass](https://forum.ansible.com/u/motorbass)\
**Post date:** [January 2, 2025, 3:10pm UTC](https://forum.ansible.com/t/getting-authentication-issue-while-connection-to-cisco-switch/39335/2 "2025-01-02T15:10:43Z")

</div>

For testing purpose do you got the same error while setting this statement

```auto
vars:
ansible_user: "{{ device_username }} "
ansible_password: “{{ device_password }}”
ansible_command_timeout: 240
ansible_become: yes
ansible_become_method: enable

```

within your task` name: Execute Command On Network Device` ?
