Skip to main content

Python module to validate the credentials of a Linux user using the /etc/shadow file

Project description

This is a Python module to validate the credentials of a Linux user using the /etc/shadow file.

Please take a look at the full documentation for how to install and use shadow_auth:

How to use Linux Shadow Authentication:

import shadow_auth

if shadow_auth.validate_with_password("username", "1234"):
    # What to do if the user is valid
    pass

if shadow_auth.validate_with_hash("username", "$1$TrOIigLp$FJg1nUqEQPt4OerLOWzr/1"):
    # What to do if the user is valid
    pass

#Get the algorithm and Salt for a User    
password_info = shadow_auth.get_password_info("username")
# password_info = {
#   "algorithm" = "1",
#   "salt" = "TrOIigLp"
# }

#Generate an MD5 hash
new_md5_hash = shadow_auth.generate_openssl_hash(
    algorithm=shadow_auth.Algorithm.MD5,
    salt="TrOIigLp",
    text="abcd12345",    
)
# new_md5_hash = "$1$TrOIigLp$FJg1nUqEQPt4OerLOWzr/1"

#Generate an SHA-256 hash
new_sha_256_hash = shadow_auth.generate_openssl_hash(
    algorithm=shadow_auth.Algorithm.MD5,
    salt="TrOIigLp",
    text="abcd12345",    
)
# new_sha_256_hash = "$5$TrOIigLp$6usEDvu0NgyuQ/IqQyvSBoP0x2RiNOz5izrMViHwXv2"

#Generate an SHA-512 hash
new_sha_512_hash = shadow_auth.generate_openssl_hash(
    algorithm=shadow_auth.Algorithm.MD5,
    salt="TrOIigLp",
    text="abcd12345",    
)
# new_sha_512_hash = "$6$TrOIigLp$IU0KwZfzVkuLLy/9vMFH1RgOmqE3LAGk0K9/15WOGStkeaN2IWYkY0jzCWHMUcSnnewnt9bOUwD2vStgko79v/"

Project details


Release history Release notifications

This version

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for shadow-auth, version 0.1
Filename, size File type Python version Upload date Hashes
Filename, size shadow_auth-0.1-py3-none-any.whl (11.8 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size shadow_auth-0.1.tar.gz (6.3 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page