Skip to content
Advertisement

Script to generate MD5 hash with openssl

I’m trying to generate some MD5 hashes with openssl for use with chpasswd

Ex. CSV file:

JavaScript

Script I created:

JavaScript

However, if I take any MD5 generated from this script and try to use it with chpasswd it does not work.

JavaScript

This password will fail

If I try to do this without the script by hand it works:

JavaScript

Advertisement

Answer

Your CSV file probably has carriage returns which is being included as part of the password field (it’s the final field).

Be sure to run dos2unix or use tr -d 'r' on your CSV before processing it.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement