I've spent quite a bit of time getting into coding with Net:SSH:Perl and have come across an interesting problem. The examples provided for that module suggest I can remotely change my password over SSH however neither example will work even after modifying it. Here is my sample ssh code:

#!/usr/bin/perl use warnings; use strict; use Net::SSH::Perl; my $srvr = "testserver"; my $username = "test"; my $oldpasswd = "test"; my ($stdout, $stderr, $exit); my $cmd = ('passwd'); my $ssh = Net::SSH::Perl->new($srvr, protocol => 2, debug => 1); $ssh->register_handler("stderr", sub { my($channel, $buffer) = @_; print "** Standard Error - I received this:\n", $buffe +r->bytes; }); # This trigger works perfectly # $ssh->register_handler("stdout", sub { my($channel, $buffer) = @_; print "** Standard Out - I received this:\n", $buffer- +>bytes; }); $ssh->login($username, $oldpasswd); $ssh->cmd($cmd); print "** Ran Command ". $cmd ."\n";
the code runs fine if I put a command such as 'ls' or 'hostname' (for example) in variable $cmd. If I put 'passwd' then the register_trigger for stderr comes back with the following error message

chqpvul8108: channel 1: new client-session
chqpvul8108: Requesting channel_open for channel 1.
chqpvul8108: Entering interactive session.
chqpvul8108: Sending command: passwd
chqpvul8108: Requesting service exec on channel 1.
chqpvul8108: channel 1: open confirm rwindow 0 rmax 16384
chqpvul8108: channel 1: rcvd eof
chqpvul8108: channel 1: output open -> drain
chqpvul8108: input_channel_request: rtype exit-status reply 0
chqpvul8108: channel 1: rcvd close
chqpvul8108: channel 1: input open -> closed
chqpvul8108: channel 1: close_read
** Standard Error - I received this:
Unexpected failure. Password file/table unchanged.
chqpvul8108: channel 1: obuf empty
chqpvul8108: channel 1: output drain -> closed
chqpvul8108: channel 1: close_write
chqpvul8108: channel 1: send close
chqpvul8108: channel 1: full closed
** Ran Command passwd

Any thoughts on what I'm missing here? I've googled and checked out the net::ssh::perl forum and haven't figured out why It's giving me heartburn. Has anyone been successful in issuing passwd with this module? This is running on a Suse Linux server and the client is a Solaris 9 Sparc. The reason I'm doing this is I'm writing a program to connect via SSH and change my password on a number of Unix/Linux servers (don't ask). Thanks!

In reply to Net::SSH::Perl and Passwd by u235sentinel

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.