- Before going any further, update & upgrade apt (advanced package tool) packages
# ๐ remote terminal
apt update && apt upgradeFail2ban is an intrusion prevention software framework that protects computer servers from brute-force attacks. Read more
# ๐ remote terminal
apt install fail2ban -y โน๏ธ `-y` stands for yes
systemctl enable fail2ban
systemctl start fail2ban
systemctl status fail2ban โน๏ธ Verify that fail2ban is active
rebootUFW, or Uncomplicated Firewall, is an interface to iptables that is geared towards simplifying the process of configuring a firewall.
# ๐ remote terminal
sudo apt-get install ufw
sudo ufw status
sudo ufw enable
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow 80 โน๏ธ HTTP
sudo ufw allow 443 โน๏ธ HTTPS
sudo ufw enableGo to and edit sshd_config file
# ๐ remote terminal
vim /etc/ssh/sshd_config # ๐ use vim or nanoEdit as showing below
# ๐ remote terminal
- PermitRootLogin Yes
+ PermitRootLogin no
- Port 22
+ Port XXX โน๏ธ Set your custom port numberRestart configs
# ๐ remote terminal
systemctl restart sshd- Create a non-root user
# ๐ remote terminal
adduser XXX # โน๏ธ Replace XXX with your own user name
password # โ ๏ธ Do not use your root password
exit # โน๏ธ Required for the next step- Verify newly created user
# ๐ remote terminal
ssh XXX@**.***.**.** # โน๏ธ You'll be asked for your user's password (not root)