|
|
@ -16,18 +16,24 @@
|
|
|
|
# limitations under the License. #
|
|
|
|
# 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
|
|
|
|
[ -z "${SSH_PUBLIC_KEY}${EC2_PUBLIC_KEY}" ] && exit 0
|
|
|
|
|
|
|
|
|
|
|
|
mkdir -m0700 -p /root/.ssh
|
|
|
|
mkdir -m0700 -p /root/.ssh
|
|
|
|
|
|
|
|
|
|
|
|
echo -n '' > /root/.ssh/authorized_keys
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if [ -n "$SSH_PUBLIC_KEY" ]; then
|
|
|
|
if [ -n "$SSH_PUBLIC_KEY" ]; then
|
|
|
|
echo "$SSH_PUBLIC_KEY" >> /root/.ssh/authorized_keys
|
|
|
|
echo "$SSH_PUBLIC_KEY" | add_keys
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if [ -n "$EC2_PUBLIC_KEY" ]; then
|
|
|
|
if [ -n "$EC2_PUBLIC_KEY" ]; then
|
|
|
|
echo "$EC2_PUBLIC_KEY" >> /root/.ssh/authorized_keys
|
|
|
|
echo "$EC2_PUBLIC_KEY" | add_keys
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
chmod 600 /root/.ssh/authorized_keys
|
|
|
|
chmod 600 /root/.ssh/authorized_keys
|
|
|
|