kdamundson has asked for the wisdom of the Perl Monks concerning the following question:
I have a script that works fine (with no intervention) for changing Linux passwords except when the remote system's authorized_keys file does not have an entry for our password depot server (where the script is run from). The script then halts and prompts for a password from the command line. Is there a way around this?...without forking a process. I have tried to use POE for non-blocking but I cannot get that to work either.
sub ChangeRemoteServerPassword
{
my ($server, $adminuser, $newpass) = @_;
my $ssh = Net::OpenSSH->new($server);
if ($ssh->error)
{
Logit(*DBLOG,"FAILED: Remote SSH connection - $ssh->error\n");
return (0);
}
my $userstr = $adminuser . "\:" . "$newpass";
my $cmd = "echo \'$userstr\' | /usr/sbin/chpasswd";
$ssh->system("$cmd");
if ($ssh->error)
{
Logit(*DBLOG,"FAILED: Running SSH cmd - $ssh->error\n");
return (0);
}
return 1;
}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Prompted for password in OpenSSH
by salva (Canon) on Apr 19, 2011 at 14:21 UTC | |
by kdamundson (Initiate) on Apr 19, 2011 at 14:47 UTC | |
|
Re: Prompted for password in OpenSSH
by fidesachates (Monk) on Apr 19, 2011 at 13:56 UTC |