The `kerberos` library provides a high-level Python wrapper for Kerberos (GSSAPI) operations, specifically designed for client/server Kerberos authentication based on RFC 4559. It directly wraps the underlying Kerberos 5 C API, offering a limited set of functions for this purpose. The current version is 1.3.1, and it maintains an active release cadence.
pip install kerberosVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates the very basic client-side initialization of a Kerberos GSSAPI context using `kerberos.authGSSClientInit` and `kerberos.authGSSClientStep`. A real Kerberos environment with a Key Distribution Center (KDC), a configured service principal name (SPN), and an active Kerberos ticket (obtained via `kinit`) is required for successful operation. The process typically involves multiple `authGSSClientStep` calls, exchanging tokens with a server.
Ensure your environment is running Python 3.9 or newer. Consider using a virtual environment to manage Python versions.
Install required system packages before `pip install kerberos`. For Debian/Ubuntu, this is typically `python3-dev libkrb5-dev gcc`. For RHEL/Fedora, `python3-devel krb5-devel gcc`. macOS and Windows users installing from wheels might bypass this, but source installs will require it.
Avoid `checkPassword` in production. Implement proper GSSAPI-based authentication flows or use higher-level libraries like `requests-kerberos` or `python-gssapi` that handle security correctly.
For common HTTP Kerberos authentication, consider `pip install requests-kerberos`. For a more comprehensive and Python-friendly GSSAPI interface, explore `pip install gssapi`.
Verify Kerberos configuration (`/etc/krb5.conf`), ensure a valid ticket exists (`klist`), and confirm the SPN matches the service being accessed. Debug with Kerberos logging if available.
Install the necessary system-level development packages. For Debian/Ubuntu: `sudo apt-get install gcc python3-dev libkrb5-dev`. For Red Hat/CentOS: `sudo dnf install gcc python3-devel krb5-devel`.
Install the package using pip: `pip install kerberos`. Ensure that you are installing it into the correct Python environment where your application is running.
Before running your Python script, obtain a Kerberos ticket using the `kinit` command (e.g., `kinit youruser@YOUR.REALM`). Verify the ticket's presence and validity with `klist`. Additionally, ensure your system's `krb5.conf` file is correctly configured for your Kerberos realm.