A CI pipeline deploys to servers over SSH. The first run fails with `Host key verification failed.` A teammate suggests `StrictHostKeyChecking=no`. What do you do?
IntermediateScenarioScenarios: deployments, user management and fleet operations
Answer
Situation read → The runner has no known_hosts entry. Disabling checking removes protection against man-in-the-middle attacks on your deploy path.
What I'd do →
- Store the servers' host keys as a CI variable (collected once from a trusted source, for example the instance's console output or your config management), and write them in the job:
install -d -m 0700 ~/.ssh printf '%s\n' "$KNOWN_HOSTS" > ~/.ssh/known_hosts chmod 0644 ~/.ssh/known_hosts - Load the deploy key from a secret with
ssh-agent, never write it with loose permissions. - Use
-o BatchMode=yesso failures are immediate. - For dynamic fleets, use SSH host certificates signed by your CA, and
@cert-authorityinknown_hosts.
Why → Host key checking is the only thing proving you are talking to your server and not an attacker.
Interview tip → Refusing StrictHostKeyChecking=no politely, with an alternative, is the answer interviewers want.
More on Scenarios: deployments, user management and fleet operations
Write the core of a deploy script with release directories, an atomic symlink switch and rollback.IntermediateDeploy to 10 servers behind an AWS ALB one at a time, removing each from the target group during its deploy. Outline the script.AdvancedAfter a deploy, the health check fails intermittently. Your script must roll back automatically, but only if the failure persists. How?IntermediateImplement a blue/green switch on a single nginx host with a script.AdvancedOnboard 30 engineers: create accounts and install their SSH keys from their GitHub usernames, idempotently.IntermediateAn engineer leaves the company. Write the offboarding steps for Linux servers.Intermediate