These steps are for Ubuntu and Debian; on AlmaLinux and Rocky Linux use dnf instead of apt.
Update the system
apt update && apt -y upgrade
apt -y install unattended-upgrades
dpkg-reconfigure -plow unattended-upgrades
Create a sudo user
adduser deploy
usermod -aG sudo deploy
rsync --archive --chown=deploy:deploy ~/.ssh /home/deploy
Disable root and password login
Set these lines in /etc/ssh/sshd_config, then restart the service. First make sure you can log in as the new user in a separate window.
PermitRootLogin no
PasswordAuthentication no
systemctl restart ssh
Firewall
ufw allow OpenSSH
ufw allow 80,443/tcp
ufw enable
Against brute-force attempts
apt -y install fail2ban
systemctl enable --now fail2ban
Was this article helpful?
Thanks! Your feedback helps us improve.
Sorry about that. Write to our support teamand we'll sort it out together.

