开发者

Perl ssh connection and execute telnet connection

开发者 https://www.devze.com 2023-02-22 02:51 出处:网络
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 c

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号