guestfish
[ qemu shell ]Manipulate qcow2 images with the guest filesystem shell
I recently found this handy tool called guestfish. It is great for manipulating disk images in a precise manner without much workflow overhead.
sudo guestfish --rw --add "my-cool-image.qcow2" -i <<EOF
write /root/.ssh/authorized_keys "$(cat "~/.ssh/id_ed25519.pub")"
upload local_file.txt /etc/foo/bar.txt
EOF