title: SSH with Perl using file handles, not Net::SSH
body: <p>Before I ask the question:</p>
  
  <p>I can not use cpan module Net::SSH, I want to but can not, no amount of begging will change this fact</p>
  
  <p>I need to be able to open an SSH connection, keep it open, and read from it's stdout and write to its stdin.  My approach thus far has been to open it in a pipe, but I have not been able to advance past this, it dies straight away.</p>
  
  <p>That's what I have in mind, I understand this causes a fork to occur.  I've written code accordingly for this fork (or so I think).</p>
  
  <p>Below is a skeleton of what I want, I just need the system to work.</p>
  
  <pre><code>#!/usr/bin/perl
  
  
  use warnings;
  
  $| = 1;
  
  $pid = open (SSH,"| ssh user\@host");
  
  if(defined($pid)){
      if(!$pid){
          #child
          while(&lt;&gt;){
              print;
          }
      }else{
          select SSH;
          $| = 1;
  
          select STDIN;
  
          #parent
          while(&lt;&gt;){
              print SSH $_;
              while(&lt;SSH&gt;){
                  print;
              }
          }
      close(SSH);
      }
  }
  </code></pre>
  
  <p>I know, from what it looks like, I'm trying to recreate "system('ssh user@host')," that is not my <em>end</em> goal, but knowing how to do that would bring me much closer to the end goal.</p>
  
  <p>Basically, I need a file handle to an open ssh connection where I can read from it the output and write to it input (not necessarily straight from my program's STDIN, anything I want, variables, yada yada)</p>
  
  <p>This includes password input.</p>
  
  <p>I know about key pairs, part of the end goal involves making key pairs, but the connection needs to happen regardless of their existence, and if they do not exist it's part of my plan to make them exist.</p>