# -*- coding: utf-8 -*-
"""
Created on Mon Sep 18 12:41:55 2017

@author: hanye
"""

import paramiko
#import scp
from scp import SCPClient
#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 = SCPClient(ssh.get_transport())

def scp_from_ftp_server(remote_filename_with_full_path, local_path):

    scp.get(remote_path=remote_filename_with_full_path,
            local_path=local_path,
            preserve_times=True)


def scp_to_ftp_server(local_file_with_full_path, remote_full_path):
    
    scp.put(files=local_file_with_full_path,
            remote_path=remote_full_path,
            recursive=True,
            preserve_times=True)