Eu finalmente poderia fazer isso com um código python:
import paramiko
import time
import os
def touch(path):
with open(path, 'a'):
os.utime(path, None)
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect('ip', port=port, username='USER', password='PASS',
key_filename='OPTIONAL Address to private Key')
baseCommand = "command"
stdin, stdout, stderr = ssh.exec_command('some command')
print(stdout.readlines())
stdin, stdout, stderr = ssh.exec_command(baseCommand + 'ls')
print(stdout.readlines())
#for copy file
localpath = "local paths" + time.strftime("%Y-%m-%d-%H-%M-%S") + ".sql"; # add a date name for file
remotepath = "remote path"
touch(localpath);
sftp.get(remotepath, localpath) # download the file
sftp.close()
ssh.close()