I want to copy the file from remote server to local.
import paramiko
paramiko.util.log_to_file('/tmp/paramiko.log')
# open transport
username = "user"
host="example.com"
port = 22
transport = paramiko.Transport((host, port))
transport.start_client()
private_key_file = "/home/user/.ssh/id_rsa"
agent = paramiko.Agent()
key = paramiko.RSAKey.from_private_key_file(private_key_file)
transport.auth_publickey(username, key)
# get sftp client
sftp = paramiko.SFTPClient.from_transport(transport)
source = "/home/user/user_1.csv"
target = "/home/local/local_sftp.txt"
sftp.get(x[0], x[1])
Above code is working fine but I want to use source = "/home/user/user_*.csv"
but this wildcard is not evaluated.
Can someone please help me fix this problem.
I found one solution for SCPClient
but not able to fix the problem for SFTPClient
.