gh-19: don't overwrite authorized keys

pull/20/head
Javi Fontan 9 years ago
parent a99ce6b1ed
commit e04ab3383f

@ -16,18 +16,24 @@
# limitations under the License. #
#--------------------------------------------------------------------------- #
function add_keys {
while read key; do
if ! grep -q -F "$key" /root/.ssh/authorized_keys; then
echo "$key" >> /root/.ssh/authorized_keys
fi
done
}
[ -z "${SSH_PUBLIC_KEY}${EC2_PUBLIC_KEY}" ] && exit 0
mkdir -m0700 -p /root/.ssh
echo -n '' > /root/.ssh/authorized_keys
if [ -n "$SSH_PUBLIC_KEY" ]; then
echo "$SSH_PUBLIC_KEY" >> /root/.ssh/authorized_keys
echo "$SSH_PUBLIC_KEY" | add_keys
fi
if [ -n "$EC2_PUBLIC_KEY" ]; then
echo "$EC2_PUBLIC_KEY" >> /root/.ssh/authorized_keys
echo "$EC2_PUBLIC_KEY" | add_keys
fi
chmod 600 /root/.ssh/authorized_keys

Loading…
Cancel
Save