I’ve had much success with the procedure above. I’ve had to do it for units as well as machines.
For unit:
./juju-generate-password 5e6635fe-ec57-45d8-87d6-c713064112d9 launchpad-mailman/0
For machines:
./juju-generate-password 4d00e10a-0c0c-430c-8fee-7ece72545b99 2
./juju-generate-password 4d00e10a-0c0c-430c-8fee-7ece72545b99 3
Where the version I’m using doesn’t allow me to specify machine-X but just the machine ID.