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

I looked into this, and while it would work fairly well via one host, the bastion in the middle causes some problems.

perhaps i should have explained that more clearly earlier.

localhost ->ssh to bastion ->ssh to remotehost->command

i'd like to keep the chain alive.

Thanks for your help, but it looks like i'm going to have to rewrite the pty code in order to pull this off.
  • Comment on Re: Re: interact with remote host via bastion

Replies are listed 'Best First'.
Re: Re: Re: interact with remote host via bastion
by tachyon (Chancellor) on Feb 15, 2003 at 23:42 UTC

    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