I have multiple cisco routers configured with telnet access allow开发者_Go百科ed from 5 specified hosts. Now I want to execute a perl script on one host which connects via ssh to the other hosts and checks if telnet to the router is possible. I tried the system "ssh host" command but unfortunately with no joy. Could somebody help me please?
Many thanks in advance.
I tried the following but with no success. Some ideas?
use Net::OpenSSH;
$ssh = Net::OpenSSH->new("linuxserver", user => "username", password => "password", master_stderr_discard => 1);
$command = "telnet routername";
@out = $ssh->capture({stdin_data => "routerpassword\n"}, $command);
print "@out\n";
You can use Net::SSH2 to connect and forward a connection to the router using the tcpip method. Alternately you can use Net::OpenSSH (which only requires the OpenSSH binaries) to do the same, see the information on Tunnels.
精彩评论