Created
December 30, 2016 03:10
-
-
Save mrlesmithjr/8670ff7bdcec5ba05b619b46d51da1ea to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
| #grab Ubuntu Codename | |
| codename="$(lsb_release -c | awk {'print $2}')" | |
| #update apt-cache | |
| apt-get update | |
| #Stop services for cleanup | |
| service rsyslog stop | |
| #clear audit logs | |
| if [ -f /var/log/audit/audit.log ]; then | |
| cat /dev/null > /var/log/audit/audit.log | |
| fi | |
| if [ -f /var/log/wtmp ]; then | |
| cat /dev/null > /var/log/wtmp | |
| fi | |
| if [ -f /var/log/lastlog ]; then | |
| cat /dev/null > /var/log/lastlog | |
| fi | |
| #cleanup persistent udev rules | |
| if [ -f /etc/udev/rules.d/70-persistent-net.rules ]; then | |
| rm /etc/udev/rules.d/70-persistent-net.rules | |
| fi | |
| #cleanup /tmp directories | |
| rm -rf /tmp/* | |
| rm -rf /var/tmp/* | |
| #cleanup current ssh keys | |
| rm -f /etc/ssh/ssh_host_* | |
| #add check for ssh keys on reboot...regenerate if neccessary | |
| sed -i -e 's|exit 0||' /etc/rc.local | |
| sed -i -e 's|.*test -f /etc/ssh/ssh_host_dsa_key.*||' /etc/rc.local | |
| bash -c 'echo "test -f /etc/ssh/ssh_host_dsa_key || dpkg-reconfigure openssh-server" >> /etc/rc.local' | |
| bash -c 'echo "exit 0" >> /etc/rc.local' | |
| #reset hostname | |
| cat /dev/null > /etc/hostname | |
| #cleanup apt | |
| apt-get clean | |
| #cleanup shell history | |
| history -w | |
| history -c |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment