Greetings,
I find myself in a bit of a bind. I'm looking for a module or perhaps method that will allow me to connect via a bastion host to a remote machine (ssh). at this point i need to execute commands and store the values in either a scalar with \n to parse into an array or directly into an array.

I've looked inot using the expect module, but from what i can tell ->before only pulls a single line. Maybe i'm missing something.

I've also attempted to use Net::Tel , using a ssh session spawned to a PTY, then interacting with the PTY. The problem with this is that with at least all the versions of openssh i use it requires a valid tty or i can't auth.

That brings up the idea of using passwordless dsa keys, but i'm not fond of this.

Now i can execute an actual expect script for each command and pull the return values into an array, but that means i need to establish an individual connection for each command. And that's jut plain wasteful.

So, the question i pose is ... what other options do i have?

In reply to interact with remote host via bastion by jaco

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.