summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzhouya <zhou.ya@zte.com.cn>2016-12-26 20:59:03 +0800
committerZhou Ya <zhou.ya@zte.com.cn>2016-12-30 11:36:39 +0800
commit46760a744f279b1d81b8af5debcdd958f0961b38 (patch)
tree2ba12cf1be2650b796376f1edb6028dc63e4c1fd
parent8752e2341e766f547377ac184f3e338613491162 (diff)
solve no file of known_hosts bug
Change-Id: If70e8765709d49a22a4f6c17ab4e2c4589fbf05a Signed-off-by: zhouya <zhou.ya@zte.com.cn>
-rwxr-xr-xci/deploy/deploy.sh2
-rwxr-xr-xdeploy/trustme.sh17
2 files changed, 14 insertions, 5 deletions
diff --git a/ci/deploy/deploy.sh b/ci/deploy/deploy.sh
index a2d18496..91d97784 100755
--- a/ci/deploy/deploy.sh
+++ b/ci/deploy/deploy.sh
@@ -88,7 +88,7 @@ sleep 20
echo "====== install daisy==========="
$deploy_path/trustme.sh $daisy_ip $daisy_passwd
scp -r $WORKSPACE root@$daisy_ip:/home
-
+ssh root@$daisy_ip "touch /root/.ssh/know_hosts"
execute_on_jumpserver $daisy_ip "mkdir -p /home/daisy_install"
update_config $WORKSPACE/deploy/daisy.conf daisy_management_ip $daisy_ip
scp $WORKSPACE/deploy/daisy.conf root@$daisy_ip:/home/daisy_install
diff --git a/deploy/trustme.sh b/deploy/trustme.sh
index eedda5ce..33b76546 100755
--- a/deploy/trustme.sh
+++ b/deploy/trustme.sh
@@ -10,6 +10,11 @@ function print_log
echo -e "`date -d today +"%Y-%m-%d %H:%M:%S"` $promt" >> $logfile
}
ip=$1
+if [ -z $ip ]; then
+ print_log "Usage: `basename $0` ipaddr passwd"
+ exit 1
+fi
+
passwd=$2
if [ -z $passwd ]; then
print_log "Usage: `basename $0` ipaddr passwd"
@@ -47,11 +52,15 @@ host=`hostname`
keyend="$user@$host"
print_log "my keyend = $keyend"
cmd="sed '/$keyend$/d' -i ~/.ssh/authorized_keys"
+local_host="127.0.0.1"
print_log "clear my old pub key on $local_host ..."
-ssh-keygen -f "/root/.ssh/known_hosts" -R $ip
-if [ $? != 0 ]; then
- print_log "delete pub key of $ip from known_hosts failed"
- exit 1
+sshpass -p $passwd ssh -o StrictHostKeyChecking=no $local_host "test -f ~/.ssh/known_hosts"
+if [ $? = 0 ]; then
+ sshpass -p $passwd ssh -o StrictHostKeyChecking=no $local_host "sed -i '/${ip} /d' ~/.ssh/known_hosts"
+ if [ $? != 0 ]; then
+ print_log "delete pub key of $ip from $local_host known_hosts failed"
+ exit 1
+ fi
fi
sshpass -p $passwd ssh -o StrictHostKeyChecking=no $ip "mkdir -p ~/.ssh && touch ~/.ssh/authorized_keys"
if [ $? != 0 ]; then