Updated: 28 September 2026 · Applies to: Ubuntu 24.04, Debian 12, AlmaLinux 9 and Rocky Linux 9

Cloud images (qcow2) usually have no password, so you need to add an SSH key before the first boot. virt-sysprep (or virt-customize) can do that without starting the image.

1. Install the tools

dnf install guestfs-tools         # AlmaLinux / Rocky 9
apt install libguestfs-tools      # Ubuntu / Debian

2. Download a cloud image

cd /var/lib/libvirt/images
wget https://repo.almalinux.org/almalinux/9/cloud/x86_64/images/AlmaLinux-9-GenericCloud-latest.x86_64.qcow2
# Ubuntu 24.04: https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.img

3. Add your key

virt-sysprep -a AlmaLinux-9-GenericCloud-latest.x86_64.qcow2 \
  --ssh-inject root:file:/root/.ssh/id_ed25519.pub \
  --hostname vm1 --selinux-relabel

Use --ssh-inject user:file:path for another user (the user must exist in the image). Leave out --selinux-relabel for Ubuntu and Debian images.

4. Boot it

virt-install --name vm1 --memory 2048 --vcpus 2 --import \
  --disk AlmaLinux-9-GenericCloud-latest.x86_64.qcow2 --osinfo almalinux9 --graphics none

Note: Cloud images also run cloud-init at boot. If you do not provide cloud-init data, boot may pause while it looks for a data source; you can also let virt-install pass the key through cloud-init instead of virt-sysprep: --cloud-init root-ssh-key=/root/.ssh/id_ed25519.pub.

Related services

KVM VPS hosting

NVMe SSD and full root access, with Free Basic Managed Support.

Unmanaged dedicated servers

full root access and free IPMI KVM, with Free Basic Managed Support.

Managed dedicated servers

our engineers look after the server for you, from $135 a month.

Was this answer helpful?

Still stuck? Open a ticket