Secure a new Linux server in 5 steps
A new VPS or dedicated server is a blank Linux system under your control. These five steps are a sensible minimum before you expose it to the internet.
Before you start
- SSH access to the server.
- Time to test the new login before you turn off the old one.
Step 1Update the system
After you sign in with SSH, apply security updates with the package tool for your OS (for example apt update && apt upgrade on Debian or Ubuntu, or dnf upgrade on AlmaLinux or Rocky Linux). Reboot if the kernel was updated.
Step 2Create a sudo user and use SSH keys
Create a normal user with sudo rights, add your SSH public key, and confirm you can sign in as that user before you change anything else. Prefer keys over a root password on the public internet.
Step 3Tighten SSH
In the SSH server config, consider disabling password login after keys work, and disabling direct root login. Keep a second session open until you have tested the new settings, so you are not locked out.
Step 4Turn on a firewall
Allow only the ports you need (SSH, and 80/443 if you serve a website). Use the firewall tool that ships with your OS, and do not block SSH before you confirm a new connection works.
Step 5Keep updates on and add only what you need
Enable unattended security updates if your OS supports them, and install only the services you will actually run. If you want help with a specific setup, write to [email protected].
✅ The server has a basic hardened baseline
This is a starting point, not a full audit. Review settings again before you go live.