SSH known_hosts Host-Key Pinning Audit Prompt
Audit SSH client host-key trust: stale known_hosts entries, disabled StrictHostKeyChecking, weak key algorithms, and missing host-key pinning across a fleet
- Target user
- security-minded DevOps engineers hardening SSH client trust on jump hosts and CI runners
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT
The prompt
You are a senior DevSecOps engineer (defensive/blue-team) who hardens SSH client-side trust to prevent man-in-the-middle and key-confusion attacks. I will provide: - One or more known_hosts files (hashed or plaintext) and relevant ssh_config / per-host blocks - The output of `ssh -Q key` and the host-key algorithms accepted by my servers - Context on how hosts are provisioned (ephemeral CI runners, long-lived bastions, autoscaling nodes) Your job: 1. **Trust-mode review** — flag any `StrictHostKeyChecking no`, `accept-new` misuse, or `UserKnownHostsFile=/dev/null` that silently accepts unknown keys, and explain the MITM exposure. 2. **Algorithm hygiene** — identify weak or deprecated host-key types (ssh-rsa with SHA-1, DSA) and recommend Ed25519/ECDSA pinning order via `HostKeyAlgorithms`. 3. **Stale & duplicate entries** — detect hosts with multiple conflicting keys, decommissioned hosts, and entries that should be re-pinned after legitimate rotation. 4. **Centralized trust options** — assess whether SSHFP DNS records or an SSH certificate authority would remove per-host known_hosts churn, and when each fits. 5. **Ephemeral-host strategy** — recommend a safe pattern for autoscaling/CI nodes (CA-signed host certs or provisioned known_hosts) instead of disabling checking. 6. **Remediation steps** — give exact `ssh-keygen -R`, re-pinning, and config hardening commands. 7. **Drift detection** — propose a recurring check that alerts on host-key changes. Output as: a per-finding table (host, issue, severity, fix), then a hardened ssh_config block and a rollout note for ephemeral hosts. Recommend re-pinning only via an out-of-band trusted channel; never auto-accept a changed key to "make it work."
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
SSH Agent-Forwarding & Jump-Host Risk Review Prompt
Audit SSH client and server config for risky agent forwarding, unrestricted ProxyJump chains, and key-exposure paths on shared bastions, then replace them with safer ProxyJump/certificate patterns.
-
Bastion / Jump-Host Hardening Review Prompt
Review a bastion/jump host for excess exposure and weak controls, then harden it into a minimal, heavily logged, single-purpose gateway with session recording and tight forwarding rules.
-
fail2ban Brute-Force Protection Tuning Prompt
Review and tune fail2ban jails to stop credential-stuffing and brute-force attempts without locking out legitimate users, with sane bantimes, allowlists, and persistent banning.
-
SSH Certificate Authority Access Design Prompt
Design an SSH CA-based access model that replaces sprawling authorized_keys with short-lived signed certificates, principals-based authorization, and clean revocation.
More DevOps Security & Hardening prompts & error guides
Browse every DevOps Security & Hardening prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.