Ubuntu Template Image Preparation and Cloning

About

Just some documentation I use to keep track of how to provision a new, fresh Ubuntu VM template on my homelab. Some values are going to differ in your environment, such as:

Fresh Install of VM

Fresh Ubuntu Installation

Post-install Ubuntu Configuration

VIM Tweaks

While cool, some of the newer VIM plugins that come with Ubuntu can cause unexpected weirdness. Lets tweak the room VIM config so that it's less of a pain when doing a sudo vi

Apparently `sudoedit` is a thing. That loads your personal .vimrc while executing edits as root. In which case, if you use sudoedit, you may want to add these tweaks to your personal ~/.vimrc

Template Image Prep

Set up OpenSSH Key Reconfiguration

If you simply clone an Ubuntu image without resetting the OpenSSH server host keys, an attacker can take those host keys and perform a MITM SSH attack on any system that was cloned from the same image. So we have to make sure those are reset before we make the image, and then automatically regenerated on the next boot.

Clear the Machine ID

Genericize the netplan config

Clear the Bash, VIM, and other history

Shutdown

Create the Template or Image

XCP-NG

Using XOA Xen Orchestra

Cloning to a New VM

XCP-NG

Using XOA Xen Orchestra

Post-Cloning Configuration


Revision #12
Created 9 July 2024 16:07:17 by jholmstadt
Updated 1 October 2024 16:45:59 by jholmstadt