我想用 Perl 脚本更改远程 Linux 机器上的 root 密码。我的第一次尝试是以下代码:
use Net::OpenSSH;
my $ssh = Net::OpenSSH->new(
"linuxpc",
user => "root",
password => "root",
master_stderr_discard => 1
);
my @changepass = $ssh->capture(
{
stderr_discard => 1,
stdin_data => "newpw123"
},
"passwd"
);
print "Done\n";
但不幸的是,它不起作用。有人可以帮我吗?