A new VPS is not secure by default. This checklist gives developers and IT administrators a practical sequence for hardening a Linux server before deployment, then provides recurring checks for SSH access, firewall rules, patches, exposed services, secrets, logs, backups, TLS, and recovery access.
Overview
VPS security hardening is the process of reducing unnecessary access, limiting the impact of a compromised account, and making recovery possible when something goes wrong. The safest approach is staged: establish a tested administrative path first, apply updates, restrict network exposure, remove or disable unused services, and only then deploy the application.
This checklist assumes a newly provisioned Linux VPS managed through a provider console and a shell session. Exact commands vary by distribution and image, so confirm package names and service behavior in the operating system documentation before applying them to production. Keep a provider-console recovery method available throughout the work. A firewall or SSH change can lock out a legitimate administrator as easily as it can block an attacker.
Use the following order for a secure Linux VPS:
- Record the server, operating system, public addresses, owner, and recovery method.
- Create an individual administrative account and verify SSH key access.
- Update the operating system and enable a practical patching process.
- Configure host and provider firewalls with a default-deny inbound policy.
- Review listening services, application permissions, secrets, logs, backups, and TLS.
- Test access, restoration, monitoring, and incident procedures before launch.
What to track
SSH access and administrator accounts
Use named, individual accounts rather than sharing a root login. Create an administrator with only the privileges needed for system maintenance, grant elevated access through the distribution's standard mechanism, and test that access from a second terminal before closing the original session.
Prefer SSH keys over passwords. Protect private keys on administrator devices with an appropriate passphrase and never copy private keys to the VPS. After confirming key-based access, consider disabling direct root login and password authentication. Do this only after verifying that at least two approved administrators can connect and that the provider console offers a recovery path. Restrict SSH to a trusted source network through the provider firewall where operationally practical; otherwise, use a carefully maintained allowlist and strong monitoring.
Updates and vulnerability exposure
Apply available security updates before installing the application. Debian- and Ubuntu-family systems commonly use apt, while Fedora-, RHEL-, and compatible systems commonly use dnf; use the package manager appropriate to the installed distribution. Track the operating-system release, kernel status, important application runtimes, and security-sensitive packages.
Do not treat a successful update as proof that every dependency is current. Review language packages, container images, plugins, libraries, and the web server separately. Establish a maintenance window for updates that may restart services, and document how to roll back an application or restore the server if an update causes an outage.
Firewall rules and exposed services
Use both the hosting provider's network firewall, when available, and a host-based firewall where it fits the operating model. Permit only required traffic: usually SSH from approved sources, HTTP and HTTPS for a public web application, and specific database or monitoring ports only when there is a documented reason.
Review listening sockets with the tools supplied by the distribution, such as ss, and compare each listener with the intended architecture. A database, cache, dashboard, development server, or orchestration API should not be publicly reachable merely because a package enabled it. Bind internal services to a private interface or loopback address where possible. After changing rules, test both allowed and blocked connections from the relevant networks.
Secrets, permissions, and application isolation
Keep API keys, database passwords, signing keys, and session secrets out of source control, shell history, public web directories, and world-readable configuration files. Use environment-specific secret storage or a restricted configuration file with ownership and permissions appropriate to the service account. Rotate credentials that were exposed during testing or migration.
Run the application as a dedicated, unprivileged user. Separate deployment, runtime, database, and administrative duties where the application warrants it. Review writable directories carefully: the web process should not be able to modify application code unless that behavior is required. Remove sample files, default credentials, test endpoints, and unused administrative panels before launch.
Logs, brute-force controls, and monitoring
Confirm that SSH, authentication, web server, application, and database logs are being written and retained long enough to support investigation. Centralized log collection is preferable for important systems because an attacker who gains host access may alter local evidence. Protect logs from unnecessary exposure and avoid recording passwords, access tokens, or personal data.
A fail2ban-style control can reduce repeated authentication attempts by temporarily blocking sources that match defined patterns. It is a supporting control, not a replacement for keys, firewall restrictions, patching, or multi-factor protection on provider and administrative accounts. Monitor failed logins, unexpected privilege changes, new listening services, disk exhaustion, certificate expiry, and unusual resource usage.
Backups, TLS, and recovery access
Back up application data, databases, configuration, deployment definitions, and any required encryption keys. A snapshot alone may not provide a consistent database restore, so pair infrastructure backups with application-aware exports where appropriate. Define a recovery point objective and recovery time objective, then perform a restore test rather than relying on backup success messages. See the website backup and disaster recovery plan for a restore-test framework.
For public web services, configure TLS at the intended termination point and redirect or block unintended plaintext access. Use the web server's current secure defaults, renew certificates automatically where possible, and test renewal before the certificate approaches expiration. Confirm that administrative interfaces are not exposed through the same public route as the application unless protected by an explicit access policy.
Reference table
| Area | Minimum check before deployment | Recurring evidence |
|---|---|---|
| SSH | Named accounts, tested keys, restricted root and password access | Successful access review and failed-login alerts |
| Firewall | Only documented ports are reachable | Rule review and external port scan |
| Patching | OS and application dependencies are updated or risk-accepted | Patch report and restart record |
| Services | Every listener has an owner and purpose | Comparison of listening sockets with the approved inventory |
| Secrets | No credentials in code, logs, or public files | Secret rotation and repository checks |
| Recovery | Backups exist and a restore path is documented | Completed restore test and recovery timing |
Cadence and checkpoints
Use a short checkpoint after every material change, not only during the initial VPS setup. After an operating-system upgrade, confirm SSH access, firewall behavior, enabled services, scheduled jobs, application health, logs, and backup execution. After an application deployment, check file ownership, exposed routes, secrets, dependency versions, and TLS behavior.
A practical operating rhythm is:
- After provisioning: complete the full hardening sequence and record the baseline.
- Monthly: review administrator accounts, SSH keys, firewall rules, listening services, failed-login activity, disk capacity, certificates, and backup status.
- Quarterly: perform a restore test, review dependency and operating-system support status, rotate selected credentials, and validate monitoring alerts.
- After an incident: preserve relevant logs, rotate exposed secrets, review access paths, rebuild when trust cannot be established, and document corrective actions.
- Every six months: refresh this checklist against supported distribution releases, package-management behavior, provider firewall terminology, SSH recommendations, TLS defaults, and vulnerability guidance.
Maintain a small security record for each VPS: hostname, purpose, owner, distribution, public and private addresses, allowed ports, administrator list, backup location, recovery console details, deployment method, and last review date. Store sensitive recovery information separately from the inventory.
How to interpret changes
Not every change is an incident, but unexplained change deserves investigation. A new listening port may reflect a legitimate deployment or an unauthorized service. A sudden increase in failed SSH attempts may be routine internet noise, or it may coincide with a compromised credential. A disk-use increase can indicate normal logs, an upload workload, a runaway process, or encrypted data created by an attacker.
Interpret findings against the approved baseline. Ask who made the change, when it occurred, which deployment or maintenance record supports it, and whether the change is limited to the intended scope. Treat these findings as higher priority:
- An administrator account, SSH key, scheduled job, or service with no known owner.
- A new public port or management interface without a documented purpose.
- Authentication success from an unexpected source, especially after repeated failures.
- Backups that complete but cannot be restored or lack required application data.
- Expired TLS, unsupported software, exposed secrets, or disabled logging.
If compromise is plausible, do not limit the response to deleting the suspicious file. Preserve evidence where required, restrict access, rotate credentials from a trusted device, review provider and repository accounts, and consider rebuilding the VPS from a known-good image. Use the hosting uptime and reliability review alongside security records to distinguish a security event from an ordinary availability problem.
When to revisit
Return to this VPS setup security checklist whenever you provision a server, deploy a new application, add an administrator, change a provider or network design, expose a new service, upgrade the operating system, migrate a website, or respond to an incident. A quarterly review is a useful minimum for active systems, while public-facing or frequently changing environments may need monthly checks.
Make the next review actionable. Assign an owner, record the review date, compare the current server with its baseline, test one restore path, and close findings with evidence rather than a verbal assurance. If the VPS supports WordPress or another application with frequent runtime changes, include application and plugin compatibility in the review; the PHP compatibility and rollback guide provides a useful model for controlled upgrades.
Before declaring the server ready, verify that a second administrator can recover access, only intended ports are reachable, updates have a documented cadence, secrets are protected, logs are useful, TLS is valid, and backups have been restored successfully. Security hardening is not a one-time switch; it is a repeatable operating practice that should travel with every new VPS and every major change.