Net::SSH::Perl Problem

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Im trying to get the example script working on
Solaris 10. It seems as if the handlers are not actually picking up the
output of the passwd command. Any idea why?

Thanks in advance for any reply's.

When run with debug flags turned on i get....
hostname# ./
hostname: Reading configuration data /root/.ssh/config
hostname: Reading configuration data /etc/ssh_config
hostname: Allocated local port 1023.
hostname: Connecting to desthost, port 22.
hostname: Remote protocol version 2.0, remote software version
hostname: Net::SSH::Perl Version 1.29, protocol version 2.0.
hostname: No compat match: Sun_SSH_1.0.
hostname: Connection established.
hostname: Sent key-exchange init (KEXINIT), wait response.
hostname: Algorithms, c->s: 3des-cbc hmac-sha1 none
hostname: Algorithms, s->c: 3des-cbc hmac-sha1 none
hostname: Entering Diffie-Hellman Group 1 key exchange.
hostname: Sent DH public key, waiting for reply.
hostname: Received host key, type 'ssh-dss'.
hostname: Host 'desthost' is known and matches the host key.
hostname: Computing shared secret key.
hostname: Verifying server signature.
hostname: Waiting for NEWKEYS message.
hostname: Enabling incoming encryption/MAC/compression.
hostname: Send NEWKEYS, enable outgoing encryption/MAC/compression.
hostname: Sending request for user-authentication service.
hostname: Service accepted: ssh-userauth.
hostname: Trying empty user-authentication request.
hostname: Authentication methods that can continue: publickey,password.
hostname: Next method to try is publickey.
hostname: Next method to try is password.
hostname: Trying password authentication.
hostname: Login completed, opening dummy shell channel.
hostname: channel 0: new [client-session]
hostname: Requesting channel_open for channel 0.
hostname: channel 0: open confirm rwindow 0 rmax 16384
hostname: Got channel open confirmation, requesting shell.
hostname: Requesting service shell on channel 0.
hostname: channel 1: new [client-session]
hostname: Requesting channel_open for channel 1.
hostname: Entering interactive session.
hostname: Sending command: passwd root
hostname: Requesting service exec on channel 1.
hostname: channel 1: open confirm rwindow 0 rmax 16384
hostname: channel 1: rcvd eof
hostname: channel 1: output open -> drain
hostname: input_channel_request: rtype exit-status reply 0
hostname: channel 1: rcvd close
hostname: channel 1: input open -> closed
hostname: channel 1: close_read
hostname: channel 1: obuf empty
hostname: channel 1: output drain -> closed
hostname: channel 1: close_write
hostname: channel 1: send close
hostname: channel 1: full closed


#!/usr/local/bin/perl -w

my($host, $username, $new_password, $old_password);


use strict;
use Net::SSH::Perl;
use Net::SSH::Perl::Constants qw( :msg );

my $ssh = Net::SSH::Perl->new($host, debug => 1);
$ssh->login($username, $old_password);

$ssh->register_handler(SSH_SMSG_STDERR_DATA, sub {
    my($ssh, $packet) = @_;
    my $str = $packet->get_str;

    if ($str eq "New Password: ") {
        print "first match\n";
        my $packet = $ssh->packet_start(SSH_CMSG_STDIN_DATA);

    elsif ($str eq "Re-enter new password: ") {
        print "second match\n";
        my $packet = $ssh->packet_start(SSH_CMSG_STDIN_DATA);

$ssh->cmd("passwd root");

Site Timeline