<%args> $pingserver <%perl> use Net::SSH::Perl; use Math::GMP; use IO::Select; #my $pingserver='172.16.50.4'; #This is for testing purposes only my $pingme ="ping -c1 $pingserver"; my $server=''; #cleaned for posting a question my $username='root'; my $ssh = Net::SSH::Perl->new($server, debug=>1,options =>[ "UserKnownHostsFile /var/www/.ssh/known_hosts2" ]); $ssh->login($username) or die "Login Failed!!!\n"; my ($out, $err, $exit) = $ssh->cmd($pingme);

<% $out %>
#### : Reading configuration data /var/www/.ssh/config : Reading configuration data /etc/ssh_config : Connecting to , port 22. : Remote version string: SSH-2.0-OpenSSH_3.8.1p1 Debian-8.sarge.4 : Remote protocol version 2.0, remote software version OpenSSH_3.8.1p1 Debian-8.sarge.4 : Net::SSH::Perl Version 1.30, protocol version 2.0. : No compat match: OpenSSH_3.8.1p1 Debian-8.sarge.4. : Connection established. : Sent key-exchange init (KEXINIT), wait response. : Algorithms, c->s: 3des-cbc hmac-sha1 none : Algorithms, s->c: 3des-cbc hmac-sha1 none : Entering Diffie-Hellman Group 1 key exchange. : Sent DH public key, waiting for reply. : Received host key, type 'ssh-dss'. : Host '' is known and matches the host key.: Computing shared secret key. : Verifying server signature. : Waiting for NEWKEYS message. : Enabling incoming encryption/MAC/compression. : Send NEWKEYS, enable outgoing encryption/MAC/compression. : Sending request for user-authentication service. : Service accepted: ssh-userauth. : Trying empty user-authentication request. : Authentication methods that can continue: publickey,keyboard-interactive. : Next method to try is publickey. : Trying pubkey authentication with key file '/.ssh/id_dsa' : Login completed, opening dummy shell channel. : channel 0: new [client-session] : Requesting channel_open for channel 0. : channel 0: open confirm rwindow 0 rmax 32768 : Got channel open confirmation, requesting shell. t: Requesting service shell on channel 0. : channel 1: new [client-session] : Requesting channel_open for channel 1. : Entering interactive session. : Sending command: ping -c1 172.16.50.4 : Requesting service exec on channel 1. : channel 1: open confirm rwindow 0 rmax 32768 : channel 1: rcvd eof : channel 1: output open -> drain : input_channel_request: rtype exit-status reply 0 : channel 1: rcvd close : channel 1: input open -> closed : channel 1: close_read #### : Reading configuration data /root/.ssh/config : Reading configuration data /etc/ssh_config : Allocated local port 1023. : Connecting to , port 22. : Remote version string: SSH-2.0-OpenSSH_3.8.1p1 Debian-8.sarge.4 : Remote protocol version 2.0, remote software version OpenSSH_3.8.1p1 Debian-8.sarge.4 : Net::SSH::Perl Version 1.30, protocol version 2.0. : No compat match: OpenSSH_3.8.1p1 Debian-8.sarge.4. : Connection established. : Sent key-exchange init (KEXINIT), wait response. : Algorithms, c->s: 3des-cbc hmac-sha1 none : Algorithms, s->c: 3des-cbc hmac-sha1 none : Entering Diffie-Hellman Group 1 key exchange. : Sent DH public key, waiting for reply. : Received host key, type 'ssh-dss'. : Host '' is known and matches the host key. : Computing shared secret key. : Verifying server signature. : Waiting for NEWKEYS message. : Enabling incoming encryption/MAC/compression. : Send NEWKEYS, enable outgoing encryption/MAC/compression. : Sending request for user-authentication service. : Service accepted: ssh-userauth. : Trying empty user-authentication request. : Authentication methods that can continue: publickey,keyboard-interactive. : Next method to try is publickey. : Trying pubkey authentication with key file '/root/.ssh/id_dsa' : Login completed, opening dummy shell channel. : channel 0: new [client-session] : Requesting channel_open for channel 0. : channel 0: open confirm rwindow 0 rmax 32768 : Got channel open confirmation, requesting shell. : Requesting service shell on channel 0. : pingme: ping -c1 172.16.50.4 : channel 1: new [client-session] : Requesting channel_open for channel 1. : Entering interactive session. : Sending command: ping -c1 172.16.50.4 : Requesting service exec on channel 1. : channel 1: open confirm rwindow 0 rmax 32768 : channel 1: rcvd eof : channel 1: output open -> drain : input_channel_request: rtype exit-status reply 0 : channel 1: rcvd close : channel 1: input open -> closed : channel 1: close_read : channel 1: obuf empty : channel 1: output drain -> closed : channel 1: close_write : channel 1: send close : channel 1: full closed OUT: PING 172.16.50.4 (172.16.50.4) 56(84) bytes of data. 64 bytes from 172.16.50.4: icmp_seq=1 ttl=62 time=9.23 ms --- 172.16.50.4 ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 9.239/9.239/9.239/0.000 ms err: Exit: 0