TL;DR
Someone’s added a hidden user account to your system’s passwd file. This guide shows you how to find and remove it, then improve security.
Steps
- Check the
passwdFile- Open the
passwdfile with a text editor as root (usingsudoif necessary). - Look for unusual usernames or entries that don’t match legitimate users. Pay attention to user IDs (UIDs) and group IDs (GIDs). A backdoor account might have a UID/GID outside the normal range, or be named something suspicious.
sudo nano /etc/passwd - Open the
- Identify the Backdoor Account
- Examine any suspect entries closely. Note the username, UID, GID, home directory, and shell.
- Use the
idcommand to check existing users:
id - If the account doesn’t appear in the output of
id, it’s likely a backdoor account. - Remove the Account
- Use the
userdelcommand to remove the account. The `-r` flag removes the home directory and mail spool as well:
sudo userdel -r - Use the
- If
userdelfails (e.g., because of a locked account), you might need to manually edit thepasswdfile (see step 6). - Check the
shadowFile- The
shadowfile contains encrypted passwords. Remove the corresponding entry for the backdoor account from this file too. Open it with a text editor as root:
sudo nano /etc/shadow - The
- Find and delete the line associated with the username you removed in step 3. Be *extremely* careful when editing this file; incorrect changes can lock everyone out of the system!
- Check for Cron Jobs
- Backdoor accounts are sometimes used to run malicious cron jobs. Check the following locations:
/etc/crontab- Files in
/var/spool/cron/crontabs/(one file per user) - Files in
/etc/cron.d/ - Remove any cron jobs associated with the backdoor account. Use a text editor to modify these files as root.
- Manual Removal (If Necessary)
- If
userdelfails, carefully edit/etc/passwdand/etc/shadowwith a text editor as root. - Delete the lines corresponding to the backdoor account in both files. Double-check your work before saving! A single mistake can render your system unusable.
- If
- Review System Logs
- Check system logs (e.g.,
/var/log/auth.log,/var/log/syslog) for any evidence of how the account was created or used. This can help you understand the extent of the compromise and identify other potential security issues.
- Check system logs (e.g.,
- Strengthen Security
- Password Policies: Enforce strong password policies (minimum length, complexity).
- Two-Factor Authentication: Enable two-factor authentication wherever possible.
- Regular Audits: Regularly audit user accounts and system logs for suspicious activity.
- Keep Software Updated: Ensure all software is up to date with the latest security patches.

