A Debian-first guide to reviewing unexpected accounts, checking authentication file changes, and removing account-based persistence safely.
Unauthorized user creation happens when a new account is added to a system without a valid administrative reason. This is a common persistence method after compromise because it gives an attacker a reusable way back in.
New users may be obvious, or they may be hidden among service accounts, unusual home directories, or SSH key additions.
cut -d: -f1 /etc/passwd
awk -F: '$7 !~ /(nologin|false)$/ {print $1 ":" $6 ":" $7}' /etc/passwd
sudo grep -Ei "useradd|new user|adduser|sudo|Accepted" /var/log/auth.log
getent group sudo
sudo find /home /root -name authorized_keys -type f -exec ls -lah {} \; -exec cat {} \;
sudo passwd -l <username>
sudo chage -E 0 <username>
sudo deluser <username> sudo
If you are not yet sure whether the account is malicious, lock it first rather than deleting it immediately.
sudo ls -lah /home/<username>
sudo find /home/<username> -maxdepth 3 -type f
sudo nano /home/<username>/.ssh/authorized_keys
sudo deluser --remove-home <username>
sudo systemctl list-unit-files --type=service
sudo find /etc/cron* -type f
sudo grep -Ei "useradd|adduser" /var/log/auth.log
If an attacker created a user, there may also be cron jobs, services, or SSH changes intended to preserve access.
awk -F: '$7 !~ /(nologin|false)$/ {print $1 ":" $6 ":" $7}' /etc/passwd
getent group sudo
sudo ufw allow from <trusted_ip> to any port 22
sudo ufw deny 22
ssh-copy-id user@server_ip
sudo grep -Ei "useradd|new user|sudo|Accepted" /var/log/auth.log
Manual user and key review should come first. Future recommendations may include options that make account auditing or centralized monitoring easier, but the core workflow remains Debian-first and command-driven.
All commands shown are based on Debian-based systems unless otherwise noted.