Short answer: Update the system, create a non-root user with sudo, log in with SSH keys, disable password and root login, turn on a firewall that only allows the ports you need, add fail2ban, enable automatic security updates, set up backups and monitoring, then install your apps.
A new VPS is reachable from the whole internet within minutes of being created, and automated bots start trying passwords almost immediately. Spend the first hour on these ten steps and your server will be safer than most.
The commands below are for Ubuntu and Debian. AlmaLinux and Rocky Linux use dnf and firewalld instead. New to the command line? Read how to use SSH and Linux commands for beginners first.
The checklist
- Update everything.
sudo apt update && sudo apt upgrade -y - Create your own user and give it sudo rights.
adduser yournamethenusermod -aG sudo yourname - Set up SSH keys from your computer.
ssh-copy-id yourname@your-server-ip - Disable password and root login over SSH. In /etc/ssh/sshd_config set
PasswordAuthentication noandPermitRootLogin no, then restart SSH. Test a new session before closing the old one. - Turn on a firewall.
sudo ufw allow OpenSSH,sudo ufw allow 80,443/tcp, thensudo ufw enable. See our UFW firewall guide. - Install fail2ban to block repeated failed logins.
sudo apt install fail2ban -y - Enable automatic security updates.
sudo apt install unattended-upgrades -y - Set the hostname and timezone so logs make sense.
sudo hostnamectl set-hostname server1andsudo timedatectl set-timezone Africa/Lagos - Set up backups: server snapshots plus off-site copies of data. See the 3-2-1 rule and backups vs snapshots.
- Add monitoring for uptime, disk space and memory. See server monitoring.
Extra hardening worth doing
- Only allow SSH from your own IP if it is fixed:
sudo ufw allow from YOUR.IP to any port 22. Find your address on our What is my IP page. - Add swap space on small servers so a memory spike doesn't crash services.
- Remove software you don't need, and close every port you don't use.
- Use strong, unique database passwords, and don't expose the database port to the internet.
- Keep a record of what you installed and changed, for when you need to rebuild.
Then install your stack
A web server (Nginx or Apache), PHP or your language runtime, a database such as MariaDB, and free SSL from Let's Encrypt. Or install a control panel like cPanel or DirectAdmin to manage it all. See cPanel vs DirectAdmin, the LAMP stack on Ubuntu, Nginx as a reverse proxy and Docker on a VPS.
Running an app? See hosting a Node.js app, hosting a Python app, Laravel hosting or WordPress on a VPS.
Frequently asked questions
Do I really need to disable root login?
It's one of the most effective defences against automated attacks, which constantly try root passwords.
What if I lock myself out?
Keep a second session open while testing SSH changes, and use your host's console access as a last resort.
Can AuroxHost help set this up?
Yes. Our Cloud VPS plans are configured with our team. Contact us about what you need.
Should I change the SSH port?
It reduces log noise from bots, but it isn't real security on its own. SSH keys, no password login and fail2ban matter far more.



