As haukex mentioned, you probably should be using a module for the SSH connection. Two recent questions suggest that Net::SSH::Perl might be useful and give both some pitfalls and solutions.

Further, the SSH configuration you describe does not do what you seem to think that it does — the user account that you have created can get a shell with "ssh user@remotehost.com /bin/sh". You need to use the "forced command" option with the public key registered on the remote machine to ensure that that key can only be used to run your program, and you really need to read perlsec if that remote program is written in Perl and make sure that it cannot be abused to gain a shell if you do not want shell access to be available.

Lastly, one big difference between running ssh on a terminal and on pipes is whether SSH sets up a pty on the remote machine by default. Try "ssh -tt user@remotehost.com" instead if you insist on using IPC::Open3 for this.


In reply to Re: Problem executing command via ssh by jcb
in thread Problem executing command via ssh by mgalindez

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.