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:
erl;
$user="jaws";
$pass="password";
$host="xxx.xxx.xxx.xxx";
$old_password="password";
$new_password="newpass";
my $ssh = Net::SSH:
erl->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
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:
$user="jaws";
$pass="password";
$host="xxx.xxx.xxx.xxx";
$old_password="password";
$new_password="newpass";
my $ssh = Net::SSH:
$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