An engineer leaves the company. Write the offboarding steps for Linux servers.
IntermediateScenarioScenarios: deployments, user management and fleet operations
Answer
Situation read → Revoke access immediately, preserve data for handover, and keep an audit trail.
What I'd do →
user=$1
id "$user" &>/dev/null || die "no such user $user"
usermod --lock --expiredate 1 --shell /usr/sbin/nologin "$user" # no password, no login
pkill -KILL -u "$user" || true # end sessions and processes
rm -f "/home/$user/.ssh/authorized_keys"
rm -f "/etc/sudoers.d/$user"
crontab -r -u "$user" 2>/dev/null || true
tar -czf "/var/backups/offboard/${user}-$(date +%F).tar.gz" -C /home "$user"
logger -t offboard "offboarded $user by ${SUDO_USER:-root}"
- Lock first, delete later (
userdel -rafter the retention period), so file ownership stays readable. - Also revoke central access: IAM, SSO, VPN, Git hosting, CI secrets the person could read.
Why → Locking keeps UIDs stable for audit and data handover while removing access instantly.
Interview tip → Mention that SSH keys bypass a locked password, which is why removing authorized_keys matters.
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.IntermediateYou are asked to audit a server for risky accounts. What does your script check?Intermediate