第一句子网 - 唯美句子、句子迷、好句子大全
第一句子网 > python登录交换机执行命令_利用Python脚本登录交换机实现自动配置备份的方法

python登录交换机执行命令_利用Python脚本登录交换机实现自动配置备份的方法

时间:2019-12-19 05:39:13

相关推荐

python登录交换机执行命令_利用Python脚本登录交换机实现自动配置备份的方法

主机参考:服务器测评参考推荐网,专注分享服务器优惠信息!如果您想在本站投放您的广告,点此直达!如果您不想付费,您也可以免费投稿您的产品信息,点此直达!联系我们

部分文章发布时间较久远,可能存在未知因素,购买时建议在本博客搜索商家名称,可查看相关文章充分了解商家!若非中文页面可使用谷歌浏览器同步翻译!跑路不诚信商家列表

利用Python脚本登录交换机实现自动配置备份的方法有哪些?下面跟着小编一起来看看吧。

一、Python脚本

ssh = paramiko.SSHClient()ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())ssh.connect(“10.x.x.x”, 22,”用户名”,”密码”,allow_agent=False,look_for_keys=False)

command = ‘sh running-config r ‘

stdin, stdout, stderr = ssh.exec_command(command)#stdin, stdout, stderr = ssh.invoke_shell(command)a=[]result = stdout.readlines()

if not result:result = stderr.read()

backup=open(“/root/worke/beifen/beifen.txt”,”w”)

for line in result:print(line)backup.write(line)

backup.close()ssh.close()

看完上文,你对利用Python脚本登录交换机实现自动配置备份的方法大概了解了吗?如果想了解更多,欢迎关注主机参考行业资讯频道哦

What are the methods to automatically configure backup by using Python script to log in switch? Let’s follow Xiaobian to have a look.

1、 Python script

SSH = paramiko. Sshclient(), SSH. Set 58853; missing host key policy (paramiko. Autoaddpolicy()), SSH. Connect (“10. X.x.x”, 22, “user name”, “password”, allow agent = false, look for keys = false)

command = ‘sh running-config r ‘

stdin, stdout, stderr = ssh.exec_command(command)#stdin, stdout, stderr = ssh.invoke_shell(command)a=[]result = stdout.readlines()

if not result:result = stderr.read()

backup=open(“/root/worke/beifen/beifen.txt”,”w”)

for line in result:print(line)backup.write(line)

backup.close()ssh.close()

After reading the above, do you have a general idea of how to use Python script to log in to the switch to automatically configure the backup? If you want to learn more, please pay attention to the host reference industry information channel

————————————————————–

主机参考,收集国内外VPS,VPS测评,主机测评,云服务器,虚拟主机,独立服务器,国内外服务器,高性价比建站主机相关优惠信息@

详细介绍和测评国外VPS主机,云服务器,国外服务器,国外主机的相关优惠信息,商家背景,网络带宽等等,也是目前国内最好的主机云服务器VPS参考测评资讯优惠信息分享平台

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。