Self-Hosting - Week 3 - Network & Security Basics
Your server is online, and the bots already found it. Week 3 of our self-hosting series covers the mandatory 4-layer security baseline to protect your Ubuntu server from day one.

Self-Hosting Week 3: Network & Security Basics (Because the Bots Are Already Watching)
In Week 2, we selected the right operating system and got your hardware ready. You’ve installed Ubuntu Server. It’s connected to your network. It’s online.
And the bots found it. Within minutes.
That’s not paranoia. That is a documented, measurable reality of the internet in 2026. The moment your server gets a public IP address or is exposed via port forwarding, automated scanners begin probing it for vulnerabilities.
You can get hardware selection wrong and still recover. You can choose a less-optimal OS and migrate later. But skipping security basics on a server connected to your network? That’s a risk with real consequences for your data, and potentially for the business or household that network serves.
This is why Week 3 of this series is the one I feel most strongly about. Let me walk you through the exact process I use to harden every Ubuntu Server I deploy for my consulting clients.
I call it the Four-Layer Baseline.
Layer 1: UFW (Your Firewall)
UFW (Uncomplicated Firewall) ships pre-installed with Ubuntu Server. Our first configuration is deceptively simple, but it establishes the fundamental rule of network security: deny by default.
- Deny all incoming connections by default.
- Allow all outgoing connections by default.
- Open only the specific ports your services explicitly need.
🚨 CRITICAL WARNING: The SSH Trap Before you do anything else, you must add your SSH exception (
sudo ufw allow sshorsudo ufw allow 22) before enabling the firewall. Every year, I see beginners enable UFW without allowing SSH first, instantly locking themselves out of their own machine. Always test your firewall rules from a second active session before closing your current one.
Layer 2: SSH Key Authentication
If your server accepts password logins, bots are actively trying to guess that password right now. They use massive dictionaries of common passwords and brute-force scripts.
An SSH key pair is a completely different class of security. The mathematics of brute-forcing a modern cryptographic key are simply not practical with any available computing power in the world.
Here is the professional setup sequence:
- Generate your key pair on your local, everyday machine.
- Transfer the public key to your server.
- Verify that key-based login works perfectly.
- Only then, disable password authentication in the SSH config.
Never disable passwords until you have 100% confirmed the key works. Otherwise, you're locking yourself out again.
Layer 3: Fail2ban (The Silent Bouncer)
Even with SSH keys configured, bots will continue their automated probing. They don't know you've changed the login method until they've already tried and failed.
Enter Fail2ban. This tool watches your authentication logs in real-time. If an IP address fails to log in too many times (e.g., three failed attempts within five minutes), Fail2ban automatically updates your firewall to ban that IP for a set period (e.g., one hour).
It runs silently in the background, requires zero manual intervention, and costs nothing.
When you check the Fail2ban status log for the first time, most people are shocked by how many IPs have already been blocked. That is normal. That is simply what the internet looks like without protection. Fail2ban turns that background noise into a non-issue.
Layer 4: Automatic Security Updates
The vast majority of real-world server compromises don't use "zero-day" magic. They exploit known vulnerabilities in unpatched software. The patch exists. The fix is available. But the administrator forgot to apply it.
Ubuntu Server includes a package called unattended-upgrades which solves this at the OS level. It automatically downloads and applies critical security patches in the background.
You configure it once. It runs indefinitely. It ensures that when a new vulnerability is announced, your server patches itself before the bots can exploit it.
The Floor, Not the Ceiling
This four-layer stack—UFW + SSH Keys + Fail2ban + Automatic Updates—is what I deploy before installing a single application on any server, anywhere.
Is it the absolute ceiling of enterprise security? No. But it is the floor. If you do not have this baseline in place, you do not have a secure server. Period.
Your Week 3 Action Plan
- Configure UFW: Allow SSH, set default policies to deny incoming/allow outgoing, and enable the firewall.
- Generate & Test SSH Keys: Create your keys on your main PC, copy them to the server, test the login, and disable password auth.
- Install Fail2ban: Run
sudo apt install fail2ban, enable the service, and check the logs to see it working. - Enable Auto-Updates: Configure
unattended-upgradesto automatically install security patches.
Need Help Securing Your Infrastructure?
Security is not something you want to guess with. If you’re following this series from Gunma (群馬県), Saitama (埼玉県), or anywhere else in Japan, and you want to ensure your new self-hosted environment is properly hardened from day one, I offer tailored consulting sessions. Let's build your infrastructure the right way.
[👉 Click here to book a 1-on-1 Security & Infrastructure Consultation] (Link to your booking page)
What’s Coming in Week 4?
Now that your server is online, reachable, and properly secured, it’s time to put it to work. In Week 4: Application Deployment & Docker Basics, we will stop installing software directly onto the OS and introduce you to containers. We'll cover why Docker is the industry standard and how to deploy your first self-hosted application safely.
Let’s Hear From You
Have you ever checked your server logs to see how many bots are trying to get in? Share your experience in the comments below, or let me know if you run into any issues setting up your SSH keys!
Get in touch for a free initial consultation.
Feel free to reach out Contact Form
or
Here you can schedule a call with Pier Alberto.
calendly.com/pierinijp/30min