60-Second Linux CLI: Stop a Live Server Attack Fast
CPU pegged, SSH hammered, unknown processes? Use this remote Linux cheat sheet—SSH in, sort by CPU, read auth.log, kill -9, and ufw deny—then know when to book Fixwebnode in Australia.
If your Ubuntu or Debian VPS in Australia is suddenly slow, burning CPU, or logging endless failed logins, you need a tight remote playbook—not a long post-mortem. This guide is a step-by-step Linux command-line cheat sheet for diagnosing and stopping a live server attack in about 60 seconds: connect over SSH, catch a hidden CPU-pegging miner with ps aux --sort=-%cpu, trace brute-force SSH attempts in /var/log/auth.log with grep, terminate rogue processes with kill -9, and block malicious IPs permanently with ufw deny.
Fixwebnode provides direct remote server support for homeowners and small businesses across Australia. We work on your box with you—no marketplace middle layer. Start from our Ubuntu Linux server support page when you want a specialist on the session.
Why a 60-second attack response matters on a live Linux host
Unauthorised load and login storms do not wait for business hours. A single rogue binary can saturate every core, spike egress bandwidth, and lock out legitimate users. Brute-force SSH traffic fills disks with auth noise and can succeed if weak keys or passwords remain. Remote digital response is the right first move: you already have SSH, process tools, logs, and a host firewall. The goal is contain first, then harden—without guessing.
Below is the same workflow Fixwebnode uses on emergency remote calls: identify the symptom, run the minimal commands, verify the host is calm, then decide whether DIY hardening is enough or you need a full cleanup.
How do I stop a live Linux server attack from Australia in under a minute?
SSH in as a sudo-capable user, sort processes by CPU to find the pegging binary, kill it with kill -9, grep failed SSH attempts from /var/log/auth.log, and permanently drop the source IPs with ufw deny from. Re-check load and auth noise; if the process returns or rootkits are suspected, book remote incident help with Fixwebnode rather than looping kill commands alone.
| Symptom | Quick CLI fix | When to call Fixwebnode |
|---|---|---|
| Load average / CPU near 100% | ps aux --sort=-%cpu then kill -9 PID | Process respawns or path is under /tmp with odd names |
| Flood of failed SSH logins | grep auth.log + ufw deny from IP | Successful unknown logins or many source countries |
| Host still slow after kill | Recheck uptime, ss -tulpn, cron | Persistence, reverse shells, or disk full of miners |
Common issues during a live server attack
These three failure modes show up constantly on small business and home-lab Ubuntu hosts. Each has different root causes—treat them separately.
1. Hidden CPU-pegging process (often an unauthorised miner)
Symptoms: fans spin (on bare metal), uptime load is many times core count, websites time out, and top shows a short random name under a normal-looking user. Legitimate packages rarely sit at 99% forever with no service name.
2. Brute-force SSH login storm in auth.log
Symptoms: thousands of Failed password or Invalid user lines, auth.log growing fast, occasional Accepted lines you do not recognise, or SSH feeling sluggish under connection floods.
3. Rogue process returns after kill; firewall never blocked the source
Symptoms: you kill a PID, CPU drops for seconds, then a new PID appears from cron, a dropped binary in /tmp, or a systemd user unit. Outbound connections keep retrying the same remote IPs.
Connect via SSH and freeze the picture (first 10 seconds)
Work from a trusted machine. Prefer key-based login. If the host is already overloaded, a lightweight session still beats a heavy panel.
Step 1 — Open the session
ssh -o ConnectTimeout=10 youruser@your.server.ipReplace user and IP. If key auth fails and you still have console access via the provider panel, use that instead—do not keep retrying passwords over a noisy network path.
Step 2 — Confirm identity and privilege
whoami
id
sudo -n true && echo "sudo ok" || echo "need password sudo"You need a path to root for kill, log reads on some layouts, and ufw.
Step 3 — Snapshot load before changing anything
uptime
free -h
df -h /Note load averages and whether disk is full (full disk can look like an “attack” when logs or downloads filled /).
Catch a hidden CPU-pegging miner with ps
Sort by CPU so the offender is line one. Do not trust process names alone—check the full command path.
Step 1 — List hottest processes
ps aux --sort=-%cpu | head -n 15Columns: USER, PID, %CPU, %MEM, COMMAND. A miner often shows a nonsense binary path, ./x, or something under /tmp, /dev/shm, or a compromised home directory.
Step 2 — Inspect the top PID in detail
TOPPID=$(ps aux --sort=-%cpu | awk 'NR==2 {print $2}')
echo "PID=$TOPPID"
ps -fp "$TOPPID"
ls -l /proc/"$TOPPID"/exe 2>/dev/null
tr '\0' ' ' < /proc/"$TOPPID"/cmdline; echoConfirm it is not mysqld, php-fpm, nginx, or a backup job you started. If exe points to a deleted binary (deleted), treat it as hostile until proven otherwise.
Step 3 — Optional network view for that PID
sudo ss -tpn | grep "pid=$TOPPID"
sudo ls -l /proc/"$TOPPID"/cwd /proc/"$TOPPID"/fd 2>/dev/null | headUnexpected outbound TCP to high ports or mining pools is a strong signal. Do not “join” those endpoints—only observe enough to block later.
Terminate rogue processes with kill -9
Graceful stop first when the binary might be a stuck legitimate service; use -9 when it ignores signals or is clearly malicious.
Step 1 — Try a controlled stop
kill -TERM "$TOPPID"
sleep 2
ps -p "$TOPPID" || echo "process exited"Step 2 — Force kill if still alive
kill -9 "$TOPPID"
ps aux --sort=-%cpu | head -n 10
uptimeCPU should drop within seconds. If a twin PID appears immediately, you have persistence (cron, broken web app write path, or a dropper)—killing alone is not enough.
Step 3 — Clear obvious drop locations (careful DIY)
sudo ls -la /tmp /var/tmp /dev/shm 2>/dev/null
# Only remove files you positively identified as the rogue binary, e.g.:
# sudo rm -f /tmp/oddnameDo not mass-delete /tmp. Wrong deletes break sessions and installers. Prefer quarantine copy for later forensics:
sudo mkdir -p /root/incident-quarantine
sudo cp -a /path/to/suspicious/binary /root/incident-quarantine/ 2>/dev/null
sudo chmod 000 /root/incident-quarantine/* 2>/dev/nullTrace brute-force SSH attempts in auth.log with grep
On Ubuntu/Debian the live trail is usually /var/log/auth.log (or journald). You want failed attempts, invalid users, and any surprise accepts.
Step 1 — Confirm log source
sudo ls -la /var/log/auth.log /var/log/auth.log.* 2>/dev/null
sudo journalctl -u ssh -n 20 --no-pager 2>/dev/nullStep 2 — Pull failed and invalid attempts
sudo grep -E "Failed password|Invalid user|authentication failure" /var/log/auth.log | tail -n 50Step 3 — Rank noisy source IPs
sudo grep -E "Failed password|Invalid user" /var/log/auth.log \
| grep -oE '([0-9]{1,3}\.){3}[0-9]{1,3}' \
| sort | uniq -c | sort -nr | head -n 20Those counts are your blocklist candidates. Also scan for successes you do not recognise:
sudo grep "Accepted" /var/log/auth.log | tail -n 30Any Accepted line for an unknown user or odd hour is escalate-now territory—password rotation and key audit next, not only firewall rules.
Block malicious IPs permanently with ufw deny
UFW is the standard simple firewall on Ubuntu. Deny the attackers before they rotate and reconnect. Prefer deny/reject from specific hosts over opening new ports mid-incident.
Step 1 — See current status
sudo ufw status verboseIf UFW is inactive, enabling it without allowing SSH first can lock you out. Always allow your admin path first.
Step 2 — Ensure SSH remains allowed (critical)
sudo ufw allow OpenSSH
# or, if SSH is on a custom port NNNN:
# sudo ufw allow NNNN/tcpStep 3 — Permanently deny attacker IPs
# Example — replace with IPs from your grep ranking
sudo ufw deny from 203.0.113.50 comment "ssh brute force"
sudo ufw deny from 198.51.100.22 comment "ssh brute force"
sudo ufw status numberedFor a short list from the ranking command, apply carefully one IP at a time. Do not paste your own office or home IP into deny rules.
Step 4 — Enable if needed, then re-test SSH from a second session
sudo ufw enable
sudo ufw status verboseKeep your existing SSH session open until a second window connects successfully.
Step 5 — Verify auth noise drops
sudo tail -n 20 /var/log/auth.log
uptime
ps aux --sort=-%cpu | head -n 8Failed attempts from blocked IPs should stop appearing as new live hits (old log lines remain). CPU should stay calm if the miner binary is gone and not respawning.
How to fix each issue end-to-end
Fix issue 1 — CPU pegged by unauthorised process
- SSH in and run
ps aux --sort=-%cpu | head. - Confirm exe path via
/proc/PID/exeand cmdline. kill -9the PID; re-check load withuptime.- Search cron and user systemd for respawn:
crontab -l,sudo crontab -l,systemctl list-units --type=service --state=running. - Quarantine the binary; rotate any credentials that lived on the host.
When to call Fixwebnode: the binary returns after reboot, exe (deleted) keeps reappearing, or you find web shell files under the document root.
Fix issue 2 — SSH brute force filling auth.log
grepfailed lines and build the top-IP list.ufw allow OpenSSHthenufw deny fromeach attacker.- Disable password auth only after keys work: edit
/etc/ssh/sshd_configcarefully (PasswordAuthentication no), thensudo systemctl reload sshorssh.service. - Optional rate limit with UFW:
sudo ufw limit OpenSSH. - Re-read
Acceptedlines for compromise indicators.
When to call Fixwebnode: you already see successful unknown logins, or you are not sure which accounts are legitimate across a team.
Fix issue 3 — Kill does not stick; traffic continues
- After
kill -9, watch withwatch -n1 'ps aux --sort=-%cpu | head'for 30–60 seconds. - Inspect
sudo grep -R "tmp\|curl\|wget" /etc/cron* 2>/dev/nulland user crontabs. - Check listening sockets:
sudo ss -tulpnfor unexpected listeners. - Block both inbound attackers and known bad outbound peers with UFW where appropriate.
- Plan a clean rebuild if rootkit indicators appear (unexpected kernel modules, shared library hijacks)—DIY patch-over is risky.
When to call Fixwebnode: persistence across reboot, unknown SSH keys in ~/.ssh/authorized_keys, or multiple hosts in a small fleet showing the same binary hash.
When DIY is enough vs when to book Fixwebnode
DIY is enough when: you found one clear high-CPU binary, kill stopped it, top attacker IPs are denied in UFW, no mystery Accepted logins, and load stays normal for a full business day. Document the PIDs, paths, and IPs you blocked.
Book Fixwebnode when: the process respawns, you lack confident root access, websites were writable by the attack path, outbound reverse connections persist, or you need a controlled remote session to harden SSH, review users, and validate backups. We are a direct specialist provider for Linux server support in Australia—including remote emergency containment—not a freelance board. See where remote coverage is organised on our service areas page, then continue on the Ubuntu support landing link for this workflow.
Closing: contain first, then talk through the cleanup
You now have a coherent 60-second path: SSH → ps aux --sort=-%cpu → inspect → kill -9 → grep on /var/log/auth.log → ufw deny → verify load and logs. That sequence stops many live attacks on small Ubuntu servers before they empty the month’s bandwidth or lock out customers.
If anything in that chain fails—or you want a specialist to finish hardening with you on a shared remote session—start a conversation via Fixwebnode Ubuntu Linux server support. Bring the PID list, IP ranking, and a note of what you already ran; we will pick up from the live state of the host.