in reply to Re: Re: interact with remote host via bastion
in thread interact with remote host via bastion

Just write a passthrough script for the bastion. All you have to do is SSH into the bastion and fire up the passthrough script. Pass commands to this script which then passes them on to another host and printing the resulting output to STDOUT which by default will go back to you localhost. Such a script might look like this:

#!/usr/bin/perl # passthrough SSH script use Net::SSH qw(sshopen2); use strict; my $user = "username"; my $host = "hostname"; while ( my $cmd = <> ) { last if $cmd =~ /exit_passthrough/; sshopen2("$user\@$host", *READER, *WRITER, "$cmd") || print "ssh: +$!"; my $result = ''; $result .= $_ while <READER>; print $result; } close READER; close WRITER;

Effectively this creates a basic SSH secured shell in the middle for you. A bonus is that you can get the script to work on the bastion box and then step back to localhost to make debugging straight forward.

cheers

tachyon

s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print