Skip to content

Architecture Overview

Understand how SSH-KLM components work together to provide comprehensive SSH key lifecycle management.

SSH-KLM uses a three-tier architecture designed for scalability, reliability, and security.

┌─────────────────────────────────────────────────────────────────────────┐
│ CLIENTS │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │ Web │ │ CLI │ │ SDK │ │ API │ │
│ │ UI │ │ Client │ │ Client │ │ Direct │ │
│ └────┬─────┘ └────┬─────┘ └────┬─────┘ └────┬─────┘ │
└───────┼─────────────┼─────────────┼─────────────┼───────────────────────┘
│ │ │ │
└─────────────┴──────┬──────┴─────────────┘
┌─────────────────────────────────────────────────────────────────────────┐
│ API GATEWAY │
│ ┌─────────────────────────────────────────────────────────────────┐ │
│ │ Authentication │ Rate Limiting │ Request Routing │ TLS Term │ │
│ └─────────────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────────────┘
┌────────────────────┼────────────────────┐
│ │ │
▼ ▼ ▼
┌───────────────┐ ┌───────────────┐ ┌───────────────┐
│ API Server │ │ API Server │ │ API Server │
│ (Replica) │ │ (Replica) │ │ (Replica) │
└───────┬───────┘ └───────┬───────┘ └───────┬───────┘
│ │ │
└───────────────────┼───────────────────┘
┌─────────────┼─────────────┐
│ │ │
▼ ▼ ▼
┌──────────┐ ┌──────────┐ ┌──────────┐
│PostgreSQL│ │ Redis │ │ Queue │
│(Primary) │ │ (Cache) │ │ (Jobs) │
└──────────┘ └──────────┘ └──────────┘
┌─────────────┼─────────────┐
│ │ │
▼ ▼ ▼
┌──────────┐ ┌──────────┐ ┌──────────┐
│ Worker │ │ Worker │ │ Worker │
│(Discovery│ │(Rotation)│ │(Rotation)│
└──────────┘ └──────────┘ └──────────┘
┌─────────────────────────────────────────────────────────────────────────┐
│ TARGET INFRASTRUCTURE │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │ Agent │ │ Agent │ │ Agent │ │ Agentless│ │
│ │ Server 1 │ │ Server 2 │ │ Server N │ │ (SSH) │ │
│ └──────────┘ └──────────┘ └──────────┘ └──────────┘ │
└─────────────────────────────────────────────────────────────────────────┘

The API Server handles all client requests and business logic.

ResponsibilityDescription
AuthenticationJWT-based auth with RBAC
REST APIRESTful endpoints for all operations
WebSocketReal-time updates for UI
ValidationRequest validation and sanitization

Background workers process async tasks.

Worker TypePurpose
Discovery WorkerScans hosts for SSH keys
Rotation WorkerExecutes key rotation jobs
Notification WorkerSends alerts and notifications
Cleanup WorkerArchives old keys, purges logs

Primary data store for all persistent data:

  • Host inventory
  • SSH key metadata
  • Rotation policies
  • Audit logs
  • User accounts

High-performance caching and job queue:

  • Session management
  • API response caching
  • Job queue (discovery, rotation tasks)
  • Rate limiting counters
  • Real-time metrics

Lightweight agent installed on target hosts:

┌─────────────────────────────────────┐
│ SSH-KLM Agent │
├─────────────────────────────────────┤
│ ┌─────────────┐ ┌───────────────┐ │
│ │ Discovery │ │ Rotation │ │
│ │ Module │ │ Module │ │
│ └─────────────┘ └───────────────┘ │
│ ┌─────────────┐ ┌───────────────┐ │
│ │ Heartbeat │ │ Secure │ │
│ │ Service │ │ Comms │ │
│ └─────────────┘ └───────────────┘ │
└─────────────────────────────────────┘
sequenceDiagram
participant UI as Dashboard
participant API as API Server
participant Queue as Job Queue
participant Worker as Discovery Worker
participant Agent as SSH Agent
participant DB as Database
UI->>API: Start Discovery Scan
API->>Queue: Enqueue Discovery Job
API-->>UI: Job ID
Queue->>Worker: Dequeue Job
Worker->>Agent: Request Key Inventory
Agent->>Agent: Scan ~/.ssh, /etc/ssh
Agent-->>Worker: Key List + Metadata
Worker->>DB: Store Discovered Keys
Worker->>Queue: Job Complete
UI->>API: Poll Status
API->>DB: Get Results
API-->>UI: Discovery Results
sequenceDiagram
participant API as API Server
participant Queue as Job Queue
participant Worker as Rotation Worker
participant Agent as SSH Agent
participant Target as Target Host
API->>Queue: Enqueue Rotation Job
Queue->>Worker: Dequeue Job
Worker->>Worker: Generate New Key Pair
Worker->>Agent: Deploy Public Key
Agent->>Target: Update authorized_keys
Agent-->>Worker: Deployment Confirmed
Worker->>Worker: Verify New Key Access
Worker->>Agent: Remove Old Key
Agent->>Target: Update authorized_keys
Worker->>API: Rotation Complete
  • All API traffic over TLS 1.3
  • Agent communication over mTLS
  • Database connections encrypted
  • Network segmentation recommended
LayerMechanism
APIJWT tokens with short expiry
AgentmTLS certificates
DatabaseCredential rotation
SecretsHashiCorp Vault integration
  • SSH private keys encrypted at rest (AES-256)
  • Audit logs immutable and signed
  • PII data encrypted
  • Key material never leaves secure boundary
ComponentScaling Method
API ServerAdd replicas behind load balancer
WorkersAdd worker pods/instances
DatabaseRead replicas, connection pooling
CacheRedis Cluster
MetricCapacity
Hosts10,000+ per cluster
Keys1M+ managed keys
Discovery1,000 hosts/minute
Rotations500 keys/minute