我希望从本地/远程linux服务器复制文件目录, 以下代码用于文件复制。但是不适用于目录。
import paramiko
import os
paramiko.util.log_to_file('LC2lucas1.txt')
host = "10.1.1.43"
port = 22
username = 'root'
password = 'pw123'
transport = paramiko.Transport((host, port))
transport.connect(username = username, password = password)
sftp = paramiko.SFTPClient.from_transport(transport)
filepath = '/tftpboot/scripts/users/lynn/'
localpath = '/tftpboot/scripts/users/lynn/'
sftp.get(filepath, localpath)
sftp.close()
transport.close()