print("\nNo CDP Neighbor on Switch ", hostname, ", Port:", port, "\n We needet ", hopcount, " Hops") print("-" * 60) interface_cfg = ssh.send_command( "show running-config interface " + port) print("Configuration for Port " + port) print(interface_cfg) print("-" * 60) quit() New_Device = { "device_type": device_type, "host": neighbor_ip, 'username': username, "password": password, } device = New_Device except Exception as e: print(Fore.RED) print(e) print(Fore.RESET) quit() ssh.cleanup() print("Disconnected from Device") print("Try to Connect to " + device["host"] + "\n") except Exception as e: print(Fore.RED) print(e) print(Fore.RESET)
''' Author: Chris Segalas Simple Netmiko script to retrieve list of remote VPN users on an ASA ''' # module imports from netmiko import Netmiko from getpass import getpass username = input('Username: '******'Password: '******'IP address: ') # device dictionary - user input for IP address, username, pw and network device type. device = { 'host': ip, 'username': username, 'password': password, 'device_type': 'cisco_asa', } net_conn = Netmiko(**device) print('Connected to:', ip) users = net_conn.send_command( 'show vpn- anyconnect | i User|Assign|Dur|Group' ) # Show Users, IP addresses, login duration and tunnel+policy groups print(users) net_conn.cleanup() net_conn.disconnect() print('Closed connection to ASA.')