Skip to main content

agent-access

CLI to grant or revoke agent access to servers (via authorized_keys) and GitHub repos (via collaborator API), driven by a per-project YAML config. It can verify keys and connectivity before changes, print an agent context block after a successful enable, and show status of current access.

Repository: github.com/ajlyakhov/agent-access

Requirements

  • Python 3.10+
  • A master SSH private key that can sign in as each configured Linux user and manage ~/.ssh/authorized_keys
  • A public key file for the agent (one or more lines) to install on servers
  • A master GitHub PAT when resources.github is non-empty: set GITHUB_TOKEN or access.master.github_token (non-empty env wins). Token needs admin on those repos to add/remove collaborators.

Host key policy uses Paramiko’s AutoAddPolicy (equivalent to blindly accepting new hosts). For production use, prime known_hosts or adjust the code if you need stricter SSH host verification.

Install

Install from Git (no clone)

pip install "git+https://github.com/ajlyakhov/agent-access.git"

From PyPI (after publish)

pip install agent-access

From a local folder (this repo on disk)

pip treats a directory as a source tree if it contains pyproject.toml. Use the project root (the folder that has pyproject.toml).

Normal install (copies the package into your environment):

cd /path/to/agent-control
pip install .

You can also pass the path without cd:

pip install /path/to/agent-control

Editable install (code changes apply immediately; best while hacking on the tool):

cd /path/to/agent-control
pip install -e .

With dev dependencies (e.g. pytest, build):

pip install -e ".[dev]"

After any of these, the agent-access command should be on your PATH for that Python environment. You can also run python -m agent_access from any directory.

From a built wheel or sdist

After python -m build, install the file under dist/:

pip install dist/agent_access-0.1.0-py3-none-any.whl
# or
pip install dist/agent_access-0.1.0.tar.gz

Config

Copy config.example.yml into ~/.agent-access/config.yml (create the directory if needed) and edit. The top-level key is the project name you pass on the CLI.

Each server has name, description, and ssh (user@host or user@host:port). Each GitHub entry has name, description, and repo (owner/name). You can still use legacy plain strings for servers (SSH target only) and repos (owner/repo).

Paths under access support ~.

access splits who owns resources vs who receives access:

  • access.master: private_key_path (SSH private key used to manage servers’ authorized_keys); optional github_token (PAT for collaborator API when GITHUB_TOKEN is unset — env wins).
  • access.agent: github_name, pubkey_path, optional github_permission (pull | push | maintain | admin, default push); optional github_token (invitee PAT for auto-accepting repo invitations when AGENT_GITHUB_TOKEN is unset — env wins).

Global CLI option --config PATH defaults to ~/.agent-access/config.yml. It must appear before the subcommand:

agent-access --config /path/to/config.yml verify myproject

Environment

Variable Purpose
GITHUB_TOKEN Optional if access.master.github_token is set. When set and non-empty, wins over config. Required (via either mechanism) for enable / disable / verify / status when GitHub repos are configured.
AGENT_GITHUB_TOKEN Optional. When set, overrides access.agent.github_token. Must belong to access.agent.github_name — used to accept repository invitations automatically after enable (org outside-collaborator flow).

Use a classic PAT with repo scope (or another token that yields permissions.admin: true on GET /repos/{owner}/{repo} for those repositories).

The invitee PAT needs permission to use GET /user and GET/PATCH /user/repository_invitations (classic repo scope is typical).

Organization repos and invitations

For organization-owned repositories, GitHub usually sends a collaborator invitation to access.agent.github_name; they must accept it before git access works — unless you set access.agent.github_token (or AGENT_GITHUB_TOKEN), in which case enable tries to accept pending invites for the configured repos via the GitHub API. verify checks that the invitee token’s GET /user login matches access.agent.github_name. Until accepted, status reports invitation pending. disable revokes active collaborators and cancels pending invitations for that login.

Commands

verify

Validates master and agent key files, SSH to each server (if any), and GitHub token/user/repo admin (if any repos listed). Prints a report to stdout; exit code 0 if all checks pass, 1 otherwise.

# Uses ~/.agent-access/config.yml when --config is omitted
agent-access verify myproject
agent-access --config /path/to/other.yml verify myproject

show

Prints the entire resolved config file to stdout (raw bytes as UTF-8 text). Uses the same --config default as other commands.

agent-access show
agent-access --config /path/to/other.yml show

enable

Runs the same checks as verify (report on stderr), then prompts:

Proceed with enable for project '…'? [y/N]:

Use -y / --yes on the enable or disable subcommand (after the verb) to skip the confirmation prompt (required in non-interactive environments). Then installs agent public keys and adds the GitHub user as a collaborator (and auto-accepts pending repo invitations when access.agent.github_token / AGENT_GITHUB_TOKEN is set). On full success, prints the AGENT_ACCESS_CONTEXT block on stdout for pasting into the agent.

agent-access enable myproject
agent-access enable -y myproject

disable

Same verification and confirmation flow as enable, then removes keys and removes the collaborator.

agent-access disable myproject -y

status

Shows whether agent keys appear in each host’s authorized_keys and collaborator permission on each repo (GitHub skipped if neither GITHUB_TOKEN nor access.master.github_token is set).

agent-access status myproject

Exit codes

Code Meaning
0 Success
1 Error or verification / operation failure
2 User cancelled enable / disable at the confirmation prompt
130 Interrupted (e.g. Ctrl+C)

Development

python -m venv .venv
source .venv/bin/activate  # Windows: .venv\Scripts\activate
pip install -e ".[dev]"
pytest

License

MIT — see LICENSE.

Release files for agent-access 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for agent-access 0.4.1
File Size Uploaded
agent_access-0.4.1.tar.gz 23.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for agent-access 0.4.1
File Interpreter ABI Platform
agent_access-0.4.1-py3-none-any.whl Python 3 none any Details

Total release size: 42.8 kB

Release files / agent_access-0.4.1.tar.gz

Download URL agent_access-0.4.1.tar.gz
Size 23.8 kB
Tags Source
SHA-256 checksum
How to use checksums
e252e4b50b371890bf4d8496bb2f70e12159067dea9ce321c63fe44b84d24b9b
BLAKE2b-256 checksum
How to use checksums
6dbde612e704840a202f79d1d7e9fb90c92e65811f3bf0c5705dbb68475ab1f5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 May 1, 2026.

Transparency log

Release files / agent_access-0.4.1-py3-none-any.whl

Download URL agent_access-0.4.1-py3-none-any.whl
Size 19.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ca3c363cc5bc8c2035fe176798bd4f982351a9613b7414d55aec4ab7030fedc6
BLAKE2b-256 checksum
How to use checksums
559e41a717b89a019aec498c9a3253ecb3883207ed143bf1fde41e688ad9008f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 May 1, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.4.1 This release

2 release 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