Perl code to generate Samba passwd hashes?

John D Blair jdblair at cobaltnet.com
Sat Aug 29 18:51:07 GMT 1998


Marlys Nelson wrote:
> 
> Does anyone have perl code that can generate the Samba passwd hashes
> from a clear text password?
> 
> I'm aware of the smbpasswd command that comes with Samba but that
> isn't the best tool for my purposes.  I have a local account
> creation/deletion software that already handles encypting the password
> to generate unix /etc/passwd files and I need to be able to do the
> same for the Samba passwd file as well.

I needed just such a perl module.  I explored creating a perl module,
but in the end opted to create a simple command-line tool called
'gethash'.  You put your password in the environmental var 'SMBPASSWD'
then run gethash.  It outputs the two password hashes on standard
output.  If you would like it I'll send you a patch file.

For example:

# export SMBPASSWD='mypasswd'
# gethash
74AC99CA40DED4204A3B108F3FA6CB6D:F671043BA08E88500D2EB5279AC65E53

Call this from perl, or any other scripting language for that matter, is
trivial.

later,
 -john.

---------------------------------------------------------------------
John D. Blair                                   jdblair at cobaltnet.com
Software Engineer, Cobalt Networks Inc.      http://www.cobaltnet.com
---------------------------------------------------------------------


More information about the samba mailing list