molecules/remaster/ec2_image/ec2.start
2012-07-21 17:16:26 +02:00

17 lines
428 B
Bash
Executable File

#!/bin/sh
# Setup Amazon EC2 provided SSH key
ssh_root=/root/.ssh
if [ ! -d "${ssh_root}" ] ; then
mkdir "${ssh_root}"
fi
chmod 700 "${ssh_root}"
# As documented in http://awsdocs.s3.amazonaws.com/EC2/latest/ec2-ug.pdf
wget -q -O - http://169.254.169.254/latest/meta-data/public-keys/0/openssh-key > /tmp/openssh-key
if [ "${?}" = "0" ]; then
cat /tmp/openssh-key >> "${ssh_root}"/authorized_keys
fi
rm -f /tmp/openssh-key