Disable StrictHostKeyChecking when removing keys too

Otherwise subsequent deploys can fail if an IP is reused.

-o UserKnownHostsFile=/dev/null is also added to avoid ugly messages
in the script output because of mismatched hostkeys that we're going
to ignore anyway.

Change-Id: If7eabd5df2ffc29d125c4f65f7fee1b0f4085817
Closes-Bug: 1766924
This commit is contained in:
Ben Nemec 2018-04-25 11:35:06 -05:00
parent 1bec57e977
commit 0edc478348

View File

@ -10,6 +10,7 @@ SUBNODES_SSH_KEY=${SUBNODES_SSH_KEY:-"$HOME/.ssh/id_rsa"}
# this is the intended variable for overriding
OVERCLOUD_SSH_KEY=${OVERCLOUD_SSH_KEY:-"$SUBNODES_SSH_KEY"}
SSH_TIMEOUT_OPTIONS=${SSH_TIMEOUT_OPTIONS:-"-o ConnectionAttempts=6 -o ConnectTimeout=30"}
SSH_HOSTKEY_OPTIONS="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
SHORT_TERM_KEY_COMMENT="TripleO split stack short term key"
SLEEP_TIME=5
@ -57,7 +58,7 @@ for HOST in $OVERCLOUD_HOSTS; do
echo "Inserting TripleO short term key for $HOST"
# prepending an extra newline so that if authorized_keys didn't
# end with a newline previously, we don't end up garbling it up
ssh $SSH_TIMEOUT_OPTIONS -o StrictHostKeyChecking=no -i "$OVERCLOUD_SSH_KEY" -l "$OVERCLOUD_SSH_USER" "$HOST" "echo -e '\n$SHORT_TERM_KEY_PUBLIC_CONTENT' >> \$HOME/.ssh/authorized_keys"
ssh $SSH_TIMEOUT_OPTIONS $SSH_HOSTKEY_OPTIONS -i "$OVERCLOUD_SSH_KEY" -l "$OVERCLOUD_SSH_USER" "$HOST" "echo -e '\n$SHORT_TERM_KEY_PUBLIC_CONTENT' >> \$HOME/.ssh/authorized_keys"
done
echo "Starting ssh admin enablement workflow"
@ -80,7 +81,7 @@ echo # newline after the previous dots
for HOST in $OVERCLOUD_HOSTS; do
echo "Removing TripleO short term key from $HOST"
ssh $SSH_TIMEOUT_OPTIONS -l "$OVERCLOUD_SSH_USER" "$HOST" "sed -i -e '/$SHORT_TERM_KEY_COMMENT/d' \$HOME/.ssh/authorized_keys"
ssh $SSH_TIMEOUT_OPTIONS $SSH_HOSTKEY_OPTIONS -l "$OVERCLOUD_SSH_USER" "$HOST" "sed -i -e '/$SHORT_TERM_KEY_COMMENT/d' \$HOME/.ssh/authorized_keys"
done
echo "Removing short term keys locally"