busybox passwd script run failed

72 Views Asked by At

busybox passwd can't use --stdin option, when i excute passwd,it need to input password twice, i want to write a shell script to change auto because some reason. i do passwd manual,it works fine。 your textbut when i write a script like this

#!/bin/sh
passwd << EOF
<new password>
<new password>
EOF

when i sh this script,the result is password for root is unchanged. is there some wrong,i am a shell rookie,hope someone can help me,thank you!

i want sh script success!

1

There are 1 best solutions below

2
Maxjr2 On

While it is possible you just need to add a line with the current pass, THIS IS VERY DANGEROUS especially for the root user.

the script would look like this:

#!/bin/sh
passwd << EOF
<current pass>
<new pass>
<new pass>
EOF

there is probably a much safer methode to do the thing you want to do, feel free to send me a message.