Net::SSH::Perl Help

B

blob

Hi all,

Below is my script that will be used to connect to a remote host and
change my password automatically:

===========================================
#!/usr/bin/perl


use strict();
use Net::SSH::perl;


$user="jaws";
$pass="password";
$host="xxx.xxx.xxx.xxx";
$old_password="password";
$new_password="newpass";


my $ssh = Net::SSH::perl->new($host,debug=>1,use_pty=>1);
$ssh->login($user, $pass);


$ssh->register_handler("stderr", sub {
my($channel, $buffer) = @_;
my $str = $buffer->bytes;


if ($str eq "Enter login password: ") {
$channel->send_data($old_password);
}


elsif ($str eq "New password: ") {
$channel->send_data($new_password);
}

elsif ($str eq "Re-enter new password: ") {
$channel->send_data($new_password);
}
});
$ssh->cmd('passwd');
==========================================

After running the program, my password didnt changed I was still able to
connect using the old password.

Does anybody has an idea what's missing or wrong with my script?

Thanks.

Jaws
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top