WordPress Security Basics for VPS Owners: 12 Hardening Steps

On a VPS, you are the hosting company. There is no support team patching the server, no managed firewall quietly blocking attacks, and no one else to blame when a site gets defaced. These WordPress security basics give VPS owners a practical starting point: 12 hardening steps that cover the server, the login screen, and the site itself. None of them requires a paid plugin, and together they block the bulk of automated attacks.

If you just bought the server, start with the first 10 things to do after buying a VPS. That checklist sets up the server-level foundation, and the steps below build the WordPress layer on top of it.

1. Keep Everything Updated, Automatically Where Possible

Outdated WordPress core, themes, and plugins cause more compromises than any exotic attack. Attackers scan for known flaws in old versions and exploit them in bulk. Turn on automatic updates for minor WordPress releases, and update themes and plugins on a fixed schedule, weekly at minimum.

Automatic updates for the operating system matter just as much. Our guide to automatic security updates on Ubuntu and Debian shows how to install security patches without logging in every day. A patched server closes the holes that WordPress-level fixes cannot reach.

2. Use Strong, Unique Credentials Everywhere

Give every account its own long password: the server user, the database user, the WordPress admin, and the hosting panel. Reused passwords turn one leak into a full compromise. Use a password manager to generate and store them, and never share the admin account between people. Create a separate editor account for each person who writes content.

Delete the default “admin” username if it exists. Attackers already know it, so it hands them half of the login pair for free. A less obvious username plus a strong password makes brute-force guessing far slower.

3. WordPress Security Basics Start With SSH Keys

Password logins over SSH are a constant target. Bots try thousands of common passwords against port 22 around the clock. Switching to SSH key authentication removes that attack surface entirely, because there is no password left to guess. Our guide to disabling password login and using SSH keys only walks through the change step by step.

Keep the private key on your own machine, protect it with a passphrase, and never email it or paste it into a chat. If a key is ever exposed, remove it from the server’s authorized keys file at once and generate a fresh one.

4. Put a Firewall in Front of the Server

A firewall should allow only the ports you actually use: SSH, HTTP, and HTTPS, plus anything your specific stack needs. Everything else stays closed. UFW makes this easy on Ubuntu, and the rules take minutes to set. Our UFW firewall setup guide for Ubuntu 24.04 covers the exact commands, including how to avoid locking yourself out of SSH.

Check the firewall rules after any software install. Some installers open extra ports without asking, and an open database port or panel port is an invitation for automated scans. That is the core WordPress firewall setup for a VPS: allow only what you use, and deny the rest.

5. Block Brute Force With Fail2ban

Even with strong passwords, repeated login attempts waste server resources and occasionally succeed against a weak account. Fail2ban watches the logs and bans IP addresses after a set number of failed attempts. It protects SSH by default, and you can add rules for WordPress logins too. Our fail2ban setup guide for SSH brute-force attacks explains the configuration and how to test that bans actually trigger.

Fail2ban is a complement to strong credentials, not a replacement. A ban slows attackers down; a strong password and two-factor login stop them.

6. Turn On Two-Factor Authentication for WordPress Logins

Two-factor authentication means a stolen password alone is not enough to get in. The attacker also needs the time-based code from your authenticator app. Enable it for every admin account, not just your own. Free plugins add this to the login screen in a few minutes, and the extra seconds at login are a small price for the protection.

Store the recovery codes somewhere safe, outside the server. If you lose the authenticator device without recovery codes, regaining access means editing the database by hand. That extra step is the heart of WordPress login security: a password alone should never open an admin account.

7. Limit Login Attempts at the WordPress Level

Limiting login attempts at the application level catches attacks that fail2ban misses, such as distributed attempts that come from many IP addresses at once. A login-limit plugin locks an account or an IP after a few failures and notifies you by email. Combined with two-factor authentication, this makes password guessing a very poor use of an attacker’s time.

Watch the notification emails for the first week. A sudden spike in attempts often means your site has been added to a target list, and it is a good prompt to double-check the other steps on this list.

8. Set Sensible File Permissions

WordPress files should be readable by the web server and writable only where needed. The standard safe values are 644 for files, 755 for directories, and 640 or 600 for wp-config.php, which holds the database password. Loose permissions, such as 777 on a directory, let any compromised script rewrite your site.

Check permissions after installing new plugins or themes, since some installers loosen them during setup and never restore them. A quick audit with a find command once a month catches drift before it matters.

9. Hide What Attackers Use to Profile Your Site

Attackers scan for the WordPress version, the list of installed plugins, and the theme name to pick known flaws. You do not need to advertise any of it. Remove the version number from page headers, keep the readme files of unused themes and plugins off the server, and delete inactive themes and plugins entirely instead of leaving them installed and outdated.

Disabling directory browsing on the web server also helps. Without it, an attacker cannot list the contents of your uploads or plugin folders just by guessing a URL.

10. Use SSL Everywhere, Not Just on Checkout Pages

Every page should load over HTTPS. SSL encrypts logins, form submissions, and admin sessions, and browsers now warn visitors about plain HTTP pages. Free certificates from Let’s Encrypt cover a VPS site with a short renewal setup, and most panels automate renewal so it never lapses.

After enabling SSL, force HTTPS redirects at the server level and check for mixed content. A single HTTP-loaded script or stylesheet weakens the protection for the whole page.

11. Back Up on a Schedule You Have Tested

A backup you have never restored is a hope, not a plan. Schedule automatic backups of both the files and the database, store a copy off the server, and restore one to a test location every month or two. That test proves the backup works and teaches you the restore steps while nothing is on fire.

Backups also limit the damage from a successful attack. When you can wipe and restore a known-clean copy, a defacement becomes an afternoon of work instead of a rebuild from scratch.

12. Watch Logs and Act on What They Tell You

Read the server and WordPress logs on a regular schedule. Failed logins, odd file changes, and unexpected admin actions all show up there first. A small monitoring setup that alerts you to failed logins or downtime turns a weekly chore into a push notification.

When something looks wrong, act fast: change admin passwords, check recently modified files, and restore from backup if you cannot explain a change. Speed matters more than certainty in the first hour of an incident.

Putting the 12 Steps Together

These VPS hardening steps work as a set. Updates close known holes, SSH keys and two-factor logins block guessing, the firewall and fail2ban cut off noisy attackers, and backups give you a way back when something still gets through. No single step makes a site safe, and no site needs all 12 done in one day. Work through them in order, starting with updates, credentials, and backups, and you will be ahead of most self-hosted WordPress sites within a weekend.

Ditulis oleh

Firdaus Safari Putra

Founder, PT FirKaizen Digital Solutions

Firdaus Safari Putra adalah founder PT FirKaizen Digital Solutions. Ia membangun dan mengoperasikan infrastruktur server di balik panduan ini, dan menulis berdasarkan apa yang benar-benar ia jalankan, uji, dan ukur — bukan teori.