2 # build the hosts configuration directory with the actual IP addresses
4 # Copyright (C) 2004 Eric Marchionni, Patrik Rayo
5 # Zuercher Hochschule Winterthur
7 # This program is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by the
9 # Free Software Foundation; either version 2 of the License, or (at your
10 # option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
12 # This program is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 # RCSID $Id: build-sshkeys,v 1.2 2005/02/15 14:12:16 as Exp $
21 source $DIR/function.sh
23 [ -f $DIR/../testing.conf ] || die "!! Configuration file 'testing.conf' not found"
24 [ -d $DIR/../hosts ] || die "!! Directory 'hosts' not found"
26 source $DIR/../testing.conf
30 cecho " * Creating directory '$BUILDDIR'"
34 LOGFILE=${BUILDDIR}/testing.log
38 cecho-n " * Logfile '$LOGFILE' does not exist..creating.."
45 cecho-n " * Creating directory '~/.ssh'.."
50 if [ -f ~/.ssh/known_hosts ]
52 cecho-n " * Backing up ~/.ssh/known_hosts to '~/.ssh/known_hosts.before_uml'.."
53 cp -fp ~/.ssh/known_hosts ~/.ssh/known_hosts.before_uml
56 cecho-n " * Creating '~/.ssh/known_hosts'"
57 touch ~/.ssh/known_hosts
61 for host in $HOSTNAMEIPV4
63 HOSTNAME=`echo $host | awk -F, '{ print $1 }'`
64 IP=`echo $host | awk -F, '{ print $2 }'`
65 if [ `grep "$IP " ~/.ssh/known_hosts | wc -l` != "0" ]
67 cecho "!! Warning: An entry exists for the following IP address: $IP"
69 cecho-n " * Adding uml host $HOSTNAME ($IP) to '~/.ssh/known_hosts'.."
70 echo "$HOSTNAME,$IP `cat $DIR/../hosts/ssh_host_rsa_key.pub`" >> ~/.ssh/known_hosts
75 #####################################
76 # preparing ssh for PK authentication
79 cecho-n " * Checking for ssh rsa key '~/.ssh/id_rsa.pub'.."
80 if [ -f ~/.ssh/id_rsa.pub ]
82 cecho "already exists"
85 cecho-n " * Generating ssh rsa key pair.."
86 echo "" | ssh-keygen -N "" -t rsa -f ~/.ssh/id_rsa >> $LOGFILE 2>&1