Docs · Security
Secure a new Linux server
A short checklist for the first hour. Updates, a non-root user, a firewall and brute-force protection.
A server on a public IPv4 starts receiving login attempts within minutes. DDoS protection is included on every plan, but the operating system is yours to harden. This checklist covers the basics on Ubuntu and Debian.
1. Update everything
apt update && apt upgrade -y
Turn on automatic security updates:
apt install unattended-upgrades
dpkg-reconfigure --priority=low unattended-upgrades
2. Create a non-root user
Day-to-day work is safer as a normal user with sudo:
adduser deploy
usermod -aG sudo deploy
Copy your SSH key to the new user so you can log in as them:
rsync --archive --chown=deploy:deploy ~/.ssh /home/deploy
Log in as deploy from a second terminal and check that sudo works before going further.
3. Use SSH keys and turn off root password login
Follow Set up SSH keys. Then, in /etc/ssh/sshd_config, set:
PermitRootLogin prohibit-password
This still lets root log in with a key, but never with a password. Use no instead to block root entirely once your deploy user works. Reload SSH afterwards:
systemctl reload ssh
4. Turn on a firewall
Allow only what you need. See Open ports on Linux:
ufw allow OpenSSH
ufw enable
5. Block repeated failed logins
Fail2ban watches the logs and temporarily bans addresses that keep failing to log in:
apt install fail2ban
systemctl enable --now fail2ban
fail2ban-client status sshd
6. Keep backups off the server
A backup on the same server is lost with the server. Copy anything important to another machine or storage service on a schedule.
That covers the first hour. If something here does not behave as described, contact support.