WWKNOW Blog

Infrastructure knowledge and operational insight for dependable digital services.

How to Secure a Linux VPS: 12 Essential Steps for Production Servers

How to Secure a Linux VPS: 12 Essential Steps for Production Servers

A Linux VPS gives businesses and developers far more control than shared hosting, but that control also creates additional security responsibilities. A server connected to the public internet may begin receiving automated login attempts and vulnerability scans within minutes of deployment.

Security does not depend on one plugin or one configuration change. A reliable production server uses several defensive layers so that a single mistake does not expose the entire system.

1. Install security updates immediately

Begin by updating the operating system and installed packages. Security patches frequently address vulnerabilities in the kernel, system libraries, web servers, database services, and administrative tools.

sudo apt update sudo apt upgrade -y

For RPM-based distributions, use the package-management commands appropriate to your operating system. After major kernel or system-library updates, schedule a controlled reboot when required.

2. Create a separate administrative user

Routine administration should not be performed through the root account. Create an individual user, grant only the required sudo permissions, and retain a clear audit trail of administrative actions.

sudo adduser administrator sudo usermod -aG sudo administrator

Confirm that the new account can log in and use sudo before restricting root access.

3. Use SSH keys instead of passwords

SSH key authentication is significantly more resistant to automated guessing attacks than password-only access. Generate a modern key pair on the administrator’s trusted workstation and copy the public key to the server.

Protect the private key with a passphrase and never send it through email, chat, or an unencrypted file-transfer service.

4. Harden the SSH service

After key-based access is verified, review the SSH server configuration. Common production safeguards include disabling direct root login, disabling password authentication, limiting permitted users, and reducing unnecessary authentication attempts.

Apply changes carefully and keep an existing SSH session open while testing a second connection. This reduces the risk of accidentally locking yourself out.

5. Configure a default-deny firewall

A firewall should expose only the services the server actually provides. For a typical web server, that may include SSH, HTTP, and HTTPS. Database ports should generally remain private unless a specific secured architecture requires remote access.

sudo ufw default deny incoming sudo ufw default allow outgoing sudo ufw allow OpenSSH sudo ufw allow 80/tcp sudo ufw allow 443/tcp sudo ufw enable

Always confirm the active SSH port is allowed before enabling the firewall.

6. Remove unused services and packages

Every listening service increases the server’s attack surface. Review active ports and disable software that is no longer required.

sudo ss -tulpn

Examples may include unused mail services, development databases, testing dashboards, file-sharing services, or legacy management tools.

7. Add login-abuse protection

Tools such as Fail2ban can temporarily block sources that repeatedly fail authentication. This does not replace strong SSH settings, but it reduces noise and limits persistent automated abuse.

Review ban thresholds carefully. Excessively aggressive settings can block legitimate administrators or monitoring systems.

8. Protect web and database services

Keep the web server, runtime, control panel, database, and application dependencies current. Remove default pages, sample applications, unused virtual hosts, and publicly accessible diagnostic files.

Database accounts should use unique credentials and only the permissions required by the application. Avoid running applications with database-administrator privileges.

9. Use TLS for public services

All public websites, APIs, and administrative interfaces should use HTTPS. TLS protects credentials, session cookies, customer information, and administrative traffic while it travels across the network.

Certificates must also be renewed and monitored. An expired certificate can make a healthy service appear unavailable or unsafe.

10. Establish reliable backups

A backup is useful only when it can be restored. Keep copies outside the VPS, define an appropriate retention policy, encrypt sensitive backup data, and test restoration procedures periodically.

For business workloads, consider combining:

  • application and database backups;
  • configuration backups;
  • server snapshots;
  • off-server or off-site storage.

11. Monitor logs, resources, and service health

Monitor authentication activity, storage capacity, CPU usage, memory pressure, database health, web-service status, certificate expiration, and unexpected process changes.

A server that is technically online may still be unhealthy. Slow queries, disk saturation, memory exhaustion, or repeated application errors often appear before a complete outage.

12. Review access regularly

Remove former employees, expired contractor accounts, unused API keys, abandoned SSH keys, and obsolete firewall exceptions. Administrative access should reflect current operational requirements rather than historical convenience.

A practical security baseline

No public server can be made completely risk-free, but disciplined hardening substantially reduces preventable exposure. The most effective approach combines restricted access, minimal services, timely updates, tested backups, and continuous monitoring.

WWKNOW helps businesses plan, deploy, and operate infrastructure with security and maintainability considered from the beginning rather than added only after a problem occurs.

Back to Blog

Enterprise Grade Components