Skip to content

Instantly share code, notes, and snippets.

@wokamoto
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wokamoto/9907847 to your computer and use it in GitHub Desktop.
Save wokamoto/9907847 to your computer and use it in GitHub Desktop.
[AWS] AMI 作る前に最低限やっておくこと
#!/bin/sh
rm -rf /tmp/*
rm -f /etc/ssh/ssh_host_*
if [ -d /var/log ]; then
find /var/log -type f -print | xargs -L1 /bin/cp /dev/null
fi
if [ -d /var/spool/mail ]; then
find /var/spool/mail -type f -print | xargs -L1 /bin/cp /dev/null
fi
/bin/cp /dev/null /root/.ssh/authorized_keys
/bin/cp /dev/null /root/.bash_history
if [ -f /root/.mysql_history ]; then
/bin/cp /dev/null /root/.mysql_history
fi
if [ -d /home/ec2-user ]; then
/bin/cp /dev/null /home/ec2-user/.ssh/authorized_keys
/bin/cp /dev/null /home/ec2-user/.bash_history
if [ -f /home/ec2-user/.mysql_history ]; then
/bin/cp /dev/null /home/ec2-user/.mysql_history
fi
fi
history -c
echo "clear!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment