Skip to content

Commit

Permalink
Create netmiko.py
Browse files Browse the repository at this point in the history
  • Loading branch information
mksbcisco authored Oct 26, 2021
1 parent 2faa019 commit a62fe6b
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions mt-automate/netmiko.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#connect to our router via SSH using module Netmiko

from netmiko import ConnectHandler

router_mikrotik = {
'device_type': 'mikrotik_routeros',
'host': '103.54.222.93',
'username': 'api',
'password': 'password',
'use_keys' : True,
'key_file' : '/Users/mankomalsingh/.ssh/id_rsa',
'port' : 22 # optional, defaults to 22
#'secret': 'secret', # optional, defaults to ''
}

net_connect = ConnectHandler(**router_mikrotik)
commands =['/interface print',
'/ip address print']

for commands in commands:
output = net_connect.send_command(commands, cmd_verify=True)
print(output)
print(type(output))

0 comments on commit a62fe6b

Please sign in to comment.