
iro.nto.etc.local.d.00-iro-nto-ssh-key.start Maven / Gradle / Ivy
The newest version!
# /etc/local.d/00-iro-nto-ssh-key.start
# Based on /etc/conf.d/local.start from Trier Family's AMI (ami-8b8a6fe2)
# Based on http://ec2ubuntu.googlecode.com/svn/trunk/etc/init.d/ec2-get-credentials
# make sure this user exists
user=iro
ssh_home=/$user/.ssh
public_key_url=http://rio.objectos.com.br/iro/nto/ssh-key
public_key_file=/tmp/openssh_id.pub
authorized_keys=$ssh_home/authorized_keys
# Try to get the ssh public key from instance data.
wget --quiet -O $public_key_file $public_key_url
test -d $ssh_home || mkdir -p -m 700 $ssh_home
if [ $? -eq 0 -a -e $public_key_file ] ; then
if ! grep -s -q -f $public_key_file $authorized_keys
then
cat $public_key_file >> $authorized_keys
$logger "New ssh key added to $authorized_keys from $public_key_url"
fi
chmod 600 $authorized_keys
rm -f $public_key_file
fi
# Ensure root created dirs belong to correct user
chown -R $user. $ssh_home
# random user password
usermod -p `dd if=/dev/urandom count=50 2> /dev/null | md5sum | cut -d " " -f1-1` $user
© 2015 - 2025 Weber Informatics LLC | Privacy Policy