From 7fadae6fe635a56eb03346ae99123548bdbd19f6 Mon Sep 17 00:00:00 2001 From: Paolo Asperti Date: Sat, 7 Mar 2020 22:33:08 +0100 Subject: [PATCH] fix for re-adoption --- root/etc/e-smith/events/actions/client-adopt | 3 ++- root/usr/bin/client-shell | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) mode change 100644 => 100755 root/usr/bin/client-shell diff --git a/root/etc/e-smith/events/actions/client-adopt b/root/etc/e-smith/events/actions/client-adopt index e4f90b1..0cd1764 100644 --- a/root/etc/e-smith/events/actions/client-adopt +++ b/root/etc/e-smith/events/actions/client-adopt @@ -17,6 +17,8 @@ ping -c1 "$HOST" >/dev/null || ( exit 1 ) +ssh-keygen -R "${HOST}" + sshpass -p "${PASS}" ssh -t -o StrictHostKeyChecking=no "${USER}@${HOST}" "whoami" || ( echo "Can't login to $HOST as $USER" exit 1 @@ -35,7 +37,6 @@ if [[ "$AMIROOT" = "" ]]; then fi PUB=$(db configuration getprop client-manager ManagementKeyFile) -ssh-keygen -R "${HOST}" cat $PUB | \ sshpass -p "${PASS}" ssh -t -o StrictHostKeyChecking=no "${USER}@${HOST}" "echo '${PASS}' | sudo -S mkdir /root/.ssh >/dev/null ; sudo tee -a /root/.ssh/authorized_keys" diff --git a/root/usr/bin/client-shell b/root/usr/bin/client-shell old mode 100644 new mode 100755 index b493d8b..6f8e27a --- a/root/usr/bin/client-shell +++ b/root/usr/bin/client-shell @@ -13,4 +13,5 @@ if [ "$USER" = "" ] ; then exit 1 fi +/usr/bin/sudo -u amgmt ssh-keygen -R "${1}" /usr/bin/sudo -u amgmt /usr/bin/ssh -o StrictHostKeyChecking=no ${USER}\@${1} ${@:2}