Published: 24.06.2026
A new server on the internet is scanned by bots within minutes. These twelve steps make it much harder to attack.
- Update the system. Install all updates right after the first login and enable automatic security updates.
- Create a normal user. Work with a regular account and use sudo instead of the root account.
- Use SSH keys. Create a key pair, add the public key to the server and disable password login.
- Disable root login over SSH. Set
PermitRootLogin noafter you confirm that sudo works. - Change defaults carefully. A non-standard SSH port reduces noise in the logs, but it is not a replacement for keys.
- Enable a firewall. Allow only the ports you really use, for example 22, 80 and 443.
- Install Fail2ban. It blocks addresses that repeatedly guess passwords.
- Remove unused services. Every open service is a risk. List the listening ports and stop what you do not need.
- Protect the database. Bind it to localhost, use strong passwords and never expose it to the internet without need.
- Use HTTPS everywhere. Issue free certificates and renew them automatically.
- Make backups. Store them outside the server and test restoring.
- Monitor. Watch the logs, disk space and load, and set alerts for unusual activity.
Regular maintenance
- Review user accounts and keys every quarter.
- Check for outdated applications and plugins.
- Test the firewall rules after every change.
Frequently asked questions
Is a managed VPS more secure? The provider handles updates and monitoring, which removes the most common mistakes.
What if I lock myself out? Use the console in your client area to restore access.