keyctl2
Dependency-free Python bindings for the Linux kernel keyring: add, search, read, describe, link and unlink keys in session and process keyrings, without shelling out to keyctl(1).
Requires Python 3.10+ and Linux. No runtime dependencies: the bindings call add_key(2), request_key(2) and keyctl(2) through ctypes.
Install
pip install keyctl2
Example
import keyctl2
# Add a user key to the session keyring and read it back.
serial = keyctl2.add_key("user", "my-secret", b"hunter2")
key = keyctl2.Key(serial)
assert key.read() == b"hunter2"
# Search the session keyring for it later.
assert keyctl2.search("session", "user", "my-secret") == serial
# Inspect it and clean up.
print(key.describe()) # KeyDescription(type='user', ...)
key.unlink("session")
Development
uv sync --group dev
make check
License: 0BSD. Quad4 Software, https://quad4.io
Release files for keyctl2 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| keyctl2-0.1.0.tar.gz | 68.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| keyctl2-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 79.4 kB
Release files / keyctl2-0.1.0.tar.gz
| Download URL | keyctl2-0.1.0.tar.gz |
|---|---|
| Size | 68.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ddc85ebb642ef3f8b3b57bac10c1b504aa33f74947da0b25260e0b0d86b42a36
|
|
BLAKE2b-256 checksum How to use checksums |
267e1973706c4824679387bb988c1242a8c92049255d279dab5ee56e0d9ec78f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 22, 2026.
Transparency logRelease files / keyctl2-0.1.0-py3-none-any.whl
| Download URL | keyctl2-0.1.0-py3-none-any.whl |
|---|---|
| Size | 10.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b4922edeb12e91f53d826f1272c2b25ca0e1b952d7132ec9ad0d8627f2dba5bf
|
|
BLAKE2b-256 checksum How to use checksums |
4d84a52fdc31429b7298d5e83c08eec24f60561fe09a5302158535cc4919a3d2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 22, 2026.
Transparency log