Creating my first Qemu Arch box and already running into a major provisioners issue: "Password change required"

After having thrown myself into the deep, I’m finally figuring out why my box isn’t building:

When the provisioners try to connect a password change is required.

I don’t know if this is an Linux Arch or some other specific issue, because I don’t see anyone else asking about this.

[folaht@pjehrsohmehj mai-base]$ PACKER_LOG=1 packer build manjaro-arm-installer.pkr.hcl
...
==> manjaro-arm-installer.qemu.main: Provisioning with shell script: scripts/cleanup.sh
2021/08/15 02:52:50 packer-provisioner-shell plugin: Opening scripts/cleanup.sh for reading
2021/08/15 02:52:50 packer-provisioner-shell plugin: [INFO] 435 bytes written for 'uploadData'
2021/08/15 02:52:50 [INFO] 435 bytes written for 'uploadData'
2021/08/15 02:52:50 packer-builder-qemu plugin: [DEBUG] Opening new ssh session
2021/08/15 02:52:50 packer-builder-qemu plugin: [DEBUG] Starting remote scp process:  scp -vt /tmp
2021/08/15 02:52:50 packer-builder-qemu plugin: [DEBUG] Started SCP session, beginning transfers...
2021/08/15 02:52:50 packer-builder-qemu plugin: [DEBUG] Copying input data into temporary file so we can read the length
2021/08/15 02:52:50 packer-builder-qemu plugin: [DEBUG] scp: Uploading script_585.sh: perms=C0644 size=435
2021/08/15 02:52:50 packer-builder-qemu plugin: [DEBUG] SCP session complete, closing stdin pipe.
2021/08/15 02:52:50 packer-builder-qemu plugin: [DEBUG] Waiting for SSH session to complete.
2021/08/15 02:52:50 packer-builder-qemu plugin: [DEBUG] scp stderr (length 83): WARNING: Your password has expired.
2021/08/15 02:52:50 packer-builder-qemu plugin: Password change required but no TTY available.
2021/08/15 02:52:50 packer-builder-qemu plugin: [DEBUG] non-zero exit status: 1, Process exited with status 1
2021/08/15 02:52:50 packer-builder-qemu plugin: [DEBUG] scp output:
2021/08/15 02:52:50 packer-provisioner-shell plugin: Retryable error: Error uploading script: Process exited with status 1
...

Alright, so here’s what I came up with as the solution:

manjaro-arm-installer.pkr.hcl

source "qemu" "main" {  
...
    boot_command           = [
                            "<enter><wait15><wait15><wait15><wait15><wait15>",
                            "/usr/bin/curl -O http://{{ .HTTPIP }}:{{ .HTTPPort }}/enable-ssh.sh<enter><wait5>",
                            "/usr/bin/curl -O http://{{ .HTTPIP }}:{{ .HTTPPort }}/poweroff.timer<enter><wait5>",
                            "/usr/bin/bash ./enable-ssh.sh<enter><wait5>",
                           ]
   ....
    http_directory         = "srv"  
...
}

srv/enable-ssh.sh

#!/usr/bin/env bash

PASSWORD=$(/usr/bin/openssl passwd -crypt 'password')

# Vagrant-specific configuration
/usr/bin/useradd --password ${PASSWORD} --comment 'Vagrant User' --create-home --user-group vagrant
echo -e 'vagrant\nvagrant' | /usr/bin/passwd vagrant 
...

The most important part being that last line because pretty much everything else was copy pasted from packer-arch.