I'm still pretty new to both linux and apache and I'm trying to setup a server (ubuntu 10.04) that is "secure enough" for a site that might grow to maybe around 300 hits per day. Recently I've been focusing on learning how to harden my server and so far this is what I've done.
I have msmtp setup for google apps and I'm going to eventually install mysql, but I'll work on hardening mysql once I feel comfortable with the OS and apache being more secure. Does anyone have any good suggestions or comments as far as setup that I could do to improve my current setup? Thanks!
I have one sudo user with RSA key pairs
For /etc/ssh/sshd_config:
I changed the default ssh port
PermitRootLogin no
PasswordAuthentication no
I installed fail2ban
I installed ufw
I installed logwatch
For apache:
hddpd.conf:
ServerSignature Off
ServerTokens Prod
Inside my virtual host:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule .* - [F]
</IfModule>
I installed libapache2-mod-evasive
For mod-security I did the following:
wget
http://etc.inittab.org/~agi/debian/liba ... 1_i386.deb
wget
http://etc.inittab.org/~agi/debian/liba ... -1_all.deb
sudo dpkg -i libapache-mod-security_2.5.9-1_i386.deb mod-security-common_2.5.9-1_all.deb
for /etc/apache2/conf.d/security:
ServerToken Prod
ServerSignature Off
For php.ini:
max_execution_time = 30
memory_limit = 64M
error_reporting = E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR
display_errors = Off
log_errors = On
error_log = /var/log/php.log
register_globals = Off
allow_url_fopen = Off
safe_mode = On
expose_php = Off
enable_dl = Off
disable_functions = system, show_source, symlink, exec, dl, shell_exec, passthru, phpinfo, escapeshellarg, escapeshellcmd
I installed php5-suhosin
for /etc/sysctl.conf I did the following:
#Enable TCP SYN Cookie Protection
net.ipv4.tcp_syncookies = 1
sudo /sbin/sysctl -p