Skip to content
Business & cloud

Secure Linux Server Setup Checklist for Your Web App

A practical, step‑by‑step checklist to harden a Linux VPS for your web application, covering firewall, SSH keys, updates, monitoring and tool comparisons.

Developer configuring a secure Linux VPS in a bright office
Illustration generated with AI.

Deploying a Linux VPS for the first time can feel risky, but you can lock down the server with a clear checklist.

Follow the steps below and you’ll have a hardened environment ready for your web app without spending hours on trial‑and‑error.

How to pick a VPS provider that supports secure Linux hosting

Root‑access and control

You need full root access from day one. Without it you cannot install hardening tools, configure kernel parameters or apply custom security policies. Verify that the provider lets you log in as root over SSH immediately after provisioning. If they force a non‑root user first, check that sudo privileges can be granted without additional licensing.

Snapshot and backup capabilities

Snapshots let you revert a compromised system to a known‑good state. Look for providers that expose an API or a web console button to create point‑in‑time images. The ability to schedule daily snapshots is a plus, because you can test restores without affecting production traffic.

EU data‑center location

Hosting your server in an EU data centre simplifies GDPR compliance. Ask the provider for a list of available regions and confirm that at least one lies within the European Economic Area. Physical proximity also reduces latency for European users.

SSH key management

Secure key upload should be a one‑click operation. Providers that let you paste a public key into a form during instance creation eliminate the need for password logins. Some also support importing keys from GitHub or a URL, which speeds up onboarding for multiple developers.

Managed options

If you prefer not to handle low‑level patches yourself, our managed hosting services cover OS updates, firewall configuration and intrusion‑detection setup. The service runs on the same VPS providers we recommend, so you keep the same security guarantees while offloading routine maintenance.

Additional signals

Check the provider’s network uptime SLA and whether they publish independent security audits. A transparent incident‑response policy indicates they take breach handling seriously. Finally, read community forums for real‑world experiences; a provider with a responsive support team can be a decisive advantage.

Essential hardening steps for a fresh Linux installation

  1. Run the system update immediately after login. Use sudo apt update && sudo apt upgrade -y on Debian‑based distributions or sudo dnf upgrade -y on Fedora. This brings the kernel and all libraries to the latest security patches.

  2. Create a dedicated administrative account. Execute sudo adduser devadmin, then add the user to the sudo group with sudo usermod -aG sudo devadmin. Log out of root and continue work as this new user.

  3. Generate an SSH key pair on your workstation and copy the public key to the server. Run ssh-keygen -t ed25519 locally, then ssh-copy-id devadmin@your.server.ip. This eliminates password‑based logins.

  4. Disable direct root SSH access. Edit /etc/ssh/sshd_config and set PermitRootLogin no, then restart the daemon with sudo systemctl restart sshd. The server now accepts only key‑based logins for non‑root users.

  5. Install and configure fail2ban to protect against brute‑force attacks. sudo apt install fail2ban (or the equivalent for your distro), then create a local jail file that monitors sshd and bans IPs after three failures.

  6. Enable a mandatory access control system. On systems that ship with SELinux, run sudo setenforce 1 and ensure SELINUX=enforcing in /etc/selinux/config. On Ubuntu‑based hosts, install AppArmor (sudo apt install apparmor apparmor-utils) and activate the default profiles.

  7. Verify that the firewall allows only required ports. Use sudo ufw allow 22/tcp for SSH, add any application‑specific ports, then enable the firewall with sudo ufw enable. A closed default stance reduces the attack surface.

  8. Reboot the machine to apply kernel, SELinux/AppArmor, and firewall changes. After the restart, confirm that all services are running as expected and that the new admin can sudo without a password prompt if you configured NOPASSWD for specific commands.

For deeper guidance on remote management, see our remote access overview. If you need a custom monitoring solution, explore the product catalog for options that integrate with these hardening steps.

Configuring firewall and intrusion protection

Enable and configure UFW

After logging in as root or using sudo, install UFW if it is not present: apt-get install ufw. Start the service with ufw enable. The default policy should deny incoming traffic: ufw default deny incoming, while allowing outgoing connections: ufw default allow outgoing. Next, open only the ports required by your web app: ufw allow 80/tcp for HTTP, ufw allow 443/tcp for HTTPS, and ufw allow 22/tcp for SSH. Verify the rule set with ufw status verbose and reload if you make changes.

Restrict SSH access

Instead of leaving port 22 open to the world, limit it to known IP ranges. Add a rule such as ufw allow from 203.0.113.0/24 to any port 22. If you use key‑based authentication, disable password login in /etc/ssh/sshd_config by setting PasswordAuthentication no, then restart the SSH daemon.

Install and tune fail2ban

Fail2ban monitors log files and bans IPs that show malicious signs. Install it with apt-get install fail2ban. The default configuration protects SSH, but you can add a jail for Apache or Nginx by creating /etc/fail2ban/jail.d/webapp.conf with content similar to:

[http-get-dos]
enabled = true
port    = http,https
filter  = http-get-dos
logpath = /var/log/nginx/access.log
maxretry = 10
bantime = 3600

Restart fail2ban and check the active jails using fail2ban-client status. Adjust maxretry and bantime based on your traffic pattern.

Optional remote assistance

If you need occasional remote help, you can arrange a secure session with a trusted engineer. Use a dedicated VPN or a one‑time SSH key that you revoke after the session. Avoid installing generic remote‑desktop tools that are not part of Qubitpage’s product portfolio.

