我爱编程

python scp dir

2018-04-13  本文已影响0人  橙姜

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)

上一篇 下一篇

猜你喜欢

热点阅读