From b36741631686b282c4dc94f7abb53f22d2680e70 Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Fri, 16 May 2008 19:17:44 +0000 Subject: [PATCH] -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 --- xCAT-server-2.0/lib/xcat/plugins/mknb.pm | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/xCAT-server-2.0/lib/xcat/plugins/mknb.pm b/xCAT-server-2.0/lib/xcat/plugins/mknb.pm index 081714d96..62e088991 100644 --- a/xCAT-server-2.0/lib/xcat/plugins/mknb.pm +++ b/xCAT-server-2.0/lib/xcat/plugins/mknb.pm @@ -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);