These steps give you a minimal yet effective perimeter: only web and SSH ports are reachable, and repeated login failures are automatically blocked. For further guidance, see our contact page for personalized assistance.

Setting up automated updates and system monitoring

Enable unattended upgrades

Install the unattended-upgrades package from your distro’s repository. After installation, edit /etc/apt/apt.conf.d/50unattended-upgrades to enable the security origin line and any additional repositories you trust. Then run dpkg-reconfigure unattended-upgrades to activate the daily run. The service will automatically fetch and install security patches without manual intervention.

Schedule health‑check cron jobs

Create a simple script, for example /usr/local/bin/health_check.sh, that runs systemctl is-active on critical services, checks disk usage with df -h, and pings a known endpoint. Add a line to /etc/crontab like:

*/5 * * * * root /usr/local/bin/health_check.sh >> /var/log/health_check.log 2>&1

This runs every five minutes and appends results to a log file you can review or forward to an alerting system.

Deploy a lightweight monitor

For real‑time metrics, install Netdata from its official script; it detects CPU, memory, network, and disk usage automatically. After the one‑line installer finishes, access the dashboard at http://your-server:19999. If you prefer a Prometheus‑compatible stack, install the node_exporter binary, configure it to listen on port 9100, and add a scrape target to your Prometheus server.

Both tools expose health data over HTTP, so you can query them from any remote console. When you need interactive access, use the remote console page at Carpathron Remote to open a browser‑based terminal without exposing SSH directly to the internet.

Combine updates and monitoring

Set a cron job that runs apt-get update && apt-get -y upgrade after hours, then reload Netdata or Prometheus to capture any service restarts. Example entry:

0 2 * * * root /usr/bin/apt-get update && /usr/bin/apt-get -y upgrade && systemctl restart netdata

This ensures the system stays patched while you retain continuous visibility into performance and availability.

When you need to protect SSH and other network services from brute‑force attacks, two open‑source firewalls dominate the conversation: fail2ban and ConfigServer Security & Firewall (CSF). Both sit on the same host, watch log files and ban offending IPs, yet they differ in scope, configuration style and resource footprint.

I prefer fail2ban for single‑service setups because its rule files are simple text snippets that you can drop into /etc/fail2ban/jail.d/. It reacts only to the patterns you define, so you keep the attack surface narrow. CSF, on the other hand, bundles a full iptables front‑end, login detection and a web UI. That extra baggage is handy when you already run a mail server or need quick port‑blocking without writing custom filters.

Choose fail2ban if you want a lightweight daemon, minimal dependencies and full control over each jail. Pick CSF when you need an all‑in‑one security suite that also handles port scanning, process tracking and email alerts out of the box. Neither tool replaces a proper firewall policy; they complement it.

Tool / Service Cost Key Features When Not to Choose
fail2ban Free (GPL) Log‑driven bans, per‑service jails, customizable actions, low CPU/memory usage Complex multi‑service environments where you need a unified UI and integrated port scanning
CSF (ConfigServer Security & Firewall) Free (cPanel license optional) iptables wrapper, login detection, port scan protection, email alerts, web UI Very lightweight servers where every megabyte of RAM counts; situations where you cannot install Perl dependencies

If you already use a Qubitpage product that offers remote administration, you can supplement either tool with manual assistance. Our Carpathron Studio page explains how to integrate external monitoring scripts, but the core hardening decision remains between fail2ban and CSF.

Frequently asked questions

Can I use a shared hosting plan for a secure Linux server?

Shared hosting isolates your web app from other customers, but you cannot enforce OS‑level hardening or custom firewall rules. You also lose control over package versions, which makes timely security patches difficult. For a production‑grade web app I recommend a VPS or dedicated instance where you can apply the checklist verbatim. If budget forces you onto shared hosting, limit exposure by using only HTTPS and a minimal set of allowed scripts.

Do I need a dedicated firewall appliance for a small VPS?

A dedicated hardware firewall adds a layer of protection, but a well‑configured host‑based firewall (iptables, nftables or firewalld) is sufficient for most small VPS workloads. The checklist includes dropping all inbound traffic except SSH (restricted to known IPs) and the web ports you actually serve. If you anticipate large‑scale attacks or need compliance reporting, a virtual firewall service from your cloud provider can complement the host firewall.

How often should I rotate SSH keys on a production server?

Key rotation depends on your risk model; a common practice is every 90 days for privileged accounts. Automate the process with a configuration management tool so you replace the public key on the server and distribute the new private key to authorized users. For low‑risk service accounts a longer interval, such as six months, may be acceptable, but always retire keys immediately after a staff change or a suspected compromise.

Final thoughts

When you finish the checklist, lock down the SSH port, enable automatic security updates and verify that your firewall only allows traffic you really need. If a single misconfiguration slips through, attackers can pivot to your database or source code repository. I recommend scheduling a monthly audit with a trusted colleague or using a lightweight scanning tool to catch drift early. Should you need a custom hardening script or a managed monitoring service, our team can extend the baseline you just built. Explore how Qubitpage can help you keep the server secure while you focus on the app. Take the final step now: apply the changes, reload the daemon and watch the logs for any unexpected connections.

Written by

Mircea S. Rusu

Founder and engineer of Qubitpage. Support engineer since 2005, CMS developer, former technical consultant at Niguarda Ca' Granda Hospital in Milan, and author of the book “The Architect”.

More about the author →