Secure a new Hostinger VPS: the 10-minute checklist
SSH keys, no root or password logins, a firewall, Fail2ban, automatic security updates and snapshots. The minimum to do before a fresh VPS goes on the internet, with copy-paste commands.
Why do this first
A new server with a public IP gets automated SSH login attempts within minutes of booting. That isn't aimed at you; bots scan the whole IPv4 range all day. The steps below shut out nearly all of that noise and take about ten minutes.
Do them in order, and keep your current SSH session open until the end. If a change locks you out, the open session is how you undo it.
1. Update everything
OS templates are built ahead of time, so a fresh server is usually a few patches behind.
apt update && apt full-upgrade -y
reboot # if a new kernel was installed2. Create a non-root user with your SSH key
Day-to-day work happens as a normal user with sudo. If you added an SSH key when you created the VPS, it's in root's `authorized_keys`; copy it across.
adduser deploy
usermod -aG sudo deploy
rsync --archive --chown=deploy:deploy ~/.ssh /home/deploy/ssh-keygen -t ed25519 -C "you@laptop"
ssh-copy-id deploy@YOUR_SERVER_IP3. Turn off root and password logins
On Ubuntu 24.04, put your settings in a drop-in file instead of editing `sshd_config`. One detail catches people out: for each setting, sshd uses the first value it reads, and drop-ins load in alphabetical order. Cloud images often ship a `50-cloud-init.conf` that turns password login on, so name your file with a lower number so it's read first.
sudo tee /etc/ssh/sshd_config.d/00-hardening.conf > /dev/null <<'EOF'
PermitRootLogin no
PasswordAuthentication no
KbdInteractiveAuthentication no
PubkeyAuthentication yes
EOF
sudo sshd -t # syntax check, prints nothing when OK
sudo sshd -T | grep -E 'permitrootlogin|passwordauthentication'
sudo systemctl restart ssh4. Firewall: allow only what you serve
UFW is the simplest firewall on Ubuntu. Allow SSH before enabling it, then open web ports. Hostinger also has a network firewall in hPanel's VPS settings; using both is fine, and the hPanel one blocks traffic before it ever reaches your server.
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 --force enable
sudo ufw status verbose5. Fail2ban for repeated failed logins
With password logins off, brute force can't succeed, but Fail2ban still keeps your logs readable and blocks noisy scanners. The default SSH jail is enough.
sudo apt install -y fail2ban
sudo tee /etc/fail2ban/jail.local > /dev/null <<'EOF'
[sshd]
enabled = true
backend = systemd
maxretry = 5
bantime = 1h
EOF
sudo systemctl enable --now fail2ban
sudo fail2ban-client status sshd6. Automatic security updates
Unattended-upgrades installs security patches every day without touching anything else. Most Ubuntu images have it already; this makes sure it's on.
sudo apt install -y unattended-upgrades
sudo dpkg-reconfigure -plow unattended-upgrades # choose "Yes"7. Snapshots and real backups
Take a snapshot in hPanel now that the server is clean, and again before any risky upgrade. Restoring takes minutes.
A snapshot isn't an off-site backup, though. Dump your database on a schedule and copy it somewhere else, such as object storage or another machine, so one account problem can't take out both the server and its backup.
- Snapshot before major upgrades or config changes.
- Nightly database dump with a cron job, kept off the server.
- Test a restore once. A backup you've never restored is a guess.
Quick checklist
Print this, or keep it in your repo's README:
- System fully updated
- Non-root sudo user with SSH key
- Root login and password login disabled, tested in a new session
- UFW on: only 22, 80 and 443 open
- Docker ports published to 127.0.0.1 only
- Fail2ban running
- Unattended security upgrades on
- Clean snapshot taken; off-server database backups scheduled
Frequently asked questions
Is a Hostinger VPS secure by default?
The platform side is (DDoS filtering, isolated KVM virtualisation), but the operating system is yours to manage. A fresh image allows root login and has no firewall rules of your own, so run through this checklist before deploying anything.
Should I change the SSH port from 22?
It reduces log noise but adds little real security once password login is off. On Ubuntu 24.04 SSH uses socket activation, so changing the port means editing the ssh.socket unit too. Most people are better off leaving 22 and using keys plus Fail2ban.
I locked myself out. What now?
Use the browser terminal in hPanel's VPS dashboard. It connects through the console, not SSH, so you can fix the sshd config or firewall from there.
Do I need both UFW and the hPanel firewall?
No, but both is a sensible belt-and-braces setup. The hPanel firewall filters traffic before it reaches the VM; UFW protects you if you ever move the server or change provider.
Ready to save an extra 20% with coupon WEBHOST2026?
Get my discount link →Disclosure: links to Hostinger on this page are referral links. If you buy through them we may earn a commission, at no extra cost to you. It doesn't change what we recommend. About us
Keep reading
How to point a domain to your Hostinger VPS (A records, step by step)
Find your VPS IP, add the right A and AAAA records whether your domain is at Hostinger, GoDaddy or Namecheap, and check propagation before you ask Let's Encrypt for a certificate.
TutorialsDeploy a Next.js app on Hostinger VPS (step by step)
A complete walkthrough: provision the server, install Node 24, build with standalone output, keep it alive with PM2, put Nginx and free HTTPS in front, and script your redeploys.
TutorialsAuto-deploy to a Hostinger VPS with GitHub Actions (push to deploy)
Every push to main deploys your app to the VPS. A dedicated SSH key, pinned host keys, a locked-down forced command and a workflow under 30 lines, with no third-party actions.