I am trying to add my public key to the root account on a qcow2 disk image (CentOS 7 Cloud Image).

The documentation from virt-sysprep says that it supports adding keys, but I cannot seem to successfully add my key.

How is this normally done?

1 Answer 1


This will currently only work with version 1.30.0-ish or higher, it does not work on any current version of ubuntu, unless you build from source.

virt-sysprep -a CentOS-6-x86_64-GenericCloud-1601.qcow2 --root-password password:asd --ssh-inject root:file:/root/my.key.pub

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .