Containment stops an incident from getting worse. It is not the final repair. The aim is to cut the attacker or the fault off from further harm while you keep the ability to investigate.
Weigh the choices
Each action has a cost. Isolating a server stops data leaving, but also stops customers using it. An intruder may notice and react. Agree who can approve disruptive steps before an incident happens.
Short term containment is quick: block an address, disable an account, isolate a host. Long term containment is a steadier arrangement while you rebuild, such as a temporary replacement server with tighter rules.
Isolate without powering off
Powering off loses memory and running state. Often it is better to change the network: apply a restrictive firewall or security group rule, move the switch port to a quarantine VLAN, or use your endpoint tool's isolate button. Keep one controlled path for responders.
If data is being destroyed right now, powering off may still be the right call. That is a judgement for the incident lead.
Changing firewall rules on a remote machine can lock you out. Have console access ready first. Blocking one IP address is weak on its own, because an attacker can use another.
Disable access
$ sudo usermod --lock --expiredate 1 deploy
$ sudo passwd -S deploy
deploy L 2026-02-01 0 99999 7 -1--lock disables the password only. SSH keys would still work, which is why the account is also expired. The date format printed by passwd -S varies between versions.
Locking does not end sessions that are already open. Review them before you stop anything:
$ ps -u deploy -o pid,lstart,cmdRecord the output, then end them with sudo pkill -KILL -u deploy if the lead approves. Also revoke API tokens, remove or rotate keys, and check scheduled jobs with sudo crontab -l -u deploy. Check first whether a service depends on the account.
Confirm and record
Verify that containment worked. Watch for new connections and repeated attempts. Write down each change with the time, who made it, and how to undo it.
Try it
On a test machine you own, create a throwaway user, lock and expire it, and view the result with sudo chage -l username. Then undo it with sudo usermod --unlock --expiredate "" username (on an account with no password set, --unlock may refuse or leave it locked). See the accounts lab for user management practice.
Check your understanding
Containment
All 3 sections · no timer
Unlimited retries
Questions from every section are combined into one assessment. Answer them all correctly to complete the article.
Your completion saves in this browser. Sign in to sync it to your account.