From: <ale...@us...> - 2011-08-17 23:14:24
|
Revision: 469 http://kiwi-ltsp.svn.sourceforge.net/kiwi-ltsp/?rev=469&view=rev Author: alexqwesa Date: 2011-08-17 23:14:17 +0000 (Wed, 17 Aug 2011) Log Message: ----------- reworked kiwi_ltsp_setup_sshkeys() and get_ssh_keys(), removed kiwi_ltsp_cluster_setup_sshkeys() Modified Paths: -------------- trunk/kiwi-ltsp/ltsp/include/kiwi-ltsp-functions.sh Modified: trunk/kiwi-ltsp/ltsp/include/kiwi-ltsp-functions.sh =================================================================== --- trunk/kiwi-ltsp/ltsp/include/kiwi-ltsp-functions.sh 2011-08-17 23:03:35 UTC (rev 468) +++ trunk/kiwi-ltsp/ltsp/include/kiwi-ltsp-functions.sh 2011-08-17 23:14:17 UTC (rev 469) @@ -710,46 +710,39 @@ fi } +#====================================== +# Verbousely add pub key of ssh servers to $output +#-------------------------------------- get_ssh_keys() { - ips="$1" - if [ -f $output -a -s $output ]; then - for ip in $ips; do -#fix this if [ $ip != $SERVER_IP ]; then - for encryption in $enc; do - host=$(arp $ip | sed -n 2p | cut -d " " -f1) - ssh_key=$(ssh-keyscan -t $encryption $ip 2> /dev/null) - if [ -n "$ssh_key" ]; then - echo $ssh_key >> $output - log "Adding ${encryption}-hostkey for ${ip} to ssh_known_hosts" - if [ -n "$host" ]; then - echo $(ssh-keyscan -t $encryption $host 2> /dev/null) >> $output - log "Adding ${encryption}-hostkey for ${host} to ssh_known_hosts" - fi - else - manual_step "No ${encryption} key found for ${ip} / ${host}, please configure the ssh server correctly and ensure that the secondary server is up." + local ips="$1" + local output="$2" + local enc="$3" + for ip in $ips; do + for encryption in $enc; do + local mac=$(arp $ip | sed -n 2p | cut -d " " -f1) + local ssh_key=$(ssh-keyscan -t $encryption $ip 2> /dev/null) + if [ -n "$ssh_key" ]; then + echo $ssh_key >> $output + log "Adding ${encryption}-hostkey for ${ip} to ssh_known_hosts" + if [ -n "$mac" ]; then + echo $(ssh-keyscan -t $encryption $mac 2> /dev/null) >> $output + log "Adding ${encryption}-hostkey for ${mac} to ssh_known_hosts" fi - done -# fi + else + manual_step "No ${encryption} key found for ${ip} / ${mac}, please configure the ssh server correctly and ensure that the secondary server is up." + fi done - fi + done } - -kiwi_ltsp_cluster_setup_sshkeys() { - ## Setup the SSH keys for seamless access of clients to the secondary servers - ips=`echo $CLUSTER_NODES | tr -d '[:space:]' | tr ',' ' '` - get_ssh_keys "$ips" - -} - +#====================================== +# Setup the SSH keys +#-------------------------------------- kiwi_ltsp_setup_sshkeys() { - ## Setup the SSH keys - ## This is smarter - hostname=$(hostname) - ips=$(ip -o addr show | awk '$3 == "inet" && $4 !~ /^127\./ { print $4 }' | sed -e 's,/[0-9][0-9]*\>,,g') - output="$KIWI_LTSP_CONF/root.default/etc/ssh/ssh_known_hosts" - enc="dsa rsa ecdsa" - names="$hostname $ips" + local ips=$(ip -o addr show | awk '$3 == "inet" && $4 !~ /^127\./ { print $4 }' | sed -e 's,/[0-9][0-9]*\>,,g') + local output="$KIWI_LTSP_CONF/root.default/etc/ssh/ssh_known_hosts" + local enc="dsa rsa ecdsa" + local names="$(hostname) $ips" log "Setting up the SSH keys in $TFTPBOOTPATH/KIWI/root.default/etc/ssh/ssh_known_hosts" if [[ -e $output ]] ; then mv -f $output $output.bak @@ -758,23 +751,31 @@ for name in $names; do for encryption in $enc; do if [ -f $TESTDIR/etc/ssh/ssh_host_${encryption}_key.pub ]; then - echo $(echo $name $(cat $TESTDIR/etc/ssh/ssh_host_${encryption}_key.pub|awk '{split ($0, a, " "); print a[1]" "a[2]" "}')) >> $output + echo -n "$name " >> $output + awk '{split ($0, a, " "); print a[1]" "a[2]" "}' \ + $TESTDIR/etc/ssh/ssh_host_${encryption}_key.pub >> $output log "Adding ${encryption}-hostkey for $name to ssh_known_hosts" else manual_step "No ${encryption} key found for ${name}, please configure your ssh server correctly" cp $output.bak $output fi done - done - - if [ -n "$CLUSTER_NODES" ]; then - kiwi_ltsp_cluster_setup_sshkeys + done + + if [ -f /etc/ltsp/ssh_known_hosts.extra ]; then + cat /etc/ltsp/ssh_known_hosts.extra >> $output fi + + ips= + if [ -n "$CLUSTER_NODES" ]; then + ## Setup the SSH keys for seamless access of clients to the secondary servers + ips="`echo $CLUSTER_NODES | tr -d '[:space:]' | tr ',' ' '`" + fi #if the SERVER_IP is not the IP on which kiwi-ltsp is setup - ips="$SERVER_IPS" + ips="$(echo $ips $SERVER_IPS | tr '[:space:]' '\n' | sort -u | tr '\n' ' ')" log "now adding server $ips" - get_ssh_keys "$ips" + get_ssh_keys "$ips" "$output" "$enc" if [ -f $output.bak ]; then rm $output.bak @@ -782,10 +783,6 @@ } # -## End of setup sshkeys -# - -# ## This section builds kiwi-ltsp-images, nfsroot, clicfs image for nbd/aoe as well as netboot images # This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |