Skip to main content

authkeys

PyPI version Python versions Documentation License: MIT

A pluggable OpenSSH AuthorizedKeysCommand provider. It resolves a user's authorized SSH keys from one or more configured sources — local key files, an HTTP endpoint, or LDAP-stored X.509 certificates — with optional TTL caching, user/group aliasing, and a small unattended HTTP key server for hosts that fetch keys centrally.

Built on the duho declarative CLI framework.

Install

pip install authkeys            # core (file source only)
pip install authkeys[http]      # + HTTP source (requests)
pip install authkeys[ldap]      # + LDAP cert source (ldap3, cryptography)
pip install authkeys[all]       # everything

authkeys targets POSIX systems (it reads the system user/group databases via pwd/grp). The package imports on any platform for testing, but resolution requires a POSIX host.

Usage

authkeys resolve alice          # print alice's authorized keys
authkeys alice                  # 'resolve' is the default command
authkeys serve --bind 0.0.0.0 --port 8090

Wire it into sshd_config:

AuthorizedKeysCommand /usr/bin/authkeys resolve %u
AuthorizedKeysCommandUser nobody

Configuration

authkeys reads (in order) /etc/authkeys.conf, /etc/authkeys/authkeys.conf, /etc/ssh/authkeys.conf, or a colon-separated list passed with --config. A per-user ~/.ssh/authkeys.conf may authorize additional users/groups. See examples/authkeys.conf for a fully commented example.

[cache]
backend = authkeys.cache.AuthKeysCacheMemBackend
expire = 3600
expired_on_error = 1

[source:files]
backend = authkeys.sources.authorizedkeys
paths =
    authorized_keys
    authorized_keys2

[source:ldap]
enabled = 1
backend = authkeys.sources.ldap
server = ldaps://ldap.example.com:636
basedn = o=Example,c=US

Sources

Alias (backend =) Reads keys from Extra dep
authkeys.sources.authorizedkeys ~/.ssh/authorized_keys* files
authkeys.sources.http an HTTP URL ({username} templated) requests
authkeys.sources.ldap X.509 certs in an LDAP directory ldap3, cryptography

Each [source:<name>] section supports enabled and cached (both default true) and an optional sanitize callable to rewrite/drop keys.

Caching

  • AuthKeysCacheMemBackend — per-process, in-memory (default).
  • AuthKeysCacheFileBackend — on-disk under path, shared across invocations.

With expired_on_error = 1, a source failure falls back to the last-known (expired) cached keys instead of returning nothing — useful when the SSH login must not be blocked by a transient LDAP/HTTP outage.

User / group aliasing

A per-user ~/.ssh/authkeys.conf may grant other principals' keys:

[authorized]
users =
    alice
    bob
groups =
    admins

HTTP key server (authkeys serve)

For hosts that can't run the command locally, authkeys serve exposes the same resolution over HTTP:

GET /keys?username=alice&apikey=<key>

Bind address, port, path, and API key come from the [serve] config section (or --bind/--port). The API key is compared in constant time; pull it from the environment with api_key = ${env:AUTHKEYS_APIKEY} to keep it off disk. If no API key is configured, authentication is disabled — only bind to a trusted interface in that case.

License

MIT — see LICENSE.

Download files

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

Source Distribution

authkeys-0.4.1.tar.gz (50.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

authkeys-0.4.1-py3-none-any.whl (35.0 kB view details)

Uploaded Python 3

File details

Details for the file authkeys-0.4.1.tar.gz.

File metadata

  • Download URL: authkeys-0.4.1.tar.gz
  • Upload date:
  • Size: 50.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for authkeys-0.4.1.tar.gz
Algorithm Hash digest
SHA256 be8cd9db36e77e1e31d350524c14867677a0eff5872225ed7e6be55cba38917f
MD5 5fe74a793c2c2f5bf0eba4fcc465e709
BLAKE2b-256 4b777715fc4a2099542c49740670d12f39b20d99407fe9c0074234a8be772b93

See more details on using hashes here.

Provenance

The following attestation bundles were made for authkeys-0.4.1.tar.gz:

Publisher: release.yml on jose-pr/authkeys

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file authkeys-0.4.1-py3-none-any.whl.

File metadata

  • Download URL: authkeys-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 35.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for authkeys-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4b7f9e20262096115f959c9b9dfd93247ac5f2034c8ac0329bb1f8fbe3def31d
MD5 e059d06b11a9cde356581f30e6af628e
BLAKE2b-256 e8f99109e0b896a2d5308b48ef9324772273f68f71e8e8ea7d328e709e8f0761

See more details on using hashes here.

Provenance

The following attestation bundles were made for authkeys-0.4.1-py3-none-any.whl:

Publisher: release.yml on jose-pr/authkeys

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.4.3

2 files

0.4.2

2 files

This release

0.4.1 This release

2 files

0.4.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page