Here's a different approach, albeit less efficient, that only uses things that seem to be working for you. I'm not in a place where I can test code, so I'm just going to sketch this out in terms of ssh commands. You are trying to connect from A to B and then from B to C:
ssh -t -l usrB machineB
ssh -t -l usrC machineC uname -a
Instead, try connecting from A to B and creating a tunnel from B:2222 to C:22. Then connect from A to B:2222:
ssh -f -N -l usrB machineB -L 2222:machineC:22
ssh -t -p 2222 -l usrC machineB uname -a
A key difference here is that the main process has to start the first ssh process and then resume execution while the ssh process continues. I've never tried this from a script, so it is possible that it requires a fork. If this does work, you can reduce the added overhead by choosing weaker encryption for the tunnel's data and rely on your second connection for security.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.