发布时间:2019-08-29 07:34:28编辑:auto阅读(2274)
记录利用Python脚本查看思科设备的接口。
#!/usr/bin/env python
import paramiko
import sys
import time
class CiscoSwitch():
def __init__(self,host,username,password):
self.username = username
self.host = host
self.password = password
def Login(self):
self.child = paramiko.SSHClient()
self.child.set_missing_host_key_policy(paramiko.AutoAddPolicy())
self.child.connect(self.host,username=self.username,password=self.password)
self.remote = self.child.invoke_shell()
def showcmd(self,cmd):
print "[+] Connect to Router..."
self.remote.send("\n")
self.remote.send(cmd)
time.sleep(0.5)
output = self.remote.recv(5000)
print output
if __name__ == '__main__':
print "[+] This Program is beging done..."
for ip in open("/opt/other/ip.txt"):
Switch = CiscoSwitch(ip,'admin','Password.123')
Switch.Login()
Switch.showcmd("show ip int brief\n") 
上一篇: fatal error: Python.
下一篇: Python机器学习实战教程
51318
50770
41364
38169
32652
29542
28387
23259
23230
21555
1629°
2364°
1968°
1911°
2240°
1947°
2641°
4426°
4267°
3038°