Skip to main content

SSH Agent Bridge

PyPI version Python versions License: MIT

A Python package that provides high-level SSH session management for AI agents. Enables non-interactive agents to communicate with remote VMs over SSH using a tool-based interface with structured parameters and returns.

Key Features

  • Agent-Centric Design: Connection pooling per agent with session isolation
  • Structured Communication: No CLI streaming - structured parameters and returns
  • Marker-Based Execution: Reliable command completion detection with exit codes
  • Interactive Support: Handle prompts, passwords, and confirmations
  • Signal Handling: Send SIGINT, SIGKILL, and other signals to processes
  • Async First: Built on asyncio for high concurrency and performance
  • Timeout Management: Configurable timeouts with graceful degradation

Installation

pip install ssh-agent-bridge

For development:

git clone https://github.com/Ganzzi/ssh-agent-bridge.git
cd ssh_agent_bridge
pip install -e .[dev]

Quick Start

Simple Ephemeral Command

import asyncio
from ssh_agent_bridge import SSHService

async def main():
    service = SSHService()

    try:
        result = await service.run_ephemeral(
            agent_id="my-agent",
            host="example.com",
            command="echo 'Hello, World!'",
            username="myuser",
            password="mypassword"
        )

        print(f"Exit code: {result.exit_code}")
        print(f"Output: {result.stdout}")

    finally:
        await service.shutdown()

asyncio.run(main())

Persistent Session

import asyncio
from ssh_agent_bridge import SSHService

async def main():
    service = SSHService()

    try:
        # Create session
        session_id = await service.create_session(
            agent_id="my-agent",
            host="example.com",
            username="myuser",
            password="mypassword"
        )

        # Run multiple commands
        commands = ["pwd", "ls -la", "whoami"]
        for cmd in commands:
            result = await service.run_command(session_id, cmd)
            print(f"$ {cmd}")
            print(result.stdout)

        # Clean up
        await service.end_session(session_id)

    finally:
        await service.shutdown()

asyncio.run(main())

Documentation

Requirements

  • Python 3.8+
  • SSH server access (OpenSSH recommended)

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development

Setup

# Install development dependencies
pip install -r requirements-dev.txt

# Run tests
pytest

# Run type checking
mypy src/

# Format code
black src/

Testing

# Run all tests (55/55 core tests PASS - 100% pass rate)
uv run pytest tests/test_core.py -v

# Run with coverage (86% coverage, exceeds 80% target)
uv run pytest tests/test_core.py --cov=src/ssh_agent_bridge --cov-report=html

# Run core unit tests
uv run pytest tests/test_core.py::TestDataTypes tests/test_core.py::TestExceptions tests/test_core.py::TestSSHService tests/test_core.py::TestConnectionManagement tests/test_core.py::TestSessionLifecycle tests/test_core.py::TestCommandExecution -v

For detailed testing information, see:

Project Status

Phase 6 Complete ✅ | Released on PyPI 🚀

Current Phase: Phase 6 - Packaging & Release (COMPLETE)

Phase 6 Completion

  • ✅ Build System: PEP 517 build configured, wheel & sdist generation tested
  • ✅ PyPI Preparation: Package metadata, classifiers, and documentation uploaded
  • ✅ Release Process: Version 0.1.1 tagged and released to PyPI
  • ✅ Package Available: https://pypi.org/project/ssh-agent-bridge/

Final Test Status

  • ✅ 55/55 core tests PASS (100% pass rate)
  • ✅ 86% Code Coverage (exceeded 80% target)
  • ✅ 7/7 Example Scripts (all working successfully)
  • ✅ 100% Core Functionality (production ready)

Next Phase: Phase 7 - Maintenance & Enhancements

  • � User Feedback: Collect issues and feature requests
  • 🔧 Maintenance: Bug fixes and security updates
  • ✨ Future Features: Connection multiplexing, advanced prompt detection, SFTP support
  • 🌐 Community: Documentation improvements, contribution guidelines

Support

If you find this project helpful, please consider:

  • ⭐ Starring the repository
  • 🐛 Reporting bugs or issues
  • 💡 Suggesting features or improvements
  • 📖 Contributing documentation
  • asyncssh - Underlying SSH protocol implementation
  • paramiko - Alternative SSH library for Python

Metadata

Release files for ssh-agent-bridge 0.2.0

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

Source distribution (sdist)

Source distribution for ssh-agent-bridge 0.2.0
File Size Uploaded Provenance Actions
ssh_agent_bridge-0.2.0.tar.gz 82.9 kB Without provenance Details for ssh_agent_bridge-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ssh-agent-bridge 0.2.0
File Interpreter ABI Platform Actions
ssh_agent_bridge-0.2.0-py3-none-any.whl Python 3 none any Details for ssh_agent_bridge-0.2.0-py3-none-any.whl

Total release size: 98.6 kB

Release files / ssh_agent_bridge-0.2.0.tar.gz

Download URL ssh_agent_bridge-0.2.0.tar.gz
Size 82.9 kB
Tags Source
SHA-256 checksum
How to use checksums
4914c80554889d66369aee88ef5582c9d0034701037392157c8b1513f8666368
BLAKE2b-256 checksum
How to use checksums
ad5a5b123dc727d024cfed58d1e1ee478111bcd27ea28515800a2c7f1790c045
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Release files / ssh_agent_bridge-0.2.0-py3-none-any.whl

Download URL ssh_agent_bridge-0.2.0-py3-none-any.whl
Size 15.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
241f24d90839329273572da30d1c3eb8b6b120821f7054350a976205da5dc382
BLAKE2b-256 checksum
How to use checksums
f3be84a3cbe3747f3b4a7d31ac0c617ee684226893c0dced2f324376ab55f239
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Security for ssh-agent-bridge 0.2.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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