voltagex
(Adam)
December 17, 2023, 6:23am
1
Hi,
My Home Assistant OS install is in a qemu VM. I’d like to enable SSH to the host as my other access is via a slightly fragile serial console.
Yes, I know about Debugging the Home Assistant Operating System | Home Assistant Developer Docs
No, it’s not simple to “plug a USB drive” into the VM.
What’s ha os import doing behind the scenes?
Edit:
From serial terminal (VM console):
cat > /root/.ssh/authorized_keys
#(enter key, ctrl+D)
systemctl start dropbear
Via looking at the ConditionFileNotEmpty setting here:
1 Like
wmaker
(Tommy Long)
December 17, 2023, 7:29pm
2
Since your VM “console” works…
A trick I have used is to take the “authorized_keys” file that one can generate off-line and copy it into say HA’s “share” folder. From the VM Console (HAOS shell) you can get to the “share” folder at /mnt/data/supervisor/share/. So just copy authorized_keys file into /root/.ssh/authorized_keys
1 Like
voltagex
(Adam)
December 17, 2023, 9:51pm
3
Thanks Tommy. My edit works as well, the key piece is that dropbear won’t start until authorized_keys is in place.
90210
May 23, 2025, 7:54am
4
Adding my method for anyone else who is interested. I created a virtual USB drive and attached it to my libvirt (kvm) haos installation
First: create the image:
dd if=/dev/zero of=usb.img bs=1M count=4096
sudo losetup -f -P usb.img
sudo mkfs.vfat -n CONFIG /dev/loop0p1
sudo mount /dev/loop0p1 /mnt/tmp
cat ~/.ssh/id_rsa.pub | sudo tee /mnt/tmp/authorized_keys
sudo umount /mnt/tmp
sudo losetup -d /dev/loop0
Copy the image to your libvirt storage (probably /var/lib/libvirt/images)
Then, attach the disk through libvirt using virt-manager:
Add hardware → Storage
Select the disk image
Change bus type to USB
My XML looks like:
<disk type='file' device='disk'>
<driver name='qemu' type='raw'/>
<source file='/var/lib/libvirt/images/usb.img'/>
<target dev='sda' bus='usb'/>
<address type='usb' bus='0' port='4'/>
</disk>
ha os import correctly imported this disk and enabled ssh