Interview Prep/Python for DevOps/Kubernetes, Docker, SSH & fleet automation

A Python script SSHes to hosts with `AutoAddPolicy`. Security says that is unacceptable. What do you change?

IntermediateScenarioKubernetes, Docker, SSH & fleet automation
Answer

Situation read → Blindly trusting host keys allows man-in-the-middle.

What I'd do →

  1. Pre-populate known_hosts from a trusted source (keys captured at provisioning time, or SSH certificates signed by your CA).
  2. ssh.load_system_host_keys() or load_host_keys(path) and set_missing_host_key_policy(RejectPolicy()).
  3. Consider SSH certificates (@cert-authority in known_hosts) so new hosts are trusted automatically and securely.
  4. On AWS, consider SSM Session Manager to remove SSH entirely.

Why → Host key verification is what makes SSH resistant to interception.

Interview tip → SSH certificates are the scalable answer for dynamic fleets.

All Python for DevOps questions Roadmap: Python for automation

More on Kubernetes, Docker, SSH & fleet automation