Security
Cloud Server Security Best Practices: A Practical Checklist for Your VPS
By NileVPS Team · Published · 5 min read
اقرأ المقال بالعربيA cloud server is reachable from the entire internet the moment it boots. With an unmanaged VPS, the provider secures the physical hardware, the network and the virtualization layer, while everything inside the operating system is your responsibility: updates, accounts, open ports, applications and backups. That sounds like a lot, but most real-world compromises come from a short list of causes: unpatched software, weak or reused passwords, services exposed that should not be, and no backups when something goes wrong. This article turns those lessons into a checklist you can apply to a new or existing server.
1. Start from a clean, supported operating system
Choose a distribution that still receives security updates, such as Ubuntu LTS, Debian stable, AlmaLinux or Rocky Linux. An end-of-life release stops getting patches, and every new vulnerability stays open forever. Install only what the server needs; each extra package is more code that can have bugs.
2. Keep the system patched, automatically
Update immediately after the first login:
sudo apt update && sudo apt full-upgrade # Ubuntu / Debian
sudo dnf upgrade --refresh # AlmaLinux / RockyThen automate security updates. On Ubuntu and Debian, install and enable unattended-upgrades:
sudo apt install unattended-upgrades
sudo dpkg-reconfigure --priority=low unattended-upgradesOn RHEL-family systems, dnf-automatic does the same job (sudo systemctl enable --now dnf-automatic.timer after setting apply_updates = yes). Kernel updates need a reboot to take effect; ls /var/run/reboot-required on Ubuntu tells you when one is pending. Schedule reboots in a quiet hour instead of postponing them indefinitely.
Software installed by hand, such as CMS plugins, Node.js packages or Docker images, is not covered by the system updater and needs its own routine.
3. Secure remote access
SSH is the main entry point, so use key-based login, disable root and password authentication and add fail2ban. Our step-by-step guide on securing SSH with keys covers each setting and how to test it without locking yourself out. On Windows servers, the equivalent is restricting RDP, using strong unique passwords and enabling Network Level Authentication.
4. Default-deny firewall
The rule is simple: block everything inbound, then open only the ports you need. A typical web server needs 22 (or your SSH port), 80 and 443, and nothing else from the public internet. Databases such as MySQL (3306), PostgreSQL (5432) and Redis (6379) should listen on 127.0.0.1 or a private network, never on a public interface. Check what is actually listening with:
sudo ss -tulpnCombining a cloud firewall at the network edge with a host firewall such as ufw gives you two independent layers.
5. Apply least privilege everywhere
Least privilege means every user, process and key gets only the access it needs:
- Daily work happens as a normal user with sudo, not as root.
- Each application runs under its own system user, not root.
- Database users are limited to their own database, and web apps never connect as the database superuser.
- File permissions are tight: configuration files containing secrets should be readable only by their owner (
chmod 600). - API tokens and SSH keys are scoped and rotated, and access is removed when a team member leaves.
6. Protect secrets
Keep passwords, API keys and certificates out of Git repositories and public web directories. Store them in environment files with restrictive permissions or in a secrets manager. A surprising number of incidents start with a .env file or a database dump left inside the web root.
7. Backups you have actually restored
Backups are your last line of defense against ransomware, mistakes and failed upgrades. Follow the 3-2-1 idea: three copies of the data, on two different types of storage, with one copy off the server. Server snapshots are excellent for quick rollbacks before risky changes, but keep additional off-server copies of databases and uploaded files too. Most importantly, test a restore regularly; a backup that has never been restored is only a hope.
8. Logging and monitoring
You cannot respond to what you cannot see. At a minimum:
- Review authentication logs with
journalctl -u sshor/var/log/auth.log. - Keep logs rotated with
logrotateso the disk does not fill up. - Monitor CPU, memory, disk and uptime with a tool such as Netdata, Uptime Kuma or Prometheus with Grafana, and set alerts.
- Watch for sudden changes: unknown processes, unexpected outbound traffic or a CPU pinned at 100% can indicate a crypto-miner.
9. Have an incident plan
Decide in advance what to do after a compromise: isolate the server, snapshot it for investigation, rebuild from a clean image, restore known-good data and rotate every credential it held. Rebuilding is safer than cleaning.
Summary checklist
| Area | Action | How often |
|---|---|---|
| Updates | Automatic security updates, planned reboots | Continuous |
| Access | SSH keys, no root or password login | Once, then review |
| Firewall | Default deny, only required ports | Review on every change |
| Privileges | Separate users, minimal permissions | Ongoing |
| Backups | 3-2-1, off-server copy, restore test | Daily backups, monthly test |
| Monitoring | Resource and uptime alerts, log review | Continuous |
If you are starting fresh, deploy a new VPS and apply this checklist before you put any data on it.
FAQ
Is a VPS secure by default?
The infrastructure is maintained by the provider, but a fresh VPS is a general-purpose system that you configure. Its security depends mostly on what you install, which ports you open and how you manage updates and access, so hardening is your job from the first login.
Do I need antivirus software on a Linux server?
For most Linux web servers, patching, a firewall, least privilege and monitoring matter far more than a traditional antivirus. Scanners such as ClamAV are useful when the server stores files uploaded by users or handles email that Windows clients will open.
How often should I check my server's security?
Automated updates and alerts should run continuously. A manual review of open ports, user accounts, SSH keys and backup status once a month is a reasonable habit, plus an extra review after every major change or new application.