I want to copy files from remote machine using Python script to my local machine. I only know the extension of the file names so I want to use wildcards to express the file name.
In addition, I want to use the SCPClient Python library and not the os.system directly as suggested in the question titled using wildcards in filename in scp in python
But when I run the following code:
from paramiko import SSHClient
import paramiko
from scp import SCPClient
with SSHClient() as ssh:
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect('10.10.100.5', username= 'root', password='Secret')
with SCPClient(ssh.get_transport()) as scp:
scp.get(remote_path='/root/*.py', local_path='.')
I get an exception
scp.SCPException: scp: /root/*.py: No such file or directory
Running from shell works just fine
scp root@10.10.100.5:/root/*.py .