I often want to create new users in Linux for testing. Creating new users without interaction can be challenging to automate because the passwd
command provides no way for you to pass in a plain text password. It will prompt you for a password which is OK for interactive sessions but not suitable for automation (e.g. creating new users in Pulumi).
The solution I have found is to pipe the password into the passwd
command like this:
This trick allows you to create new users and set their passwords without interaction!