Guide
Harden SSH
Disable password and root logins, limit who may connect, filter the port and verify the new configuration before closing the old session.
1. Set the authentication rules
In /etc/ssh/sshd_config set PermitRootLogin no, PasswordAuthentication no and KbdInteractiveAuthentication no. Apply with systemctl reload sshd while the current session stays open.
2. Limit the principals
AllowUsers deploy or AllowGroups ssh-users restricts who can authenticate at all, which removes every default account from the attack surface.
3. Filter the port at the firewall
ufw allow from 198.51.100.7 to any port 22 proto tcp && ufw deny 22/tcp. Exposure drops to the addresses you name, regardless of what sshd allows.
4. Turn off what you do not use
X11Forwarding no, AllowAgentForwarding no, MaxAuthTries 3. Each closed feature is one less path for a compromised client machine.
5. Move the port if you want less noise
Port 2222 cuts log volume but is not a control on its own. Pair it with the source-address filter above.
6. Verify from a second terminal
ssh -p 22 deploy@203.0.113.10 'echo ok'. Only close the first session after the new one authenticates.
FAQ
Questions we get on this page
What if I lock myself out?+
Should I disable IPv6 on SSH as well?+
Ready when you are
Tell us what you need. A human answers.
Pilot stage: one facility in Reykjavík, plans confirmed by hand, payment in crypto. Write to the desk and you get a real person, not a queue.