/
/
Ubuntu Blog Series (Part 4): Securing Your Ubuntu Server — Best Practices for Beginners
Developers
Welcome to Part 4 of our Ubuntu Blog Series. So far, we’ve introduced Ubuntu, installed it on a VPS, and learned essential commands. But before you start deploying apps or hosting websites, there’s one step you can’t skip: security.
An unsecured server is an open door to attackers. Fortunately, a few simple practices can dramatically improve your Ubuntu VPS security. Let’s walk through them.
1. Create a Non-Root User
By default, you log in as root
. While powerful, it’s risky—one wrong command can break everything. Create a safer user:
Now you can log in with your new user for daily tasks.
2. Use SSH Keys Instead of Passwords
Passwords can be guessed. SSH keys are far more secure.
On your local machine:
Copy it to your server:
From now on, you log in securely without typing a password.
3. Enable a Firewall (UFW)
Ubuntu includes Uncomplicated Firewall (UFW). Turn it on to control incoming traffic:
This ensures only necessary services (like SSH or web servers) are accessible.
4. Keep Software Updated
Updates patch vulnerabilities. Make it a habit to run:
For automated updates:
5. Disable Root Login
Once you’ve set up a user with sudo access, disable root login in the SSH config:
Find:
Change it to:
Then restart SSH:
6. Monitor Activity
Install monitoring tools to keep an eye on what’s happening:
Fail2Ban → Blocks IPs after repeated failed login attempts.
htop → View processes and resource usage in real-time.
logwatch → Analyze logs and email reports.
7. Backups Are Security Too
Even the best-secured system can fail. Always have automated backups of your critical files and databases. With Raff, you can schedule snapshots of your VPS for peace of mind.
Security doesn’t have to be complicated. With a few steps creating a non-root user, using SSH keys, enabling UFW, and keeping everything updated you dramatically reduce risks.
In Part 5 of our Ubuntu Blog Series, we’ll explore Advanced Ubuntu for Developers and Teams—covering Docker, cron jobs, and performance monitoring.
Secure your server today, and you’ll thank yourself tomorrow.