Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: openssh start another ssh session on machine b

by salva (Abbot)
on Mar 27, 2014 at 08:47 UTC ( #1079891=note: print w/replies, xml ) Need Help??


in reply to openssh start another ssh session on machine b

You can use the ProxyCommand feature of OpenSSH (requires tunnels enabled on host b and a relatively recent version of OpenSSH on the local host):
my $ssh_b = Net::OpenSSH->new($host_b, ...); $ssh_b->error and die; my $tunnel_cmd = $ssh_b->make_remote_command({tunnel => 1}, $host_c, 2 +2); my $ssh_c = Net::OpenSSH->new($host_c, master_opts => [-o => "ProxyCom +mand=$tunnel_cmd"], ...); $ssh_c->error and die; $ssh_c->system('ls');
Another option is to install Net::OpenSSH::Gateway available from GitHub.
my $ssh_c = Net::OpenSSH->new($host_c, gateway => { proxy => "ssh://$h +ost_b"}, ...);
That module implements a set of strategies to forward SSH connections over different kinds of proxies including SSH gateways. It is not on CPAN because I was not happy with its internal architecture and planed to revamp it completely but unfortunately, I never got the time (or the guts) to actually do it and it has languished there. In any case I would fix any bug reported.

Replies are listed 'Best First'.
Re^2: openssh start another ssh session on machine b
by jhuijsing (Acolyte) on Mar 31, 2014 at 03:53 UTC
    Can't install anything on machine "B" easily. Have to get vendor approval. What I need to do is ssh to "B" and then ssh to a different port on the "B" to start a CLI session.
      Neither of the two methods exposed on my previous post require installing anything on host B. Everything is done in host A.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1079891]
help
Chatterbox?
LanX 4 kids and wanting to upgrade to 5? wow! ! !
[1nickt]: My lads are 15 and 31 now and both drive me just as crazy as when little, just less frequently.
[LanX]: ;p
[marto]: LanX I'd rather commit sudoku :P
[marto]: trench humour folks, feeling rough.
[marto]: there is never a night when they sleep all the way through, but last night was something else
[marto]: gave in at 3:45 ish and let Charlie watch videos about spitfires, the battle of Britain. He's plane crazy
[1nickt]: marto soothing!

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (7)
As of 2017-11-18 18:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (277 votes). Check out past polls.

    Notices?