Skip to main content

Enable/disable agent SSH and GitHub collaborator access from a YAML project config

Project description

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.

Project details


Download files

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

Source Distribution

agent_access-0.4.1.tar.gz (23.8 kB view details)

Uploaded Source

Built Distribution

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

agent_access-0.4.1-py3-none-any.whl (19.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for agent_access-0.4.1.tar.gz
Algorithm Hash digest
SHA256 e252e4b50b371890bf4d8496bb2f70e12159067dea9ce321c63fe44b84d24b9b
MD5 3635333927c2e757e363650470c16bbe
BLAKE2b-256 6dbde612e704840a202f79d1d7e9fb90c92e65811f3bf0c5705dbb68475ab1f5

See more details on using hashes here.

Provenance

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

Publisher: publish-pypi.yml on ajlyakhov/agent-access

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

File details

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

File metadata

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

File hashes

Hashes for agent_access-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ca3c363cc5bc8c2035fe176798bd4f982351a9613b7414d55aec4ab7030fedc6
MD5 9ec4ed25edac233d57acb08caafc99ca
BLAKE2b-256 559e41a717b89a019aec498c9a3253ecb3883207ed143bf1fde41e688ad9008f

See more details on using hashes here.

Provenance

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

Publisher: publish-pypi.yml on ajlyakhov/agent-access

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

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page