skillfed

python-pam

Python PAM module using ctypes, py3

python-pam v2.0.2 2.3M downloads/30d#3,128 on PyPI119
Permissive license License :: OSI Approved :: MIT License Active released

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-pam

uv

uv add python-pam

poetry

poetry add python-pam

Installing 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

Development Status :: 6 - MatureEnvironment :: PluginsIntended Audience :: DevelopersIntended Audience :: Information TechnologyIntended Audience :: System AdministratorsLicense :: OSI Approved :: MIT LicenseOperating System :: POSIXOperating System :: POSIX :: LinuxProgramming Language :: PythonProgramming Language :: Python :: 2Programming Language :: Python :: 3Topic :: SecurityTopic :: System :: Systems Administration :: Authentication/Directory

Tags

linux pam authenticationsystem user authentication pythonpam credentials verifylinux password validationpluggable authentication modules pythonunix user authenticationpam service authentication
linux-pamsystem-authctypes-binding

More Security packages