From cb9d780d74a2c80146e8d840866e65104496da7d Mon Sep 17 00:00:00 2001 From: lissav Date: Mon, 11 May 2009 16:59:54 +0000 Subject: [PATCH] fix generation of hostkeys during initial install and migration from previous xcat versions git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@3344 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT/xCAT.spec | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/xCAT/xCAT.spec b/xCAT/xCAT.spec index 41aabf8c1..948bf135c 100644 --- a/xCAT/xCAT.spec +++ b/xCAT/xCAT.spec @@ -109,23 +109,31 @@ if [ ! -d /etc/xcat/hostkeys ]; then mkdir -p /etc/xcat/hostkeys fi -# never generated the keys -if [ ! -f /install/postscripts/hostkeys/ssh_host_key.pub ]; then +# Do not have private keys in install or /etc/xcat/hostkeys +# Generate new keys and update /install with the public keys +if [ ! -f /install/postscripts/hostkeys/ssh_host_rsa_key ] && [ ! -f /etc/xcat/hostkeys/ssh_host_rsa_key ] ; then echo Generating SSH1 RSA Key... /usr/bin/ssh-keygen -t rsa1 -f /etc/xcat/hostkeys/ssh_host_key -C '' -N '' echo Generating SSH2 RSA Key... /usr/bin/ssh-keygen -t rsa -f /etc/xcat/hostkeys/ssh_host_rsa_key -C '' -N '' echo Generating SSH2 DSA Key... /usr/bin/ssh-keygen -t dsa -f /etc/xcat/hostkeys/ssh_host_dsa_key -C '' -N '' + /bin/rm /install/postscripts/hostkeys/* /bin/cp /etc/xcat/hostkeys/ssh_host*.pub /install/postscripts/hostkeys/ -fi -# generated the keys before, still have private keys in install -# copy all to the new private directory and then remove private keys -if [ -f /install/postscripts/hostkeys/ssh_host_key ]; then - /bin/cp -p /install/postscripts/hostkeys/* /etc/xcat/hostkeys/. - /bin/rm /install/postscripts/hostkeys/ssh_host_dsa_key - /bin/rm /install/postscripts/hostkeys/ssh_host_rsa_key - /bin/rm /install/postscripts/hostkeys/ssh_host_key +else +# generated the keys before and still have private keys in install +# copy all from /install to /etc/xcat/hostkeys and then remove private keys +# from /install + if [ -f /install/postscripts/hostkeys/ssh_host_rsa_key ]; then + /bin/cp -p /install/postscripts/hostkeys/* /etc/xcat/hostkeys/. + /bin/rm /install/postscripts/hostkeys/ssh_host_dsa_key + /bin/rm /install/postscripts/hostkeys/ssh_host_rsa_key + /bin/rm /install/postscripts/hostkeys/ssh_host_key + fi + if [ ! -f /install/postscripts/hostkeys/ssh_host_rsa_key.pub ]; then + /bin/rm /install/postscripts/hostkeys/* + /bin/cp /etc/xcat/hostkeys/ssh_host*.pub /install/postscripts/hostkeys/ + fi fi if [ -d /install/postscripts/.ssh ]; then /bin/mv /install/postscripts/.ssh/* /install/postscripts/_ssh/.