I need to generate password hashes on Mac for CentOS. I can generate sha with echo foopass | shasum -a 512, but as I've understood password hashes are more just one sha application.

I've found some one-liners, but looks like they use system crypt function (I've tried some myself), which on Mac only supports DES.

Maybe there are some already implemented on macOS this way?


I decided to use Docker: run image of system where I need to create pass and then run Python code suggested in one-liners.

I got Docker Desktop already, just in case instructions for install.

Then when Docker Desktop running in shell:

$ docker run -it centos:7

Inside running container I decided to also check if hash is generated correctly, so first adding user, then output of it's hash, then generating hash for the given specific salt then finally generating needed number of hashes (for same password):

# adduser test
# passwd test         
Changing password for user test.
New password: 123
BAD PASSWORD: The password is shorter than 8 characters
Retype new password: 123
passwd: all authentication tokens updated successfully.
# cat /etc/shadow | grep test
# yum install python3

...long output and confirming install with y-s.

# python3
>> import crypt
>> print (crypt.crypt("123","$6$msMZIy.A")) # taking part of grep output
>> exec ('for i in range(30):print (crypt.crypt("neededpass",crypt.mksalt(crypt.METHOD_SHA512)))')
...list of 30 hashes for neededpass with ramdom salt
>> exit()
# exit
| improve this answer | |

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .