Linux password manipulation in Python
jkrukoff at ltgc.com
Tue Mar 18 02:43:44 CET 2003
You probably want to look at man 3 crypt. Since every current linux
distribution that I know of uses MD5 sums to encrypt its passwords you
probably need to make use of the bit of magic mentioned near the bottom
of the page (and by another poster talking about perl webmin scripts),
under 'GNU EXTENSION'.
On my box (gentoo):
# grep jkrukoff /etc/shadow
>>> from crypt import crypt
>>> crypt( 'bob', '$1$TR8v8QBY$' )
Where the salt begins with '$1$', is a maximum of eight characters and
is optionally terminated by a '$'. Needless to say, this probably isn't
I would guess that the only way to attempt to work with passwords
portably would probably be to wrap the passwd command. Still, it must be
a difficult problem as I haven't seen a configure script yet that will
create all required users for you... Anybody know a portable way to set
On Mon, 2003-03-17 at 11:30, Gary Herron wrote:
> This may be more of a Linux than Python question, but I'll try asking
> it here first.
> How does one deal with encrypted passwords on a Linux system which
> uses shadow passwords?
> The 'crypt' module has an example in its documentation of encrypting a
> password (and then comparing to the contents of the /etc/passwd file),
> but that example explicitly states it does not support shadow
> passwords. And when I use crypt to encrypt a known password, I do not
> get anything like the contents of the /etc/shadow file.
> Thanks for any help,
> Gary Herron
John Krukoff <jkrukoff at ltgc.com>
Land Title Guarantee Company
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 196 bytes
Desc: This is a digitally signed message part
More information about the Python-list