Part 6: Security layer
27. Save a snapshot first#
What you'll do: copy the current settings into a private folder, so you can put them back if a change goes wrong. Time: 5 minutes.
Step 1: Make the snapshot#
Type on: the server
snap="/root/snapshot-$(date +%Y%m%d-%H%M)"
sudo install -d -m 700 "$snap"
sudo tar -czf "$snap/config.tar.gz" -C / etc/ssh etc/ufw etc/apt/apt.conf.d etc/systemd/system
sudo chmod 600 "$snap/config.tar.gz"
echo "Saved in $snap"
Write the folder name it prints in your notebook.
Have Part 5 (AI)?
Add etc/ai-runtime and home/alex/.config/systemd/user to the end of the tar line.
Step 2: Write down how things are now#
Type on: the server
sudo ufw status numbered
sudo ss -lntup
systemctl --failed
Keep this output. Copy it into a note on your computer. Later you can compare "before" and "after".
ss -lntup lists every program waiting for connections:
| Address shown | Means |
|---|---|
127.0.0.1:… |
This computer only (the AI parts, later the dashboard) |
0.0.0.0:… or [::]:… |
Any network; the firewall decides who gets in |
How to undo (only if needed)#
To put one file back from the snapshot, e.g. the SSH settings:
Type on: the server
sudo tar -xzf /root/snapshot-YYYYMMDD-HHMM/config.tar.gz -C / etc/ssh
sudo systemctl reload ssh
Use your real folder name.
Done when: the snapshot folder name is written down.
Next: 28. Tighten SSH