Python SDK
Python SDK
Section titled “Python SDK”Official Python SDK for SSH-KLM.
Installation
Section titled “Installation”pip install qcecuring-sshRequirements
Section titled “Requirements”- Python 3.9 or later
httpxfor async support
Quick Start
Section titled “Quick Start”from qcecuring import QcClient
client = QcClient(api_key="sk_live_...")
# List hostshosts = client.ssh.list_hosts()for host in hosts: print(f"{host.hostname}: {host.status}")Async Support
Section titled “Async Support”import asynciofrom qcecuring import AsyncQcClient
async def main(): client = AsyncQcClient(api_key="sk_live_...")
hosts = await client.ssh.list_hosts() for host in hosts: print(host.hostname)
asyncio.run(main())Configuration
Section titled “Configuration”client = QcClient( api_key="sk_live_...", base_url="https://api.qcecuring.com", timeout=30, retries=3)Common Operations
Section titled “Common Operations”Discovery
Section titled “Discovery”# Start discoveryscan = client.ssh.start_discovery( hosts=["server01.example.com", "server02.example.com"], scan_type="full")
# Wait for completionresult = client.ssh.wait_for_scan(scan.id, timeout=300)print(f"Discovered {result.keys_found} keys")Rotation
Section titled “Rotation”# Rotate keyrotation = client.ssh.rotate_key( key_id="key_123", algorithm="ed25519", reason="Scheduled rotation")Ephemeral Access
Section titled “Ephemeral Access”# Request ephemeral credentialscreds = client.ssh.request_ephemeral( host="server.example.com", username="deploy", ttl=300, reason="Deployment")
print(creds.private_key)Error Handling
Section titled “Error Handling”from qcecuring.exceptions import QcError, RateLimitError, NotFoundError
try: client.ssh.rotate_key(key_id="invalid")except NotFoundError: print("Key not found")except RateLimitError as e: print(f"Rate limited, retry after {e.retry_after}s")except QcError as e: print(f"Error: {e.code} - {e.message}")Context Manager
Section titled “Context Manager”from qcecuring import QcClient
with QcClient(api_key="sk_live_...") as client: hosts = client.ssh.list_hosts() # Connection automatically closed