When you deploy a new Linux VPS, it is important to harden it before running production websites or applications. Below is a practical baseline that works well for most GARMTECH VPS customers.
Important: Always keep an active SSH session open while changing SSH settings. Test a new login in a second terminal before closing the first one.
Install security updates right away:
# Ubuntu/Debian
sudo apt update && sudo apt -y upgrade
# AlmaLinux/Rocky/CentOS
sudo dnf -y update
Do not use root for daily work.
adduser youruser
usermod -aG sudo youruser # Ubuntu/Debian
# RHEL-based:
usermod -aG wheel youruser
ssh-keygen).ssh-copy-id youruser@SERVER_IP).Edit /etc/ssh/sshd_config carefully and apply conservative changes:
PermitRootLogin no (or prohibit-password if you still need root via keys)PasswordAuthentication no (only after you confirmed key login works)Restart SSH service:
sudo systemctl restart sshd
Example with UFW (Ubuntu):
sudo ufw allow OpenSSH
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable
sudo ufw status
Only open ports you actually use (mail, database, admin panels, etc.).
On Ubuntu you can enable unattended security upgrades:
sudo apt -y install unattended-upgrades
sudo dpkg-reconfigure unattended-upgrades
For SSH protection, many users install Fail2ban to automatically ban repeated failed login attempts.
Security hardening is not a replacement for backups. Make sure you have a backup plan (snapshots, remote backups, or scheduled backups).