import paramiko import time,os import pymysql from concurrent.futures import ThreadPoolExecutor flie_time =str(time.strftime('%Y-%m-%d')) #时间格式2023-04-10 def sftp_down_file(host,timeout=10): try: connect_sftp = paramiko.Transport((host,22)) connect_sftp.banner_timeout = timeout connect_sftp.connect(username='账号',password='密码') sftp = paramiko.SFTPClient.from_transport(connect_sftp) sftp.get('/startup.cfg') connect_sftp.close() print(host,'ok') return True except Exception as e: with open( "err", "a+") as f: f.write(host + "\n") print(host,'写入文件中') time.sleep(1) host_ll =['ip1',iP2...] theard_pool = ThreadPoolExecutor(max_workers=20) for my_host in host_ll: theard_pool.submit(sftp_down_file, my_host)
h3c交换机sftp下载startup.cfg
最新推荐文章于 2024-05-23 17:41:28 发布