Securing a Linux server after installation
The essential settings to take care of in the first hour: updates, a dedicated user, SSH keys, a firewall and protection against brute-force attacks.
1 min read · Updated on
A server exposed to the Internet starts receiving automated login attempts within minutes of going online. Here are the settings to apply as soon as your server is delivered, on Debian or Ubuntu.
1. Update the system
apt update && apt full-upgrade -y
Then enable automatic security updates:
apt install -y unattended-upgrades
dpkg-reconfigure -plow unattended-upgrades
2. Create an admin user
Avoid working as root day to day:
adduser marie
usermod -aG sudo marie
Copy your SSH key for this new user, then check that you can log in before moving on to the next step.
3. Disable password logins over SSH
In /etc/ssh/sshd_config, set:
PermitRootLogin prohibit-password
PasswordAuthentication no
Then reload the service: systemctl reload ssh.
4. Enable a firewall
apt install -y ufw
ufw allow OpenSSH
ufw allow 80,443/tcp
ufw enable
Only open the ports you actually need.
5. Block brute-force attacks
apt install -y fail2ban
systemctl enable --now fail2ban
The default configuration already protects SSH.
Further reading
Turning on automatic security updates
Install security fixes automatically on Debian, Ubuntu, AlmaLinux and Rocky Linux, and choose when reboots happen.
How many vCPU, how much memory and storage for my VPS?
Practical guidelines to size your VPS for your project, and how to tell when it is time to add resources.
Paying your invoice by Interac e-Transfer
How to pay an invoice by Interac e-Transfer: amount, recipient, message and security question. Your server is then delivered automatically.

