#! /usr/bin/perl -w
use strict;
use Net::SSH::Perl;
use Term::ReadKey;
my $host = '10.0.0.254';
my $user = 'foo';
my $pw = 'bar';
my $ssh = Net::SSH::Perl->new( $host, (
protocol => '1',
debug => 1,
)) or die "Could not create Net::SSH::Perl object: $!\n";
$ssh->login($user, $pw);
if( @ARGV ) {
ReadMode('raw');
$ssh->shell;
ReadMode('restore');
}
else {
my($stdout, $stderr, $exit) = $ssh->cmd("get config\n");
print <<"SSH_END";
STDOUT BEGIN
$stdout
STDOUT END
STDERR BEGIN
$stderr
STDERR END
EXIT=$exit
SSH_END
}
####
localhost: Reading configuration data /home/foo/.ssh/config
localhost: Reading configuration data /etc/ssh_config
localhost: Connecting to 10.0.0.254, port 22.
localhost: Remote protocol version 1.5, remote software version SSH Protocol Compatible Server SCS 2.0
localhost: Net::SSH::Perl Version 1.23, protocol version 1.5.
localhost: No compat match: SSH Protocol Compatible Server SCS 2.0.
localhost: Connection established.
localhost: Waiting for server public key.
localhost: Received server public key (768 bits) and host key (1024 bits).
localhost: Host '10.0.0.254' is known and matches the host key.
localhost: Encryption type: DES3
localhost: Sent encrypted session key.
localhost: Received encryption confirmation.
localhost: RSA authentication using agent refused.
localhost: RSA authentication failed: Can't load public key.
localhost: Trying password authentication.
localhost: Requesting pty.
localhost: Requesting shell.
localhost: Entering interactive session.
Remote Management Console
foo-> get config
Total Config size 6527:
set auth type 0
set auth timeout 20
...
foo-> exit
####
ocalhost: Reading configuration data /home/dlandgre/.ssh/config
localhost: Reading configuration data /etc/ssh_config
localhost: Connecting to 10.0.0.254, port 22.
localhost: Remote protocol version 1.5, remote software version SSH Protocol Compatible Server SCS 2.0
localhost: Net::SSH::Perl Version 1.23, protocol version 1.5.
localhost: No compat match: SSH Protocol Compatible Server SCS 2.0.
localhost: Connection established.
localhost: Waiting for server public key.
localhost: Received server public key (768 bits) and host key (1024 bits).
localhost: Host '10.0.0.254' is known and matches the host key.
localhost: Encryption type: DES3
localhost: Sent encrypted session key.
localhost: Received encryption confirmation.
localhost: RSA authentication using agent refused.
localhost: RSA authentication failed: Can't load public key.
localhost: Trying password authentication.
localhost: Sending command: get config
localhost: Entering interactive session.
localhost: Warning: ignoring packet of type 15
####
$ssh->register_handler( 15, sub {
my($s, $pkt) = @_;
print "\ngot: ", $pkt->get_str, "\n";
});
####
Use of uninitialized value in addition (+) at /usr/local/share/perl/5.6.1/Net/SSH/Perl/Buffer.pm line 125.
substr outside of string at /usr/local/share/perl/5.6.1/Net/SSH/Perl/Buffer.pm line 48.
Use of uninitialized value in print at ./getcfg line 27.
got: