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, 22); my $ssh_c = Net::OpenSSH->new($host_c, master_opts => [-o => "ProxyCommand=$tunnel_cmd"], ...); $ssh_c->error and die; $ssh_c->system('ls');