Interview Prep/Linux/Patching, Automation & Golden Images

What must you clean up before capturing an image?

AdvancedProductionPatching, Automation & Golden Images
Answer
sudo cloud-init clean --logs --machine-id   # reset cloud-init state and machine-id
sudo truncate -s0 /etc/machine-id
sudo rm -f /etc/ssh/ssh_host_*              # regenerated on first boot
sudo rm -rf /tmp/* /var/tmp/* /root/.ssh/authorized_keys /home/*/.bash_history
sudo journalctl --rotate && sudo journalctl --vacuum-time=1s

Duplicate machine-ids break DHCP client IDs, journald and some monitoring agents; duplicate SSH host keys make every server look identical to an attacker.

All Linux questions Roadmap: Linux

More on Patching, Automation & Golden Images