Setting Up Your Own VPS: A Secure Starting Point
Описание и применение
Настройка защищённого VPS: обновление, создание sudo‑пользователя, настройка SSH‑ключей, UFW, автоматические обновления и защита Docker‑портов.
Задача
New VPS instances are vulnerable immediately after launch due to default configurations that allow root access, password authentication, open ports, and lack of automatic updates.
Результат
A hardened VPS ready for secure self‑hosting: patched, key‑only SSH, restricted firewall, automatic updates, and Docker port safety.
Рабочий процесс
- Log in as root and run
apt update && apt upgrade -yand reboot if kernel updated. - Create a non‑root sudo user with
adduser deployandusermod -aG sudo deploy. - Generate an ed25519 SSH key pair locally with
ssh-keygen -t ed25519 -C "you@your-machine"and copy it to the server withssh-copy-id -i ~/.ssh/id_ed25519.pub deploy@YOUR_SERVER_IP. - Configure SSH hardening by creating
/etc/ssh/sshd_config.d/99-hardening.confwithPermitRootLogin no,PasswordAuthentication no, etc., test withsshd -tandsshd -T, then reload SSH. - Install UFW (
sudo apt install -y ufw), set default deny incoming, allow outgoing, allow OpenSSH and web ports, enable UFW and verify status. - Install and configure
unattended-upgradesto apply security updates automatically, test with--dry-run. - Optionally install
fail2banto ban repeated SSH failures. - Address Docker firewall bypass by binding published ports to 127.0.0.1 or not publishing internal services at all.
Доказательства
Never do daily work as root. Create a sudo user and log in as that instead.
Docker bypasses UFW. When you publish a container port, Docker writes its own firewall rules that skip UFW entirely.
- Дата записи: 2026-09-02T14:26:12.522Z