SSH Hardening: Securing sshd_config on Your VPS

VDS / VPS Servers · 19.04.2026
SSH Hardening: Securing sshd_config on Your VPS

Key sshd_config Settings

Port 2222
PermitRootLogin no
PasswordAuthentication no
AllowUsers deploy admin
ClientAliveInterval 300

Generate and Add SSH Key (Ed25519)

ssh-keygen -t ed25519 -C "myserver" -f ~/.ssh/myserver
ssh-copy-id -i ~/.ssh/myserver.pub user@server.example.com

Fail2Ban Setup

sudo apt install fail2ban -y
# /etc/fail2ban/jail.local
[sshd]
enabled = true
port = 2222
maxretry = 5
bantime = 3600
⚠️ Don't close your current SSH session until you verify login works in a new window. A config error can lock you out of your server.
← Back to Knowledge Base Ask Support