Ok, so I got sick of looking up the details when was building a new server … so I did it once and wrote a new script for the guest:

!/bin/bash
sudo apt install -y linux-headers-$(uname -r) build-essential dkms
mkdir -p /media/cdrom
mount /dev/cdrom /media/cdrom
cd /media/cdrom
./VBoxLinuxAdditions.run
cd ~
umount /dev/cdrom