# Change Following Values$ sudo vim /etc/ssh/sshd_config
PasswordAuthentication no
# Restart SSH$ sudo service ssh restart
Enable Automatic Security Updates
Update the file to look like below.
You should probably keep updates disabled and stick with security updates only.
$ sudo apt-get install unattended-upgrades
$ sudo vim /etc/apt/apt.conf.d/10periodic
// Automatically upgrade packages from these (origin:archive) pairs
Unattended-Upgrade::Allowed-Origins {
// "${distro_id}:${distro_codename}";"${distro_id}:${distro_codename}-security";
// "${distro_id}:${distro_codename}-updates";
// "${distro_id}:${distro_codename}-proposed";
// "${distro_id}:${distro_codename}-backports";};
Install Fail2Ban
$ sudo apt-get install Fail2Ban
Firewall Setup
# Enable UFW$ sudo ufw enable# By default Deny Everything$ sudo ufw default deny
# Allow Port 22 SSH$ sudo ufw allow 22
# Allow Port 80 HTTP$ sudo ufw allow 80
# Allow Port 443 HTTPS$ sudo ufw allow 443
# Limit Connections to SSH which slowdown SSH Attacks$ sudo ufw limit ssh/tcp
Install Logwatch To Keep An Eye On Things
$ sudo apt-get install logwatch
$ sudo vim /etc/cron.daily/00logwatch
#!/bin/bash#Check if removed-but-not-purgedtest-x /usr/share/logwatch/scripts/logwatch.pl ||exit 0
#execute
/usr/sbin/logwatch --output mail --mailto Mr.Miteshah@gmail.com --detail high
#Note: It's possible to force the recipient in above command#Just pass --mailto address@a.com instead of --output mail