Update password for Busybox system

On SMP865x board, passowrd is managed with “/etc/shadow” file by Busybox (crypt(3), MD5).

Here is how to update the password (On Debian only, Slackware doesn’t support it):

mkpasswd -5 -s 'YourPassWord'

Then use the output update /etc/shadow file.

And here is a python command for the same purpose too (Python 2.x. If using Python 3.x, replace print to print()):

python -c 'import crypt; print crypt.crypt("YOURPASS", "$1$YOURSALT")'

From http://serverfault.com/questions/330069/how-to-create-an-sha-512-hashed-password-for-shadow , we can change it for more purpose.

6 is the type of hash for SHA-512

  • 1 -> MD5
  • 2a -> Blowfish (not in mainline glibc; added in some Linux distributions)
  • 5 -> SHA-256 (since glibc 2.7)
  • 6 -> SHA-512 (since glibc 2.7)

I’d recommend you look up what salts are and such and as per smallclamgers comment the difference between encryption and hashing.

Update: The string produced is suitable for shadow and kickstart scripts.

To use the python script on Slackware automatically, I use mkpasswd to generate random salt (Only Slackware supported. It doesn’t work on Debian):

python -c 'import crypt; import os; print crypt.crypt("YOURPASS", "$1$" + os.popen("mkpasswd").read())'

I did not found a way working on every OS. —- It seems that I should learn more about crypt.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s