| 主机参考: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参考测评资讯优惠信息分享平台
这几篇文章你可能也喜欢:
- 蓝色Xiyun香港AMD服务器4内核4G 19.9/月8核8G 39/月16核心16G 79/月,相同的价格更新价格
- HOSTDARE US虚拟托管在第一个月起为0.03美元(US Virtual IP)
- 网站服务器和虚拟主机有什么区别? (虚拟主机和虚拟服务器)
- 野马云:2024年采购季节的特别优惠,香港VPS年度付款从89元开始,服务器从199元/月开始
- Ultahost:外国VPS/独立服务器/虚拟主机(如何构建外国服务器)
本文由主机参考刊发,转载请注明:利用Python脚本登录交换机实现自动配置备份的方法 https://zhujicankao.com/12707.html
主机参考













评论前必须登录!
注册