How to use homectl in a script (not interactive)

I’m writting a script to be activated at first boot to create a user managed my systemd-homed, and I can’t find a way to make it not interactive.

When homectl create.. is executed, it asks for the password of the user being created. Is there a way to skip this request or set the password in some other way?

man homectl

--password-change-now=BOOL
           Takes a boolean argument. If true the user is asked to change their password on next login.

Something like this?

1 Like

I figured it out.

I just needed to include the password as part of the JSON identity file.

 "secret" : {
        "password" : [
            "my-password"
        ]
    }

The solution above only applies to homectl create though. I’m still looking to activate the user without having to type a password when homectl activate
is executed.

You mean log in the user without password?

This is not secure. You would let him create a password and then apply auto login. So the user is not without a password.

sudo NEWPASSWORD="1234" \
homectl create --password-change-now=true sigulete

@sigulete, I have mines on a systemd service file for simplicity.