import paramiko import os def download_from(ip,u,p): file_list=[‘file2‘,file3‘,‘file4‘] file_path="/home/projs/" client=paramiko.Transport((ip,22)) client.connect(username=u,password=p) sftp=paramiko.SFTPClient.from_transport(clie
import paramiko
import os
def download_from(ip,u,p):
file_list=[‘file2‘,file3‘,‘file4‘]
file_path="/home/projs/"
client=paramiko.Transport((ip,22))
client.connect(username=u,password=p)
sftp=paramiko.SFTPClient.from_transport(client)
for file in file_list:
sftp.get(os.path.join(file_path,file),os.path.join(‘local_path‘,file))
client.close()
def put_to(ip,u,p):
file_path="E:\\"
remote_path=‘/home/ubuntu/‘
client=paramiko.Transport((ip,22))
client.connect(username=u,password=p)
sftp=paramiko.SFTPClient.from_transport(client)
for file in os.listdir(file_path):
file_s=os.path.join(file_path,file)
if os.path.isfile(file_s):
sftp.put(file_s,os.path.join(remote_path,file))
client.close()