How to change user password in script with busybox and openssl?

I need to synchronize the user account and password with an external source on a system with busybox and openssl installed. When an external source tells my system to update credentials, how do I change the user password in a script? I will have a password in plain text.

This needs to be automated, and from what I can tell, busybox passwd is interactive, and I really don't want to write the www1 type for wwwwww, if possible. It looks like openssl can generate password hashes (openssl passwd -1 -salt "abcdefgh" {password}), but do I need to directly change / etc / shadow?

Busybox has these commands available.

+6
linux openssl busybox change-password
source share
2 answers

You can write a small script like this to update the password. Put the following text in the file and execute it. It will change your password.

#! / Bin / w
passwd <EOF
<old password>
<new password>
<new password>
Eof

+6
source share

Turns off current versions of busybox chpasswd ( source ). chpasswd uses a username with a colon password: the password for stdin. I do not know if I can update busybox on my system, but I will leave this answer in case someone else takes a look.

From busybox documentation:

chpasswd chpasswd [--md5|--encrypted] Read user:password from stdin and update /etc/passwd Options: -e,--encrypted Supplied passwords are in encrypted form -m,--md5 Use MD5 encryption instead of DES 
+5
source share

All Articles