Your own VPN server · WireGuard, Outline, AmneziaWG · 6 cities · Pay in BTC, USDT, USDC, ETH, SOL, LTC, XMR
Language: English
Get a VPN server

Guide · SSH hardening on a VPN server

How do I secure SSH on a VPS?

Keys instead of passwords, one small config file, and a safe way to test it so a typo never locks you out of your own VPN server.

Last updated: · 4 min read

Quick answer

How do I secure SSH on a VPS?

Here is how to secure SSH on a VPS: log in with an ed25519 key, then turn password login off with PasswordAuthentication no in a file under /etc/ssh/sshd_config.d/. Reload SSH and test from a second window before closing the first. A TunnelVPS server ordered with a key already has password login off. It takes 5 steps.

In brief
  • Key: ssh-keygen -t ed25519 on your computer; the public half goes on the server.
  • Passwords off: PasswordAuthentication no and KbdInteractiveAuthentication no.
  • Root: PermitRootLogin prohibit-password allows root by key only.
  • Safety net: keep one session open while testing from another.

What are the 5 steps to lock SSH to keys?

Securing SSH on a TunnelVPS server, 5 steps, from sshd_config(5) read 16 November 2026
StepWhereWhat to do
1Your computerCreate a key with ssh-keygen -t ed25519 if you have none.
2ServerAdd the public key to /root/.ssh/authorized_keys and test a key login.
3ServerWrite PasswordAuthentication no and related lines in /etc/ssh/sshd_config.d/.
4ServerReload SSH with systemctl reload ssh.
5Second windowLog in again with the key before closing the first session.

Why does SSH matter on a VPN server?

Because whoever gets root over SSH gets every VPN key on the server. The SSH port faces the internet, and password guessing against it never stops. A key cannot be guessed the way a password can.

The VPN keys and client list live only on the server. Protecting SSH protects them. Learning how to secure SSH on a VPS takes ten minutes and is the first job after delivery.

Where does a TunnelVPS server start?

With password login already off if you gave a public key at checkout. Root logs in over SSH. A public key given at checkout is installed and password login stays off; without a key, the team sets a temporary root password, shown in the dashboard, to change with passwd at first login.

Without a key, you log in once with the temporary password and change it with passwd. Then add a key and follow the steps below. The first SSH login guide shows how to create the key and where to paste it.

On your computer: create a key and print the public half
ssh-keygen -t ed25519
cat ~/.ssh/id_ed25519.pub

Which settings turn password login off?

PasswordAuthentication no, plus KbdInteractiveAuthentication no for the other password route. TunnelVPS read the Debian sshd_config manual on 16 November 2026. Upstream, both default to yes. PermitRootLogin defaults to prohibit-password, which already blocks passwords for root.

The same manual notes that Debian includes /etc/ssh/sshd_config.d/*.conf at the start of the main file. Settings there override the main file, so a small drop-in is cleaner than editing sshd_config.

/etc/ssh/sshd_config.d/10-keys-only.conf
PasswordAuthentication no
KbdInteractiveAuthentication no
PermitRootLogin prohibit-password
PubkeyAuthentication yes

How do you apply the change without locking yourself out?

Reload SSH, keep the current session open, and log in from a second window. A reload keeps existing sessions alive. If the new login fails, fix the file from the session that is still open.

If both sessions are lost, the server page may show a control panel card with a console and rescue mode. The late or down guide lists what to do for each status.

Apply, then test from a new window
systemctl reload ssh
# in a second terminal on your computer:
ssh [email protected]

What else helps beyond keys?

A firewall that allows only SSH and the VPN ports, and regular updates. The UFW guide allows SSH before enabling anything, so the session survives. The update guide keeps OpenSSH patched.

Keep the private key on your own devices only. TunnelVPS cannot recover a lost private key and never asks for it. A spare key on a second device avoids being locked out. Those habits complete how to secure SSH on a VPS for the long run.

SSH questions

Should I change the SSH port?

It reduces log noise but adds little security once passwords are off. If you change it, allow the new port in the firewall first.

What is the best way to secure SSH on a VPS in 2026?

Key-only login with an ed25519 key, password and keyboard-interactive login off, and a firewall limited to the ports you use.

Can I add a second key?

Yes. Add one public key per line in /root/.ssh/authorized_keys, for example one per computer.

Does the AmneziaVPN app still work with password login off?

Yes. Give it your SSH private key instead of a password; it runs on your own device.

What if I lose my only private key?

Use the console from the control panel card, when one shows, or reinstall the server. A reinstall erases the disk, VPN keys included.

Verdict
  • Keys only, passwords off, set in a drop-in file under sshd_config.d.
  • Always test from a second window before closing the first.
Sources (3)
  1. sshd_config(5) manual page (Debian) — Debian (read 2026-11-16)
  2. ufw(8) manual page — Ubuntu (read 2026-11-16)
  3. Amnezia: install VPN on your server — Amnezia (read 2026-11-16)

Order with your key

Paste your public key at checkout and password login stays off from the start. Home costs $6.37 a month on 12 months.

From $2.25/mo on 12 months · no KYC

Get a server