I am building a script to fully automate a VPS setup, and I need to change the root password. I would like to avoid typing it as the script is running through SSH.
Is there a way to redirect an arbitrary value to the input of passwd command?
EDIT
I know for passwd < passwd_file.txt containing the password twice... I would like to know if there is a more elegant way as it seems a little bit clumsy to use a temp file for this purpose.
usermod -p '*' root, and setup SSH key-based authentication?