主机参考:VPS测评参考推荐/专注分享VPS服务器优惠信息!若您是商家可以在本站进行投稿,查看详情!此外我们还提供软文收录、PayPal代付、广告赞助等服务,查看详情! |
我们发布的部分优惠活动文章可能存在时效性,购买时建议在本站搜索商家名称可查看相关文章充分了解该商家!若非中文页面可使用Edge浏览器同步翻译!PayPal代付/收录合作 |
利用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测评,主机测评,云服务器,虚拟主机,独立服务器,国内外服务器,高性价比建站主机相关优惠信息@zhujicankao.com
详细介绍和测评国外VPS主机,云服务器,国外服务器,国外主机的相关优惠信息,商家背景,网络带宽等等,也是目前国内最好的主机云服务器VPS参考测评资讯优惠信息分享平台
这几篇文章你可能也喜欢:
- 华纳云:服务器2.3折起,香港CN2服务器低至800元/月,海外云服务器月付7折,季付5.5折,续费同价。
- Band wagon主机:92.30美元/年/2核/2G内存/40SSD/1T流量/1Gbps/ CMI/香港/软银大阪/CN2 GIA洛杉矶。
- Spinservers:美国达拉斯机房独立服务器年中推广!(达拉斯机场是美国的哪个城市?)
- 莱卡棉:七月促销!港美欧云服务器产品低至15.9元(徕卡论坛)
- 华纳云:100M专属大带宽服务器低至688元/月,不限流量/现场交付,适用于CDN/视频直播多场景应用。
本文由主机参考刊发,转载请注明:利用Python脚本登录交换机实现自动配置备份的方法 https://zhujicankao.com/12334.html
评论前必须登录!
注册