Update devstack configure_ironic_ssh_keypair

When authorized_file doesn't contain new-line character at the end,
configure_ironic_ssh_keypair() just append new key to the existed line,
as result both keys becomes corrupted. The patch adds a check for
last character in the authorized_key file, if new-line is missed
add it.

Change-Id: I64a7bba5f3c7dee76ae2faf659af1231280f2b8b
Closes-Bug: #1611207
This commit is contained in:
Vasyl Saienko 2016-08-09 08:47:16 +03:00
parent 0cfaf52e99
commit 600e2e4057

@ -1184,6 +1184,10 @@ function configure_ironic_ssh_keypair {
fi
echo -e 'n\n' | ssh-keygen -q -t rsa -P '' -f $IRONIC_KEY_FILE
fi
# NOTE(vsaienko) check for new line character, add if doesn't exist.
if [[ "$(tail -c1 $IRONIC_AUTHORIZED_KEYS_FILE | wc -l)" == "0" ]]; then
echo "" >> $IRONIC_AUTHORIZED_KEYS_FILE
fi
cat $IRONIC_KEY_FILE.pub | tee -a $IRONIC_AUTHORIZED_KEYS_FILE
# remove duplicate keys.
sort -u -o $IRONIC_AUTHORIZED_KEYS_FILE $IRONIC_AUTHORIZED_KEYS_FILE