Check User (Expected: root):
sudo whoami
Deactivate root:
sudo nano /etc/ssh/sshd_config
Change "#Port 22" to "Port 2244".
Change "PermitRootLogin" to "PermitRootLogin no".
Change "PasswordAuthentication" to "PasswordAuthentication no".
Change "PubkeyAuthentication" to "PubkeyAuthentication yes".
sudo ufw allow 2244/tcp && sudo ufw delete allow 22/tcp && sudo ufw reload
sudo passwd -l root && sudo systemctl restart ssh
Install Fail2Ban:
sudo apt update && sudo apt install fail2ban -y && sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local && sudo nano /etc/fail2ban/jail.local
Change:
[sshd]
enabled = true
port = 2244
logpath = %(sshd_log)s
backend = %(sshd_backend)s
maxretry = 3
findtime = 10m
bantime = 1h
sudo systemctl restart fail2ban
New Terminal: SSH with port 2244
ssh -p 2244 @