Security Assessment
Linux Security Hardening Platform
Security Score
Prevent direct root login via SSH to reduce attack surface
sudo sed -i "s/#PermitRootLogin yes/PermitRootLogin no/" /etc/ssh/sshd_config && sudo systemctl restart sshdMove SSH from default port 22 to reduce automated attacks
sudo sed -i "s/#Port 22/Port 2222/" /etc/ssh/sshd_config && sudo systemctl restart sshdUse key-based authentication instead of passwords
sudo sed -i "s/#PubkeyAuthentication yes/PubkeyAuthentication yes/" /etc/ssh/sshd_config && sudo systemctl restart sshdForce key-based authentication only
sudo sed -i "s/#PasswordAuthentication yes/PasswordAuthentication no/" /etc/ssh/sshd_config && sudo systemctl restart sshdActivate Ubuntu's Uncomplicated Firewall
sudo ufw --force enableBlock all incoming connections by default
sudo ufw default deny incoming && sudo ufw default allow outgoingAllow SSH connections on custom port
sudo ufw allow 2222/tcpEnable firewall logging for monitoring
sudo ufw logging onPrevent core dumps that could leak sensitive information
echo "* hard core 0" | sudo tee -a /etc/security/limits.conf && echo "fs.suid_dumpable=0" | sudo tee -a /etc/sysctl.confEnable Address Space Layout Randomization
echo "kernel.randomize_va_space=2" | sudo tee -a /etc/sysctl.conf && sudo sysctl -pPrevent non-root users from reading kernel logs
echo "kernel.dmesg_restrict=1" | sudo tee -a /etc/sysctl.conf && sudo sysctl -pInstall and configure Fail2Ban for intrusion prevention
sudo apt install fail2ban -y && sudo systemctl enable fail2ban && sudo systemctl start fail2banProtect SSH service with Fail2Ban
echo -e "[sshd]\nenabled = true\nport = ssh\nfilter = sshd\nlogpath = /var/log/auth.log\nmaxretry = 3\nbantime = 3600" | sudo tee /etc/fail2ban/jail.localInstall Advanced Intrusion Detection Environment
sudo apt install aide -y && sudo aideinit && sudo mv /var/lib/aide/aide.db.new /var/lib/aide/aide.dbPrevent system from acting as a router
echo "net.ipv4.ip_forward=0" | sudo tee -a /etc/sysctl.conf && sudo sysctl -pProtect against SYN flood attacks
echo "net.ipv4.tcp_syncookies=1" | sudo tee -a /etc/sysctl.conf && sudo sysctl -pPrevent ICMP redirect attacks
echo "net.ipv4.conf.all.accept_redirects=0" | sudo tee -a /etc/sysctl.conf && sudo sysctl -pConfigure strong password requirements
sudo apt install libpam-pwquality -y && echo "minlen=12" | sudo tee -a /etc/security/pwquality.confLock accounts after failed login attempts
echo "auth required pam_tally2.so deny=5 unlock_time=900" | sudo tee -a /etc/pam.d/common-auth