0

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!

Linn
  • 1
  • 1

1 Answers1

0

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.

Maxjr2
  • 1
  • 2
  • thank you for your reply, the script your answed i also tried,the result is failed as same,and when i type passwd in shell,it only let me input new pass。 – Linn Jan 30 '23 at 00:38
  • i try this script in another machine,the command passwd also busybox.it works fine. i think the problem is the Embedded system self。 – Linn Jan 30 '23 at 09:03