In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)06/01 Report--
What are the ways to automate configuration backups using Python script login switches? Let's take a look at it together with Xiaobian.
1. Python script
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect("10.x.x.x", 22,"username","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 understanding of how to use Python scripts to log in to the switch for automatic configuration backup? If you want to know more, please pay attention to the industry information channel
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.