Skip to content

Python SDK

Official Python SDK for SSH-KLM.

Terminal window
pip install qcecuring-ssh
  • Python 3.9 or later
  • httpx for async support
from qcecuring import QcClient
client = QcClient(api_key="sk_live_...")
# List hosts
hosts = client.ssh.list_hosts()
for host in hosts:
print(f"{host.hostname}: {host.status}")
import asyncio
from 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())
client = QcClient(
api_key="sk_live_...",
base_url="https://api.qcecuring.com",
timeout=30,
retries=3
)
# Start discovery
scan = client.ssh.start_discovery(
hosts=["server01.example.com", "server02.example.com"],
scan_type="full"
)
# Wait for completion
result = client.ssh.wait_for_scan(scan.id, timeout=300)
print(f"Discovered {result.keys_found} keys")
# Rotate key
rotation = client.ssh.rotate_key(
key_id="key_123",
algorithm="ed25519",
reason="Scheduled rotation"
)
# Request ephemeral credentials
creds = client.ssh.request_ephemeral(
host="server.example.com",
username="deploy",
ttl=300,
reason="Deployment"
)
print(creds.private_key)
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}")
from qcecuring import QcClient
with QcClient(api_key="sk_live_...") as client:
hosts = client.ssh.list_hosts()
# Connection automatically closed