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;
}
In reply to Prompted for password in OpenSSH by kdamundson
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |