Re: Unable to set root password with clear text using preseed/early_command
On Tue, Feb 15, 2022 at 08:08:08PM +0800, Glen Huang wrote:
> Hi,
>
> I want to set the root password to a random string. this is the preseed I use:
>
> d-i preseed/early_command string \
> pw="$(tr -dc A-Za-z0-9 </dev/urandom | head -c 24)"; \
> debconf-set passwd/root-password "$pw"; \
> debconf-set passwd/root-password-again "$pw"
>
> However, the installer still prompts me for the root password.
>
> Setting the crypted password works though:
>
> d-i preseed/early_command string \
> debconf-set passwd/root-password-crypted '<crypted-string>'
>
> Directly setting the password also works:
>
> d-i passwd/root-password password r00tme
> d-i passwd/root-password-again password r00tme
>
> From https://sources.debian.org/src/user-setup/1.88/user-setup-ask/#L36,
> it seems the installer will ask for the root password if
> root-password-crypted is empty or !. My guess is that in the direct
> version, somehow root-password-crypted gets a corresponding value when
> only root-password and root-password-again are set, but I couldn't
> find the code responsible for that.
>
> I'd be grateful if anyone could shed some light.
>
Completely UNtested, a.k.a. sharing a thought:
d-i preseed/early_command string \
tr -dc A-Za-z0-9 </dev/urandom | head -c 24 > /tmp/pw ; \
cat /tmp/pw | debconf-set passwd/root-password - ; \
cat /tmp/pw | debconf-set passwd/root-password-again -
Groeten
Geert Stappers
Not knowing how much of the early_command_string gets into log file.
--
Silence is hard to parse
Reply to: