[Libguestfs] virt-builder: --ssh-inject fails because it is executed before --firstboot-command?

Pino Toscano ptoscano at redhat.com
Tue Dec 5 14:01:17 UTC 2017


Hi,

On Tuesday, 5 December 2017 14:24:42 CET Guido Schmidt wrote:
> Version 1.34.6 (on Debian Stretch)
> 
> Using virt-builder I tried to create a user and inject my ssh key:
> 
> virt-builder -v -x centos-7.4 --output testimage --format qcow2 
> --selinux-relabel --hostname testimage --firstboot-command 'useradd -m 
> -p "" dummy' --firstboot-command 'chage -d 0 dummy' --ssh-inject dummy
> 
> ...
> 
> [  16.1] Installing firstboot command: useradd -m -p "" dummy
> [  16.1] Installing firstboot command: chage -d 0 dummy
> [  16.1] SSH key inject: dummy
> virt-builder: error: ssh-inject: the user dummy does not exist on the guest
> 
> (Full debug output attached)
> 
> Seems like this can never work as the injection is carried out before 
> the first boot. Is this a bug in my version? Or is this limited to users 
> that are already in the image?

The injection of SSH keys (using --ssh-inject) is performed during the
image customization process, i.e. while virt-builder/virt-customize run.
Theoretically it should be possible to create the user directly in this
phase, so the SSH injection works, and then force the password change on
first login (with chage, as you used already).

-- 
Pino Toscano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part.
URL: <http://listman.redhat.com/archives/libguestfs/attachments/20171205/ab3606c3/attachment.sig>


More information about the Libguestfs mailing list