Skip to content

Instantly share code, notes, and snippets.

@aabenitez
Last active September 23, 2021 18:21
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 aabenitez/45148bc92bb582c5fce0c16ffc2c9e56 to your computer and use it in GitHub Desktop.
Save aabenitez/45148bc92bb582c5fce0c16ffc2c9e56 to your computer and use it in GitHub Desktop.
Seal for clean a VM (machine-id and users log data) for Proxmox - Ubuntu 18.04+
#!/bin/bash
# /usr/local/sbin/vm-seal.sh
unset HISTFILE
apt-get update -y
apt-get upgrade -y
> /etc/machine-id
hostnamectl set-hostname localhost.localdomain
rm -f /etc/ssh/ssh_host_*
rm -rf /root/.ssh/
rm -f /root/.bash_history
rm -f /var/log/boot.log
rm -f /var/log/cron
rm -f /var/log/dmesg
rm -f /var/log/grubby
rm -f /var/log/lastlog
rm -f /var/log/maillog
rm -f /var/log/messages
rm -f /var/log/secure
rm -f /var/log/spooler
rm -f /var/log/tallylog
rm -f /var/log/wpa_supplicant.log
rm -f /var/log/wtmp
rm -f /var/log/apt/term.log
rm -f /var/log/audit/audit.log
rm -f /var/log/tuned/tuned.log
sys-unconfig
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment