Script for basic ospf configuration
gns3 Topology
import paramiko
import time
import getpass
from pip._vendor.distlib.compat import raw_input
ssh_client = paramiko.SSHClient()
ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
username = raw_input('Enter username:')
password = getpass.getpass('Enter Password:')
router = {'hostname': '10.10.10.1', 'port': '22', 'username': username, 'password': password}
print(f'Connecting to Device...{router["hostname"]}')
ssh_client.connect(**router, look_for_keys=False, allow_agent=False)
shell = ssh_client.invoke_shell()
shell.send('enable\n')
shell.send('cisco\n')
shell.send('conf t\n')
shell.send('router ospf 10\n')
shell.send('net 0.0.0.0 0.0.0.0 area 0\n')
shell.send('end\n')
shell.send('show ip protocols\n')
time.sleep(2)
output = shell.recv(10000).decode()
print(output)
print('Closing Connection')
ssh_client.close()
Output post execution of the Script
No comments:
Post a Comment