Credential stuffing is the quiet version of a break-in. Instead of guessing one password at a time, an attacker takes username and password pairs leaked from another site’s breach and tries them against your server, thousands at a time. When you secure your VPS against credential stuffing, you are not fighting a genius hacker. You are fighting an automated script that found your login page and a reused password. This guide walks through the defenses that actually stop it, in the order that matters most.
What Credential Stuffing Is and Why Your VPS Is a Target
Credential stuffing works because people reuse passwords. A breach at a forum, a shop, or a streaming service dumps millions of real email and password pairs onto the internet. Attackers feed those pairs into bots that try them against SSH, WordPress logins, control panels, and webmail on servers all over the world. Your VPS does not need to be famous to get hit. Bots scan the whole internet, and any server with port 22 or a WordPress login page open will see attempts within hours of going live.
It differs from a brute-force attack in one important way. Brute force guesses many passwords for one account. Credential stuffing tries a small number of known passwords against many accounts. The brute force vs credential stuffing distinction matters, because a lockout that blocks an account after five wrong tries does little against stuffing: the bot only needs one or two tries per account, spread across hundreds of usernames. The fix is to make stolen credentials useless in the first place, and to slow the bots down enough that the attack is not worth running.
How to Secure Your VPS Against Credential Stuffing, Step by Step
The steps below stack. No single one of them is enough on its own, and you do not need to do them all in one sitting. Start at the top and work down.
1. Turn off SSH password login entirely
This is the single most effective change you can make. If SSH only accepts keys, a leaked password cannot log anyone in, no matter how many pairs the attacker tries. Generate an SSH key pair on your own computer, copy the public key to the server, then set PasswordAuthentication no in /etc/ssh/sshd_config and restart the SSH service. Test the key login in a second terminal window before you close your current session, so a mistake does not lock you out. Our walkthrough on how to harden SSH on Ubuntu 24.04 with key-only login and fail2ban covers the exact config lines and the order to apply them.
2. Add two-factor authentication to SSH
Key-only login stops password stuffing, but a second factor protects you if a private key ever leaks. Google Authenticator PAM works with most SSH setups: install the module, run google-authenticator for your user, scan the QR code, and add the module to the SSH PAM stack. After that, logging in needs both the key and a six-digit code that changes every 30 seconds. A stolen credential alone is no longer enough. The full setup is covered in our guide to setting up two-factor authentication for SSH on your VPS.
3. Let fail2ban ban the bots for you
Fail2ban watches your logs and blocks IP addresses that fail too many logins. A fail2ban credential stuffing setup goes further than the default SSH jail: add jails for your web apps too. A WordPress jail that watches for failed wp-login.php attempts, for example, stops a bot after a handful of tries instead of letting it run through a list of ten thousand pairs. Keep ban times long enough to matter. A ten-minute ban barely slows a botnet that rotates IPs; a ban of several hours, or a repeat-offender jail that escalates to a day, does. If you run WordPress, pair fail2ban with the steps in our guide on how to stop WordPress brute-force attacks with fail2ban and strong passwords.
4. Rate-limit login pages at the web server
Fail2ban reacts after failures. Rate limiting reacts before them. With nginx limit_req_zone you can allow, say, one login attempt per second per IP on /wp-login.php and your admin panel, with a small burst allowance for real users. A bot trying hundreds of pairs per minute gets throttled to a crawl, and the extra load on your server drops to almost nothing. This also protects your PHP workers from being tied up by login floods. Our guide to blocking bad bots with nginx rate limiting shows the exact zone and location blocks to add.
5. Harden the WordPress login itself
SSH is not the only door. If your VPS hosts WordPress, the login page is usually the most attacked endpoint on the server. Use a unique admin username, never “admin”. Use a long password generated by a password manager, and do not reuse it anywhere else. Add a login attempt limit plugin or a web application firewall rule that blocks repeated failures. If only a few people need wp-admin access, restrict /wp-admin/ by IP in nginx, or put it behind HTTP basic auth as a second gate. Each layer removes another batch of stolen pairs from the attacker’s usable list.
Which Defenses Stop What
It helps to see how the layers fit together, because each one covers a gap the others leave open.
| Defense | What it stops | Effort |
|---|---|---|
| SSH key-only login | All SSH password stuffing | 30 minutes, one-time |
| SSH two-factor authentication | Login with a stolen private key | 20 minutes, one-time |
| Fail2ban jails | Repeated failures on SSH and web logins | 1 hour, then occasional tuning |
| Nginx rate limiting | High-volume login floods and bot load | 30 minutes, one-time |
| Unique admin user + long password | Stuffing against the WordPress admin account | 10 minutes |
| IP restriction on wp-admin | All remote login attempts from unknown IPs | 15 minutes, needs a stable IP |
How to Tell If You Are Already Under Attack
Most VPS owners find out about credential stuffing from their logs, not from a breach. Check /var/log/auth.log for SSH and your web server access log for repeated POST requests to login pages. A stuffing attempt has a clear signature: many different usernames from one IP or a small set of IPs, one or two attempts each, often with user agents that look like a script rather than a browser. A sudden spike in failed logins, or CPU usage from PHP-FPM during a login flood, is the same signal.
Do not rely on memory for this. Set up a weekly habit of reviewing failed logins, or a simple daily report mailed to you from a cron job. If you want a routine for it, our guide on how to audit who logged into your VPS and spot suspicious logins walks through the log commands and the patterns worth flagging. The goal is to notice the attack while it is still failing, not after a login succeeds.
What to Do If a Login Succeeds
If your logs show a successful login from an unfamiliar IP, or a user account logged in at a time nobody on your team was working, treat it as a breach, not a false alarm. Change every password on that account and any account that shares the same password. Rotate SSH keys if key-based access was involved. Check for new users, new SSH keys in ~/.ssh/authorized_keys, new cron jobs, and unfamiliar processes. Review what the account could reach: databases, backups, and other sites on the same server.
Then restore from a backup you trust, if there is any doubt about what the attacker changed. A backup made before the incident is worth more than hours of hunting for modified files by hand. After cleanup, close the hole that let them in, whether that was a reused password, an open login page, or a missing fail2ban jail. The attack will come back. Bots retry servers that worked before.
Credential Stuffing Protection Is a Routine, Not a One-Time Fix
Credential stuffing protection works when it is boring and automatic. That is the core of VPS login security: keys instead of passwords, a second factor where it matters, fail2ban watching the logs, and rate limits on the login pages. Set those four up, check the logs once a week, and rotate anything that looks exposed. The bots will keep trying your server. With these layers in place, the pairs they stole from someone else’s breach will not open your doors.