I'm using busybox with a limited passwd (I don't have --stdin option) and without chpasswd and I need to change the password of an user from bash. Here is my best result:echo newpassword > pwdfileecho newpassword > pwdfilecat pwdfile | passwd myuserChanging password for myuserEnter the new password (minimum of 5, maximum of 8 characters)Please use a combination of upper and lower case letters and numbers.Enter new password:Bad password: too simple.Warning: weak password (continuing).Re-enter new password:passwd: The password for myuser is unchanged.
How to set a new password from bash?
linux;bash;password;pipe
Busybox has chpasswd(8) which is a utility best used to create/update a lot of users very quickly and with one command. It accepts data from STDIN in username:password form. That means that you can do something like this:$ cat pwdfile | chpasswdor$ < pwdfile chpasswdNote that pwdfile must have username:new_password syntax.Then again, you could always edit /etc/shadow yourself -- but please don't.