-Fix mknb to extract id_rsa.pub if it doesn't exist yet id_rsa does

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@1435 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
jbjohnso 2008-05-16 19:17:44 +00:00
parent 42f3c37255
commit b367416316

View File

@ -50,10 +50,18 @@ sub process_request {
return;
}
unless ( -r "/root/.ssh/id_rsa.pub" ) {
$callback->({data=>["Generating ssh private key for root"]});
my $rc=system('ssh-keygen -t rsa -q -b 2048 -N "" -f /root/.ssh/id_rsa');
if ($rc) {
$callback->({error=>["Failure executing ssh-keygen for root"],errorcode=>[1]});
if (-r "/root/.ssh/id_rsa") {
$callback->({data=>["Extracting ssh public key from private key"]});
my $rc = system('ssh-keygen -y -f /root/.ssh/id_rsa > /root/.ssh/id_rsa.pub');
if ($rc) {
$callback->({error=>["Failure executing ssh-keygen for root"],errorcode=>[1]});
}
} else {
$callback->({data=>["Generating ssh private key for root"]});
my $rc=system('ssh-keygen -t rsa -q -b 2048 -N "" -f /root/.ssh/id_rsa');
if ($rc) {
$callback->({error=>["Failure executing ssh-keygen for root"],errorcode=>[1]});
}
}
}
my $tempdir = tempdir("mknb.$$.XXXXXX",TMPDIR=>1);