Pluggable AuthorizedKeysCommand provider for OpenSSH (file/HTTP/LDAP sources, TTL cache, optional key server)
Project description
authkeys
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 underpath, 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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file authkeys-0.4.0.tar.gz.
File metadata
- Download URL: authkeys-0.4.0.tar.gz
- Upload date:
- Size: 45.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a47ea04e309d904e6e282d41b22a4f4dc259391d8c4b76f27cfa0fd797e53d3
|
|
| MD5 |
feef9e50efea62e618e8762d37865845
|
|
| BLAKE2b-256 |
41d5581e97cb03f8323ab2b3c962c3a558246518af23fe91cbb0086cb6d6a9eb
|
Provenance
The following attestation bundles were made for authkeys-0.4.0.tar.gz:
Publisher:
release.yml on jose-pr/authkeys
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
authkeys-0.4.0.tar.gz -
Subject digest:
7a47ea04e309d904e6e282d41b22a4f4dc259391d8c4b76f27cfa0fd797e53d3 - Sigstore transparency entry: 2206700438
- Sigstore integration time:
-
Permalink:
jose-pr/authkeys@dbafe07cf3490a6fc9660e9e41ed1888a6dc9506 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/jose-pr
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@dbafe07cf3490a6fc9660e9e41ed1888a6dc9506 -
Trigger Event:
push
-
Statement type:
File details
Details for the file authkeys-0.4.0-py3-none-any.whl.
File metadata
- Download URL: authkeys-0.4.0-py3-none-any.whl
- Upload date:
- Size: 27.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9eb3c514781d09d0910cede86eacfba2e6d0170fc368de94495b525b3622bef4
|
|
| MD5 |
3a53cfd95be1155dc5d3f52986fe15a7
|
|
| BLAKE2b-256 |
cdf9e1e34a7c4f52157774b6be43d940e82e7448f160bb18ac0591320d057c07
|
Provenance
The following attestation bundles were made for authkeys-0.4.0-py3-none-any.whl:
Publisher:
release.yml on jose-pr/authkeys
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
authkeys-0.4.0-py3-none-any.whl -
Subject digest:
9eb3c514781d09d0910cede86eacfba2e6d0170fc368de94495b525b3622bef4 - Sigstore transparency entry: 2206700451
- Sigstore integration time:
-
Permalink:
jose-pr/authkeys@dbafe07cf3490a6fc9660e9e41ed1888a6dc9506 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/jose-pr
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@dbafe07cf3490a6fc9660e9e41ed1888a6dc9506 -
Trigger Event:
push
-
Statement type: