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 →
- Pre-populate known_hosts from a trusted source (keys captured at provisioning time, or SSH certificates signed by your CA).
ssh.load_system_host_keys()orload_host_keys(path)andset_missing_host_key_policy(RejectPolicy()).- Consider SSH certificates (
@cert-authorityin known_hosts) so new hosts are trusted automatically and securely. - 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.
More on Kubernetes, Docker, SSH & fleet automation
You need a report of every pod in the cluster with no CPU or memory limits. How do you write it?BeginnerYou are asked to write a small operator-like script that adds a label to every new namespace. How do you approach it?AdvancedYou need to restart all Deployments in a namespace that reference a rotated Secret. How?AdvancedYour CI runners keep running out of disk because of Docker images. Write a cleanup plan in Python.IntermediateYou need to run `df -h` on 300 Linux hosts and list any above 85%. Python or Ansible?BeginnerYou want to validate all Kubernetes manifests in a repo in CI with Python. What would the script check?Intermediate