python-pam
Python PAM module using ctypes, py3
What it is and what it does
python-pam is a ctypes-based wrapper around the Linux PAM (Pluggable Authentication Modules) library, allowing Python code to authenticate users against system credentials. It exposes PAM's authentication flow through a simple API: create an authenticator object, call authenticate() with a username and password, and receive a boolean result plus error codes and reason strings.
The package is designed for system administration and security-focused applications that need to verify user credentials against the system's authentication stack (typically /etc/shadow via pam_unix.so). It has no external runtime dependencies and runs on any Linux/POSIX system with PAM installed. Authentication is subject to privilege constraints: unprivileged code can only verify the current user's credentials, while privileged (root) code can verify any user.
Use it for:
- Authenticate users in a Python web application or service against system accounts without reimplementing password verification
- Build system administration tools that need to verify user credentials as part of access control logic
- Integrate PAM authentication into Python-based login or privilege-escalation workflows
- Verify user identity in containerized or virtualized environments where system PAM is available
- Test PAM service configurations programmatically by authenticating against different PAM services
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Python wrapper for Linux PAM (Pluggable Authentication Modules) that authenticates users against system credentials using ctypes bindings.
Yes, if you need to authenticate against Linux system credentials and are comfortable with the privilege model and platform constraints. The package is mature, permissively licensed, has no dependencies, and carries no known vulnerabilities. The 1610-day gap since last release is notable but not disqualifying given the stable nature of PAM itself; verify that ctypes bindings remain compatible with your target systems before deploying.
Install
python-pam on PyPI
pip
pip install python-pamuv
uv add python-pampoetry
poetry add python-pamInstalling python-pam
Before you install
Low install friction with no runtime dependencies. Marked as mature and actively maintained with recent commits, though last release was in 2022.
License in practice
MIT license (permissive) — you can use, modify, and distribute this package freely in commercial or private projects with minimal restrictions.
Quickstart
pip install python-pam
import pam
p = pam.authenticate()
result = p.authenticate('username', 'password')
print(result) # True if successful, False otherwise
Linux/POSIX system only (not Windows). Requires PAM libraries installed on the system. Privilege constraints apply: without root, you can only authenticate the current user; with root, you can authenticate any user.
Verify before relying
- Whether the package works with modern Python versions beyond 3.9 (classifiers list Python 2 and 3 generically)
- Current state of ctypes bindings compatibility with recent glibc/PAM versions
- Whether the 1610-day gap since last release indicates maintenance concerns or stable maturity
Package facts
| License | License :: OSI Approved :: MIT License (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 1,610 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 2,335,539/month — #3,128 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: python_pam-2.0.2-py3-none-any.whl
Tags
More Security packages
Provides Python bindings to the FreeDesktop.org…
permissive · top 1,000 on PyPI
msalMSAL for Python handles OAuth2 and OpenID…
permissive · top 1,000 on PyPI
joserfcjoserfc implements JOSE standards (JWS, JWE,…
permissive · top 1,000 on PyPI
AuthlibAuthlib provides a complete implementation of…
permissive · top 1,000 on PyPI
argon2-cffi-bindingsProvides low-level CFFI bindings to the…
permissive · top 1,000 on PyPI
adalADAL for Python authenticates applications with…
permissive · top 1,000 on PyPI
pamelaPamela provides a Python interface to the…
permissive · top 15,000 on PyPI
httpx-ntlmAdds NTLM authentication support to HTTPX,…
permissive · top 15,000 on PyPI
docker-pycredsProvides Python bindings to interact with…
permissive · top 5,000 on PyPI
pyseccomppyseccomp provides a pure-Python interface to…
permissive · top 5,000 on PyPI
pure-python-adbPure-Python ADB client that communicates with…
permissive · top 15,000 on PyPI
google-cloud-privilegedaccessmanagerPython client library for Google Cloud…
permissive · top 15,000 on PyPI
siweImplements EIP-4361 Sign-In with Ethereum for…
permissive · top 15,000 on PyPI
wsgidavWsgiDAV is a WebDAV server implementation in…
permissive · top 15,000 on PyPI
pyspnegoHandles SPNEGO, NTLM, Kerberos, and CredSSP…
permissive · top 1,000 on PyPI
requests-ntlm2Adds NTLM authentication support to the…
permissive · top 15,000 on PyPI