#!/usr/bin/python import paramiko def push_file(file): f = open(file,‘r‘) running = 1 while running: line = f.readline() if line != ‘‘: line = line.strip(‘\n‘) list = line.split(‘ ‘) ip = list[0] username = list[1] password = list[2] t = paramiko.Transport((ip,22)) t.connect(username = username, password = password) sftp = paramiko.SFTPClient.from_transport(t) remotepath=‘/root/data/test.txt‘ localpath=‘/root/data/test.txt‘ sftp.put(localpath,remotepath) t.close() else: running = 0 f.close() push_file(‘host_list‘)
时间: 2024-10-09 01:17:53