Parallel-uniform inspection of pipelines and inlet / outlet pipes

I need a paramiko-based file transfer method with lightweight SSH2 ( dropbear ) that does not support SCP or SFTP . Is there a way to reach the cat and redirect the transfer of style files, for example:

ssh server "cat remote_file" > local_file

with paramiko channels?

Can paramiko.Transport.open_channel () or Message () do the job? I am not sure how to proceed.

+3
source share
1 answer

The following may be useful as a starting point (for example, the command "/ sshpipe host"):

#! /usr/bin/env python

import sys
import paramiko

def sshpipe(host, line) :
    client = paramiko.SSHClient()
    client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    client.connect(host)
    stdin, stdout, stderr = client.exec_command(line)
    output = stdout.read()
    sys.stdout.write(output)
    stdin.close()
    stdout.close()
    stderr.close()
    client.close()

sshpipe(sys.argv[1], sys.argv[2])
+3

Source: https://habr.com/ru/post/1729916/


All Articles