-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnetmiko_connect_and_run.py
More file actions
25 lines (21 loc) · 938 Bytes
/
netmiko_connect_and_run.py
File metadata and controls
25 lines (21 loc) · 938 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# from netmiko import Netmiko
# connection = Netmiko(host='10.1.1.10', port='22', username='u1', password='cisco', device_type='cisco_ios')
from netmiko import ConnectHandler
# creating a dictionary for the device to connect to
cisco_device = {
'device_type': 'cisco_ios', #device type from https://github.com/ktbyers/netmiko/blob/master/netmiko/ssh_dispatcher.py
'host': '10.1.1.1',
'username': 'admin',
'password': 'admin',
'port': 22, # optional, default 22
'secret': 'cisco', # this is the enable password
'verbose': True # optional, default False
}
# connecting to the device and returning an ssh connection object
connection = ConnectHandler(**cisco_device)
# sending a command and getting the output
output = connection.send_command('sh ip int brief')
print(output)
# closing the connection
print('Closing connection')
connection.disconnect()