赞
踩
import paramiko #创建ssh对象 ssh = paramiko.SSHClient() #ssh.load_host_keys("C:/Users/Administrator/.ssh/known_hosts") #允许连接不在know_hosts文件的主机上 ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) filename = ['artist_followby_user.tsv','artist.tsv','activity_artist.tsv','order.tsv','raise.tsv','user.tsv','activity_followby_user.tsv'] #本地文件路径 for i in filename: localpath = "/Users/taihe/Desktop/" + i #服务器的文件路径 remotepath = "/data/tdc_data/" + i #可设置多台服务器,尽量服务器的密码保持一致 server = "xxxxxx" # words = server.split(",") # for word in words: #连接服务器 print(server,'开始数据传输') ssh.connect(server, username="xxxxx", password="xxxxxx") sftp = ssh.open_sftp() sftp.put(localpath, remotepath, callback = None) #关闭连接 ssh.close() print('数据传输完成')
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。