title: How can I redirect program output using libssh2?
body: <p>I'm using libssh2 for a C++ program in a Linux environment and so far I'm able to start a program on a remote machine using <code>libssh2_channel_exec</code>. However I'd like to redirect the program's output to the local machine (i.e. the output shall travel over ssh).
  I'd like to achieve the same goal of the following bash line:</p>
  
  <p><code>$ ssh user@remote ls &gt; local_file.txt</code></p>
  
  <p>I cannot specify the <code>&gt; local_file.txt</code> part the <code>command</code> parameter because the file must be written in the local machine and not in the remote one.</p>
  
  <p>So, how can I redirect a remote program's output to the local machine?</p>