Friday, 22 September 2017

Python for network Engineer:- SSH to cisco router and run multiple commands :- python2.7

import paramiko
import time
#from getpass import getpass

ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect('192.168.10.1', username='test', password='test')


ssh = ssh.invoke_shell()

ssh.send("show ip int brief\n")
time.sleep(1)
output = ssh.recv(65535)
print output
time.sleep(5)
ssh.send("sh ver\n")
time.sleep(1)
output = ssh.recv(65535)
print output


No comments:

Post a Comment