As a serious security researcher, I'm looking for an answer to securing a Ubuntu installation against unwanted intrusion. This should include how I can:
- Log and alert remote connection attempts,
- Log and alert when a file changes, as well as restoration of those files on request,
- Is it necessary to Harden the TCP/IP stack of the machine?
My end use case scenario is going to be in Virtualbox for ease of restoration, so it would be great to know what I need to do to get the image started.
Would the following iptables
definitions work the same as fail2bans purpose?:
$ iptables -N IN_SSH
$ iptables -A INPUT -p tcp --dport ssh -m conntrack --ctstate NEW -j IN_SSH
$ iptables -A IN_SSH -m recent --name sshbf --rttl --rcheck --hitcount 3 --seconds 10 -j DROP
$ iptables -A IN_SSH -m recent --name sshbf --rttl --rcheck --hitcount 4 --seconds 1800 -j DROP
$ iptables -A IN_SSH -m recent --name sshbf --set -j Accept
$ iptables -A INPUT -p tcp --dport ssh -m conntrack --ctstate NEW -j IN_SSH
P.S.: Would some one give the code to properly box off scripting?
I'm tempted to flag this as a duplicate since there have been several questions like this asked before, but you ask for specific security-centric things. Therefore in the spirit of helping:
There is an active security audit that's ongoing during every release cycle. It also contains good advice about some basic security measures that are already in place specifically to harden and test your system against unwanted external access.
Configuration
No Open Ports Password hashing SYN cookies
Subsystems
Mandatory Access Control (MAC)
Filesystem encryption
Userspace Hardening
Kernel Hardening
With the list of existing protections in place, lets examine the rest of your question:
So it appears that all you really need to do at this point, is ensure the extra applications you may/may not be installing are undergoing active security audits and that you are current with any patches. Have installed any extra AppArmor profiles required to secure your customizations. (or SELinux additions, respective to your particular configuration)
How to detect a SYN attack
Have a look at the following links which may help strengthen your Ubuntu install:
http://www.maketecheasier.com/protect-ssh-server-with-fail2ban-ubuntu/
http://www.rawcomputing.co.uk/linux/linux-firewall-part1.html
http://blog.lavoie.sl/2012/09/protect-webserver-against-dos-attacks.html
These links you might find helpful:
Some software might be useful: