sshd reloads.
That risk dropped a lot in November. The OnetSolutions console can now change a VPS password in one click and restart it in rescue mode. Together with the KVM console, which goes through neither SSH nor the network, you always have a way back in.
This guide hardens SSH in an order that keeps access at every step, on Debian, Ubuntu, AlmaLinux and Rocky Linux: Ed25519 keys only, no more passwords, root by key or not at all, fail2ban, then the console firewall.
What you change, and how to check it
Summary as of November 30, 2026:Before you start: two sessions and a way back in
Three rules keep you from losing access:- Keep one SSH session open from start to finish. It stays your workbench if the new configuration refuses logins.
- Test every change in a second session, never in the one you keep open.
- Validate before reloading:
sshd -tchecks the configuration without applying anything.
ssh on Debian and Ubuntu, sshd on AlmaLinux and Rocky Linux. The commands below give both.
Install an Ed25519 SSH key
Generate the key on your workstation. Ed25519 is the type our SSH keys documentation recommends:(ED25519). An (RSA) or (ECDSA) key will be refused at the next step: replace it with an Ed25519 key first.
A key saved in the console is installed when a VPS is created or reinstalled. For a server already running,
ssh-copy-id or a line added to ~/.ssh/authorized_keys does the job.Create a sudo user so you can do without root
This step is optional if you keep root by key. You need it if you want to forbid root over SSH. On Debian and Ubuntu:sudo, not for SSH. Then give the user root’s keys:
Where to put your SSH configuration: a file in sshd_config.d
The OpenSSH manual is explicit: for each keyword, the first value read wins. Included files are read in the lexical order of their names. Debian, Ubuntu, AlmaLinux and Rocky Linux include/etc/ssh/sshd_config.d/*.conf at the top of /etc/ssh/sshd_config. Check it, and look at what the directory already holds:
Include /etc/ssh/sshd_config.d/*.conf appears before any other active directive.
You will often find files put there by the system:
A file named
10-... is read after 01- but before 25- and 50-. To make yours win over all of them, start its name with 00-. It stays in charge even if cloud-init rewrites its own file on a later boot.
Record the effective configuration before you touch anything:
Disable SSH password authentication
Create the hardening file. Pick thePermitRootLogin line that fits you:
KbdInteractiveAuthentication matters as much as PasswordAuthentication. The cloud-init documentation points it out: with PAM, keyboard-interactive authentication can still accept a password. Debian and Ubuntu already turn it off in their sshd_config; declaring it here costs nothing.
Validate, then reload:
sshd -t prints an error, fix the file and run the test again. Do not reload until it is silent.
Check that passwords are really refused
Read the effective configuration again:prohibit-password shows under its older name, without-password: it is the same setting.
Then, from your workstation and in a second session, the three tests that count:
Permission denied (publickey). without ever asking for a password.
With PermitRootLogin no, add a fourth test: ssh -o PreferredAuthentications=publickey root@203.0.113.10 must be refused too. Close the first session only once everything checks out.
Set up fail2ban on the sshd jail
Without passwords, brute force leads nowhere. fail2ban still earns its place: it bans the bots that cycle through usernames, and trims the log accordingly. What each distribution’s package does, checked on November 30, 2026:
Debian 12 no longer installs
rsyslog by default: without it there is no /var/log/auth.log, and the default jail does not start. The fix landed in package 1.0.2-3, which Debian 12 did not get. The backend = systemd setting below takes its place.
Debian and Ubuntu
.local file, read after the package configuration. List in ignoreip the addresses you manage the server from:
AlmaLinux and Rocky Linux
fail2ban comes from the EPEL repository. Thefail2ban-systemd package sets it up to read the systemd journal:
Check fail2ban
fail2ban-client status sshd answers with the Currently failed and Total banned counters and the Banned IP list. fail2ban-regex counts matched lines as soon as bots have tried their luck.
To lift a ban:
Restrict SSH to your IP addresses with the console firewall
The console firewall is set up without installing anything on the VPS. Reserved for your addresses, port 22 stops answering bots. First note the address you are connected from:
Add one rule per admin address.
Check: your SSH session still opens from your workstation. From another connection, a mobile hotspot for example,
ssh gets no answer until it times out.
Locked out: get back in from the console
Each situation has its way out:
In rescue mode, the console opens a root session on the rescue system. Mount your system partition, then remove the hardening file or add your key:
/dev/sda1 with the partition lsblk -f points to, and the ssh-ed25519 AAAA... line with your public key. Then leave rescue mode from the Rescue mode tab: the VPS restarts on its own system.
Common pitfalls
APasswordAuthentication yes read before yours. The first value wins. A 01- file or a setting placed above the Include line takes precedence: only sshd -T tells the truth.
Forgetting KbdInteractiveAuthentication. On a system where PAM enables it, passwords are still accepted that way. The keyboard-interactive test reveals it.
An RSA key still in use. With PubkeyAcceptedAlgorithms limited to Ed25519, an old RSA key, such as a deployment tool’s, is refused. Take stock with ssh-keygen -lf before reloading.
Reloading without sshd -t. One typo in the file and the service refuses new logins. The test takes a second.
Banning your own address. A few key failures from a misconfigured workstation are enough. Put your fixed addresses in ignoreip.
Updating the firewall after your address changes. If your address changes, add the new rule before removing the old one.
Going further
- SSH keys: generate a key and save it in the console for your next VPS
- Firewall: create and order your VPS rules
- KVM console, password change and rescue mode: the console’s three ways back in
- Lost your VPS root password and VPS that won’t boot: rescue mode, step by step
- Automatic security updates: so OpenSSH gets its fixes without delay
- regreSSHion (CVE-2024-6387): why an up-to-date sshd matters as much as its configuration

