Python 官方文档:入门教程 => 点击学习
记录利用python脚本查看思科设备的接口。#!/usr/bin/env Python import paramiko import sys import time class CiscoSwitch(): de
记录利用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")
--结束END--
本文标题: Python脚本查看思科设备的接口
本文链接: https://lsjlt.com/news/186927.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0