Kyrnet opens soon. Get notified of the launch on our Discord.

Join our Discord →
KyrnetKyrnet
Security

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