Project Phoenyx – Part 2: Pouring the Foundation (Base & Security)
Welcome to the Construction Site
In the first part, we drew the blueprints. Now we put on our work gloves. Our goal today: Transform two bare Ubuntu installations into secure, manageable servers. We call them Server01 (our Manager) and Server02 (our Workhorse).
Crucially: We perform all steps identically on both servers. Consistency is the key to a stress-free admin life.
Step 1: Packing the Toolbox
A fresh Ubuntu is like an empty apartment – functional, but unfurnished. Before we build complex systems, we need tools. Nothing is more frustrating than having to install editors in the middle of a configuration session.
Log in to both servers and bring them up to date first:
sudo apt update && sudo apt upgrade -y
Now we install our "survival gear":
- nano: The text editor for people who get their fingers tied in knots with
vim. Simple and effective. - mc (Midnight Commander): A visual file manager for the console. Reminiscent of old Norton Commander days, but unbeatable when you need to move files quickly.
- htop: Shows you CPU, RAM, and processes much more nicely and clearly than standard
top. - ncdu: A lifesaver when the disk is full. It interactively shows you which folder is eating up the most space.
- tree: Visualizes directory structures as a tree – perfect for overview.
- curl & git: Standard tools for fetching data from the web.
The command for both servers:
sudo apt install -y nano mc tree ncdu htop curl git
Step 2: Secure Access (SSH Keys)
Passwords are so 1990. They are annoying to type and vulnerable to brute-force attacks. In a professional environment, we use SSH Keys. It's like a physical key: whoever has it gets in – without entering a code.
This has a huge advantage for our backups later: Server01 needs to log in to Server02 to secure data. This only works automatically if no password is requested.
How to set it up (On your PC at home):
If you don't have a key yet, create one and copy it to both servers:
# Copy key to the servers (replace User and IP) ssh-copy-id user@IP-of-Server01 ssh-copy-id user@IP-of-Server02
Now try to log in. If you are not asked for a password: Congratulations! You have just massively increased your security and convenience.
Step 3: Firewall – Full Control (Bye Bye UFW)
Now we come to a point that often causes debate. Ubuntu comes standard with UFW (Uncomplicated Firewall). The name says it all: it's simple. "Allow port 80" is typed quickly.
Why we are removing UFW anyway:
We will be using Docker intensively later. Docker is a powerful tool, but it has a habit of intervening directly in the kernel's network settings (iptables). Often the following happens: You block a port in UFW, but Docker opens it anyway because Docker pushes its rules before your UFW rules.
This is a security risk. We want to see what is really happening. That's why we use "pure" iptables in conjunction with iptables-persistent. This saves our rules so that they are still there after a reboot.
The Switch
Run this on both servers to disable UFW and install the persistent tool:
sudo ufw disable sudo apt remove ufw sudo apt install iptables-persistent
During installation, you will be asked if current IPv4 and IPv6 rules should be saved. Confirm this with YES.
Your firewall rules are now located in the file /etc/iptables/rules.v4. At first glance, this looks more cryptic than UFW, but it gives us absolute control over who is allowed to talk to our containers.
Interim Conclusion
Our servers are now updated, have the right tools on board, let us in securely via key, and use a professional firewall base.
In the next part, it gets exciting: We lay our "internal cables" (VLAN) and install the engine for our applications (Docker).