# -*- coding: utf-8 -*-
"""
Created on Mon Sep 18 12:41:55 2017
@author: hanye
"""
import paramiko
import scp
import datetime
def createSSHClient(server, port, user, password):
client = paramiko.SSHClient()
client.load_system_host_keys()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(server, port, user, password)
return client
server = '192.168.17.12'
port = 22
user = 'root'
password = 'Lz8rsAVF'
ssh = createSSHClient(server, port, user, password)
scp = scp.SCPClient(ssh.get_transport())
today_T = datetime.datetime.today()
today_compacted_str = today_T.isoformat()[0:10].replace('-', '')
ftp_folder_path = '/boot/opt/qingbo/'
filename = 'appurl'+today_compacted_str+'.zip'
ftp_file_full_path = ftp_folder_path+filename
target_server_path = '/home/hanye/project_data/qingbo-ftp-files/'
scp.get(remote_path=ftp_file_full_path,local_path=target_server_path,preserve_times=True)
-
litaolemo authoredd83f79a7