cant login to cisco IOS switch
Warsenius opened this issue · 2 comments
Warsenius commented
Hello all.
I am trying to get some experience with ansible\napalm but im having a issue getting the example playbooks working.
I found this playbook:
- name: Test Inventory #The Task Name
hosts: switch #This will be in your ansible inventory file
connection: local #Required
gather_facts: no #Do not gather facts
tasks: #Begin Tasks
- name: get facts from device
napalm_get_facts: #Call the napalm module, in this case napal_get_facts
hostname: "{{ inventory_hostname }}" #This is a parameter and is derived from your ansible inventory file
dev_os: 'ios' #The hardware operating system
username: 'my_username'
password: 'my_secret' #The line level password
filter: 'facts'
register: result #Ansible function for collecting output
- name: print results #Task Name
debug: msg="{{ result }}" #Display the collected output
But when i run it i get:
TASK [get facts from device] *********************
fatal: [10.0.0.11]: FAILED! => {"changed": false, "msg": "cannot connect to device: Authentication failure: unable to connect cisco_ios 10.0.0.11:22\nAuthentication failed."}
When I use netmiko in a python script i get the output of the given command:
from netmiko import ConnectHandler
from getpass import getpass
ip_addr = raw_input("Enter IP Address: ")
device = { 'device_type': 'cisco_ios', 'ip': ip_addr, 'username': 'my_username', 'password': getpass(), }
net_connect = ConnectHandler(**device)
output = net_connect.send_command("show ip int brief")
print(output)
The switch is setup with TACACS, the username of the ssh session is normally used. The terminal will only ask for a password and you will end in enable mode by default.
ktbyers commented
I don't see immediately anything wrong. That error in general would be a username/password failure.
I assume the IP address is reachable from the Ansible machine?
Warsenius commented
yes both the netmiko\python script work and ssh command from the cli works fine.