rc_local

Path: lib/boxgrinder-build/plugins/platform/ec2/src/rc_local
Last Update: Wed Apr 27 16:37:28 +0000 2011

curl 169.254.169.254/2009-04-04/meta-data/public-keys/0/openssh-key 2>/dev/null >/tmp/my-key

if [ $? -eq 0 ] ; then

   for home in `find /home/* -maxdepth 0 -type d 2>/dev/null | tr '\n' ' '`; do
       user=`echo $home | awk -F '/' '{ print $3 }'`

       if [ ! -d $home/.ssh ] ; then
            mkdir -p $home/.ssh
            chmod 700 $home/.ssh
            chown $user $home/.ssh
        fi

       cat /tmp/my-key >> $home/.ssh/authorized_keys
       chmod 600 $home/.ssh/authorized_keys
       chown $user $home/.ssh/authorized_keys

   done
   rm /tmp/my-key

fi

[Validate]