Enzonic VPS
Cyber Monday: 40% off your first 2 months on VPS plans.Ends in 1d 3hSee deal prices
Guides · 6 min read

Secure SSH on your VPS: keys only, no root login

Add an SSH key, turn off password and root logins and keep a safe way back in with the browser console.

Password logins are the first thing bots try. With key-only SSH, guessing passwords stops working. Keep the panel console open in another tab while you change SSH settings, so a typo never locks you out.

  1. 1Create a key on your computer

    Ed25519 keys are short and strong. Skip this if you already have one.

    ssh-keygen -t ed25519 -C "you@laptop"
  2. 2Copy the public key to the VPS

    You can also add keys in the panel (SSH keys) before you create or reinstall a server.

    ssh-copy-id -p 30020 debian@203.0.113.10
  3. 3Turn off passwords and root login

    Put your settings in a drop-in file so package updates never overwrite them.

    sudo tee /etc/ssh/sshd_config.d/90-hardening.conf >/dev/null <<'EOF'
    PasswordAuthentication no
    KbdInteractiveAuthentication no
    PermitRootLogin no
    EOF
    sudo sshd -t && sudo systemctl reload ssh
  4. 4Test before you log out

    Open a second terminal and log in again. Only close the first session once the new one works.

    ssh -p 30020 debian@203.0.113.10
  5. 5Slow down brute force (optional)

    fail2ban bans addresses that keep failing. With keys only it mostly keeps your logs quiet.

    sudo apt install -y fail2ban
    sudo systemctl enable --now fail2ban

Locked out anyway? Open the Console tab in the panel, or boot rescue mode, fix the file and reboot.

Your VPS is a few clicks away

Create it in the VPS panel with your Enzonic account. Refunds within 72 hours of payment.

Deploy a VPS