What security steps should you take in the first hour of a new server?
A short checklist to apply as soon as a VDS or VPS goes live. SSH keys, turning off root and password login, a firewall, fail2ban, updates and backups.


Write the checklist before you rent the server and apply it in order the moment the server is up. First set up SSH login with a key, then turn off password and root login, switch on a firewall, install fail2ban, put security updates on automatic and shut down services you do not use. If you are installing a control panel, give it a strong password and two-step verification. Set up backups last. The whole list takes about an hour. The hurry is real. In our experience, bots and malware start trying to log in from the moment a server comes online, even when nothing is running on it yet.
Why does SSH need a key?
If password login is open, bots try usernames and passwords and keep trying until one works. With key login the server holds only the public key, the private key stays on your computer and there is no password to guess. Ubuntu's server documentation covers it in two commands. ssh-keygen -t ed25519 creates the key pair and ssh-copy-id user@server copies the public key across.
Before you turn passwords off, check in a second window that key login works. The same page warns that a wrong SSH setting can lock you out, and tells you to keep a copy of the original config file first.
How do you turn off password and root login?
According to OpenSSH's configuration manual, PasswordAuthentication is on by default and PermitRootLogin defaults to prohibit-password, which means root can still log in with a key. Set both to no. Create a normal user first, add it to the sudo group and work from there.
One detail trips people up. Ubuntu's default config reads the files in /etc/ssh/sshd_config.d/ first, and OpenSSH uses the first value it sees for most settings. A hosting provider's ready-made image may have dropped its own file into that folder. You can switch passwords off in the main file and still have them on. After changing a setting, check the config with sudo sshd -t, then run sudo systemctl restart ssh. Keep your current session open until you have logged in again from a new one. We apply this list on your behalf and hand over the result as server setup and management work.
What do a firewall and fail2ban do?
A firewall lets traffic in only through the doors you chose to open. According to Ubuntu's documentation, ufw is disabled after installation. Allow SSH first (sudo ufw allow ssh), then turn it on with sudo ufw enable and read the rules with sudo ufw status verbose. The order matters. Enable it before allowing SSH and you lock yourself out. If you will serve a website, add ports 80 and 443 and keep everything else closed.
As its own page describes it, fail2ban scans login logs and temporarily blocks addresses with too many failed attempts through the firewall. The same page says it does not remove the risk of weak authentication. It is a helper and does not replace key login.
What about updates and unused services?
On Ubuntu the unattended-upgrades package comes installed and, per the documentation, starts installing security updates by itself right after installation. By default it covers security sources only, and automatic reboot is off. Updates that need a restart are yours to schedule. If you use another distribution, check its own documentation for the equivalent.
For services, run sudo ss -tlnp and see which program is listening on which port. Any listening service you cannot explain and do not need is an extra door for an attacker. Close it or remove it. For a wider frame, NIST's guide to general server security walks through every stage from choosing a server to maintaining it.
What if you install a control panel, and what about backups?
A management panel such as Hestia or cPanel is a second login door open to the internet. Give it a strong password you use nowhere else, turn on two-step verification if the panel supports it and change the default admin name. If you can restrict the panel to your own IP address, do that in the firewall too.
Backups belong in the first hour for a reason. If the server is compromised or breaks and the backup sits on the same server, it goes with it. Keep the backup somewhere off the server and restore it once to see that it works. A backup you have not tested is a backup you do not know works.