Web Application Setup - Server Security

webapp server ubuntu digitalocean

Optimizing Ubuntu Server

Services and programs you can likely kill:

This was taken from this site

  1. BASICS

    Killing these didn’t impact the system at all when I tested:

    ... sudo apt remove snapd -y --purge
    ... sudo apt remove lxcfs -y --purge
    ... sudo apt remove policykit-1 -y --purge
    ... 
    ... sudo apt remove lvm2 -y --purge
    ... sudo apt remove at -y --purge
    ... sudo apt remove mdadm -y --purge
    ... sudo apt remove open-iscsi -y --purge
    ... sudo apt remove accountsservice -y --purge
    
  2. EXTREME

    I did not test these, but were listed as extreme possibilities.

    ... sudo apt remove dbus -y --purge
    ... sudo apt remove rsyslog -y --purge
    ... sudo apt remove acpid -y --purge
    ... sudo systemctl stop cron && sudo systemctl disable cron
    ... sudo rm /etc/systemd/system/getty.target.wants/getty@tty1.service
    ... sudo rm /lib/systemd/system/getty@.service
    

Securing Ubuntu Server

Install fail2ban

  1. Install:

    
    ... sudo apt-get update
    ... sudo apt-get fail2ban
    

Change SSH Port

  1. Update sshd_config

    ... vim /etc/ssh/sshd_config
    

    Change Port 22 to a different port that is less than 1024. Example Port 666

  2. Update firewall:

    ... sudo ufw allow 666
    
  3. Update fail2ban jail.local:

    [sshd]
    enabled = true
    port = 666
    
  4. Restart ssh:

    ... sudo systemctl restart ssh
    
  5. Restart fail2ban:

    ... sudo systemctl restart fail2ban
    

Install nmap

  1. Install

    ... sudo apt-get install nmap
    
  2. Run a ping scan for open ports:

    ... nmap -v -sT localhost
    
  3. Run a SYN SYN Stealth Scan:

    ... sudo nmap -v -sS localhost
    

Install rootkit checkers

  1. Install rkhunter and chkrootkit:

    ... sudo apt-get install rkhunter chkrootkit
    
  2. Run check with chkrootkit:

    ... sudo chkrootkit
    
  3. Run check with rkhunter:

    ... sudo rkhunter --update
    ... sudo rkhunter --propupd
    ... sudo rkhunter --check
    

    reboot the server:

    ... sudo systemctl reboot