import paramiko
from contextlib import closing
from scpclient import WriteDir
ssh_client = paramiko.SSHClient()
ssh_client.load_system_host_keys()
ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh_client.connect("10.239.168.112", username="user", password="123456")
with closing(WriteDir(ssh_client.get_transport(), '~/remote_dir/')) as scp:
scp.send_dir('./local_dir/', preserve_times=True)
网友评论