| 主机参考: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参考测评资讯优惠信息分享平台
这几篇文章你可能也喜欢:
- HOSTDARE:在美国洛杉矶的VPS主持人40%折扣,年度付款起价为10.4美元起,起价为10美元。
- DIYVM:日本/美国/香港的副总裁以50元/月的价格开始,香港的服务器从499元/月开始
- HOSTKVM韩国本地VPS在有限的时间内可享受10%的折扣,您可以享受2核4G配置,价格为11.7美元,适合国际业务扩张(VPS品牌在韩国都优越)
- VMISS便宜的VPS:从多个国家 /地区的多个计算机室中进行选择,并支持CN2 GIA,AS9929等的高速线路。
- [5.1] Edgenat香港VPS/US VPS/韩国VPS每年折扣30%,香港独立服务器的起价为300元/月
本文由主机参考刊发,转载请注明:利用Python脚本登录交换机实现自动配置备份的方法 https://zhujicankao.com/12334.html
主机参考















评论前必须登录!
注册