Created
January 6, 2012 21:03
-
-
Save weavenet/1572391 to your computer and use it in GitHub Desktop.
Script to cleanup RHEL5 instance before creating AMI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
USER=ec2-user | |
echo 'Removing host keys' | |
sudo /bin/rm -rf /etc/ssh/ssh_host*_key* | |
echo 'Removing ec2-user' | |
userdel -f $USER ; /bin/rm -rf /home/$USER | |
echo 'Cleaning up /var/log' | |
/bin/cp /dev/null /var/log/secure | |
/bin/cp /dev/null /var/log/messages | |
/bin/cp /dev/null /var/log/dmesg | |
/bin/cp /dev/null /var/log/wtmp | |
/bin/cp /dev/null /var/log/lastlog | |
/bin/cp /dev/null /var/log/cron | |
/bin/rm /var/log/*.log | |
echo 'Removing faillog' | |
/usr/bin/faillog -r | |
echo 'Removing bash_history' | |
export HISTSIZE=0 | |
/bin/rm /root/.bash_history | |
echo 'Removing everything from /root' | |
/bin/rm -r /root/* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment