Running your own server gives freedom and control — but also responsibility. Here are five practical steps that immediately make your Linux server more secure.
Why server security matters
Many people set up a server, install their services — and stop there. Default settings, open ports, and weak login methods make the server an easy target.
These five steps are easy to implement and give a clear security boost immediately.
-
Switch from passwords to SSH keys
Here's how:
- Generate a key with
ssh-keygen
- Upload the key to the server using
ssh-copy-id
- Disable password login in
/etc/ssh/sshd_config
-
Change the default SSH port
Bots constantly scan the internet for servers listening on port 22.
By changing the port — for example to 2222, you reduce automated attacks significantly.
Here's how:
- Open
/etc/ssh/sshd_config
- Change
Port 22 to something like Port 2222
- Open the new port in your firewall before restarting SSH
-
Install and configure Fail2ban
Fail2ban monitors logs and blocks IP addresses after a number of failed login attempts.
It's an effective protection against brute-force attacks.
Here's how:
- Install:
sudo apt install fail2ban
- Create or edit
/etc/fail2ban/jail.local
- Start the service with
sudo systemctl enable --now fail2ban
-
Enable a firewall (UFW)
A firewall ensures that only necessary traffic is allowed.
On Ubuntu, UFW is a simple interface for controlling which ports are open.
Example:
sudo ufw allow 80 # HTTP
sudo ufw allow 443 # HTTPS
sudo ufw allow 2222 # din SSH-port
sudo ufw enable
-
Keep the system updated
Security updates patch known vulnerabilities.
One of the most important — and most overlooked — steps is to update regularly.
Basic command::
sudo apt update && sudo apt upgrade -y
Want to automate security updates?
sudo apt install unattended-upgrades
No server is ever 100 % secure – but with these five steps, you’re well on your way:
- Use SSH keys instead of passwords
- Change the default SSH port
- Install and configure Fail2ban
- Enable UFW and only open necessary ports
- Keep the system and packages up to date
Want help reviewing your server step by step?
Contact Axira and we’ll go through it together.