A new server is exposed to the internet within minutes of going online. Automated bots scan every public IP address looking for weak passwords, open ports and outdated software. Knowing how to secure a VPS server is not an advanced skill reserved for system administrators. It is a basic responsibility for anyone who runs a website, an app or a database on a server.
In this guide, you will find practical VPS security steps you can apply today, in order of importance.
Why VPS Security Matters
A Virtual Private Server (VPS) gives you root access and full control. That is its biggest advantage, and also the reason security is your job. Your hosting provider protects the physical hardware and the network. You protect everything inside the server: the operating system, the services, the users and the data.
This applies wherever the server is located. If you choose a VPS in Turkey to serve visitors in Turkey, the Middle East or Europe with low latency, the same security rules apply as in any other country. Location affects speed, not the need for hardening.
1. Update Your System Right Away
Outdated packages are one of the most common ways servers get compromised. After the first login, update everything.
On Ubuntu or Debian:
sudo apt update && sudo apt upgrade -y
On AlmaLinux or Rocky Linux:
sudo dnf update -y
Then enable automatic security updates so you do not have to remember. On Ubuntu, install the unattended-upgrades package and enable it. Reboot when kernel updates require it.
Your action: Run the update commands now and schedule a monthly check for anything that needs a manual restart.
2. Create a Non-Root User
Logging in as root for daily work is risky, because one wrong command or one stolen session gives an attacker everything. Create a normal user and give it sudo rights:
adduser deploy
usermod -aG sudo deploy
Use this account for all regular tasks and only elevate privileges when needed.
3. Use SSH Keys Instead of Passwords
Passwords can be guessed. A properly generated SSH key pair cannot be guessed in practice. SSH key authentication is the single most effective change you can make to your VPS security.
On your own computer, generate a key:
ssh-keygen -t ed25519
Copy it to the server:
ssh-copy-id deploy@your-server-ip
Test that you can log in with the key. Only after that, edit /etc/ssh/sshd_config and set:
PasswordAuthentication no
PermitRootLogin no
Restart the SSH service with sudo systemctl restart ssh. Keep your current session open while you test a second login, so you do not lock yourself out.
4. Change the Default SSH Port (Optional)
Moving SSH from port 22 to another port will not stop a determined attacker, but it removes a large amount of automatic bot noise from your logs. Treat it as a small extra layer, not a replacement for SSH keys. If you change it, remember to allow the new port in your firewall before restarting SSH.
5. Set Up a Firewall
A firewall decides which doors are open. The rule is simple: close everything, then open only what you need. On Ubuntu, UFW makes this easy:
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow 22/tcp
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable
Replace 22 with your custom SSH port if you changed it. If you run a database such as MySQL or PostgreSQL, do not open its port to the whole internet. Restrict it to specific IP addresses or keep it listening on localhost only.
Your action: Run sudo ufw status and check that every open port has a clear reason.
6. Block Repeated Login Attempts with Fail2ban
Even with key-only login, bots keep knocking. Fail2ban reads your logs and temporarily bans IP addresses that fail to authenticate several times.
sudo apt install fail2ban -y
sudo systemctl enable --now fail2ban
The default configuration already protects SSH. You can add jails for web servers, mail services and control panels as needed.
7. Remove What You Do Not Use
Every installed service is a possible entry point. List the services listening on your server:
sudo ss -tulpn
If you see something you do not recognize or do not need, stop it and disable it. Uninstall unused packages too. A smaller server is easier to defend.
8. Secure Your Web Applications
Many VPS compromises happen through the website, not through SSH. Keep these habits:
- Update your CMS, themes and plugins regularly. WordPress, for example, is a frequent target through old plugins.
- Install an SSL/TLS certificate and redirect all HTTP traffic to HTTPS. Free certificates from Let’s Encrypt work well.
- Use strong, unique passwords for admin panels and databases, and enable two-factor authentication where available.
- Set correct file permissions. Web files should not be writable by everyone.
- Hide server version information in your web server configuration.
9. Protect Against DDoS and Traffic Abuse
You cannot stop a large DDoS attack from inside the server alone, because the traffic saturates the network before it reaches you. Choose a provider that offers network-level DDoS protection, and add rate limiting in your web server or a reverse proxy such as Cloudflare for extra filtering. When comparing providers, ask what protection is included, not only what the price is.
10. Back Up Regularly and Test Restores
Security is not only about keeping attackers out. It is also about recovering fast when something goes wrong, whether from an attack, a bad update or a human mistake.
- Follow the 3-2-1 idea: three copies of your data, on two different types of storage, with one copy off the server.
- Automate backups with a schedule, so they do not depend on memory.
- Test a restore at least once. A backup you have never restored is only a hope.
Provider snapshots are convenient, but keep an independent backup of your important data as well.
11. Monitor Logs and Resource Usage
Unusual activity usually leaves signs: sudden CPU spikes, strange outgoing traffic, new users you did not create, or many failed logins. Check these places regularly:
/var/log/auth.log(or/var/log/secure) for login attemptslastandlastbfor recent and failed loginstoporhtopfor unexpected processes
For larger setups, use a monitoring tool that sends alerts to your email or phone, so you find out about problems before your visitors do.
12. Choose a Secure Hosting Foundation
Good habits on your side work best on top of a reliable platform. Look for a provider with up-to-date hardware, isolated virtualization, DDoS protection, a clear backup option and responsive support. At WORLDBUS, our VPS plans give you full root access and let you pick a location close to your audience, including a VPS in Turkey, so you can combine low latency with the security practices described above.
Quick VPS Security Checklist
- Update the system and enable automatic security updates
- Create a non-root user
- Switch to SSH key authentication and disable root login
- Enable a firewall with only the required ports open
- Install Fail2ban
- Remove unused services and packages
- Keep your website software and SSL certificates up to date
- Use DDoS protection and rate limiting
- Automate backups and test restores
- Monitor logs and server activity
Final Thoughts
Learning how to secure a VPS server does not require expert-level knowledge. Most attacks succeed because of simple gaps: a weak password, an open port, an old plugin or a missing backup. Close these gaps one by one, and your server becomes a much harder target than the average one on the internet.
Start with SSH keys, a firewall and updates today. Then add monitoring and backups. Security is an ongoing habit, so review your setup every few months and adjust it as your project grows.