|
|
Quote:
security system is perfect and it is always good to have some forms of intrusion detection just incase somebody does get in you can be notified. Do not immediatly get worried if in an email you get a positive, many of them are false and from upgrades. I would first suggest running "rkhunter -c" from ssh and looking at the errors. If it is a few bad binaries you should check to see what was updated recently. If you have a rootkit detected you should start to worry because it is very uncommon for a false positive on a rootkit or trojan.
Download and unzip rkhunter
-----command-----
cd /usr/local/src/
wget http://downloads.rootkit.nl/rkhunter-1.2.8.tar.gz
tar -zxf rkhunter-1.2.8.tar.gz
cd rkhunter
-----command-----
Install it
-----command-----
./installer.sh
-----command-----
Now create a cronjob so it will email you with notifications to the root mailbox:
-----command-----
crontab -e
-----command-----
Now the crontab is going to be created. The first line is an update function so that you can be assured your rkhunter has the latest rules before it scans your system. The second line will run the actual scan an email root the results. At the bottom add the following line
10 0 * * * /usr/local/bin/rkhunter --update > /dev/null 2>&1
25 0 * * * /usr/local/bin/rkhunter -c --nocolors --cronjob --report-mode --createlogfile --skip-keypress --quiet
Press control x to save
|
http://www.eth0.us/rkhunter
Quote:
A firewall is a very good idea for a server. Though many people think that a firewall is instant protection that will do everything it really is not. A firewall will help prevent some things but it is not going to stop everything. It is just one piece of the security network that is being woven. I recommend advanced protection firewall (APF) by rfxnetworks. APF will block unused outgoing and incoming ports. It can also be configured to use information from some block lists. The below port list will work for cPanel. For the other control panels you will need to add in the administration ports.
http://www.rfxnetworks.com/apf.php
-----command-----
cd /usr/local/src
wget http://rfxnetworks.com/downloads/apf-current.tar.gz
tar -zxf apf-current.tar.gz
cd apf-0.*
./install.sh
-----command-----
Now edit config file
-----command-----
pico -w /etc/apf/conf.apf
-----command-----
Scroll down to the "Common ingress (inbound) TCP ports section. At this point you need to find the correct configuration for your control panel.
-----cPanel -----
IG_TCP_CPORTS="20,21,22,25,26,53,80,110,143,443,465,993,995,2082, 2083,2086,2087,2095,2096"
IG_UDP_CPORTS="21,53,873"
EGF="1"
EG_TCP_CPORTS="21,22,25,26,27,37,43,53,80,110,113,443,465,873,208 9"
EG_UDP_CPORTS="20,21,37,53,873"
----Ensim -----
IG_TCP_CPORTS="21,22,25,53,80,110,143,443,19638"
IG_UDP_CPORTS="53"
EGF="1"
EG_TCP_CPORTS="21,22,25,53,80,110,443"
EG_UDP_CPORTS="20,21,53"
----Plesk -----
IG_TCP_CPORTS="20,21,22,25,53,80,110,143,443,465,993,995,8443"
IG_UDP_CPORTS="37,53,873"
EGF="1"
EG_TCP_CPORTS="20,21,22,25,53,37,43,80,113,443,465,873,5224"
EG_UDP_CPORTS="53,873"
Save the file and start apf via.
-----command-----
apf -s
-----command-----
If everything still works then edit the config file and turn dev mode off. Make sure you can start a new ssh session before changing dev mode off. If you are kicked out you need to go back and look at what caused the problem!
DEVEL_MODE="0"
Now restart APF
-----command-----
apf -r
-----command-----
|
http://www.eth0.us/apf
Quote:
Miscellaneous system tweaks
In this guide I am going to go over some basic system tweaks that will help the security of your server. None of are that big of a deal but every little bit helps secure your server more.
Updated Feb 18 to include enabling syncookies
The first thing we are going to do is to enable tcp_syncookies by simply typing the following command.
-----command-----
echo 1 > /proc/sys/net/ipv4/tcp_syncookies
-----command-----
For an explanation of syncookies please refer to this website: http://cr.yp.to/syncookies.html Basically it will allow the server to distinguish SOME legitimate connections from those that are meant to be malicous. It will help with a few different types of DOS style attacks.
Next we are going to do is harden resolv.conf because if improperly configured it can be used to spoof or create a DOS attack. First go ahead and open up the config file:
-----command-----
pico -w /etc/resolv.conf
-----command-----
You should see something like "nameserver xxx.xxx.xxx.xxx" and maybe "search xxx.com". The important thing is that 127.0.0.1 is NOT listed. At the top you should have your servers internet ip address. This will function basically the same as 127.0.0.1 as many servers were configured with but it is less prone to attacks. You can also remove the search line as it is not needed. Once you are done save out of the config and you are all done.
Next we will look at the /etc/hosts to ensure that it is properly setup and remove additional entries.
-----command-----
pico -w /etc/hosts
-----command-----
You should only have 2 lines listed. One of them should be 127.0.0.1 and to the right of it should be localhost. The second line should have yout servers internet ip and to the right of it should be your servers hostname beside your servers full hostname + domainname (example hostname.domain.com and hostname). If you have any entires that are still there you can go ahead and remove them as they are not needed. Save out and you are done.
Next we will secure sshd.
-----command-----
pico -w /etc/ssh/sshd_config
-----command-----
Locate the line with "Protocol" in it and change it so that it reads "Protocol 2". This will let ssh only connect on protocol 2 which is more secure and is compatible with any modern client. If for some reason your current client does not support protocol 2 Putty is free and supports it.
Another very good option is to disable root logins. **NOTE** If you do this you need to make sure that you have added a user to the wheel group and have ensured that they are able to "su -" root. Do not turn this feature on without testing that you can first login as another user and gain root access, you have been warned! Look for "PermitRootLogin" and change it to read "PermitRootLogin no".
Save and restart sshd via "service sshd restart".
Many php exploit scritps use common *nix tools to download rootkits or backdoors. By simply chmod'ing the files so that no none-wheel or root user can use them we can eliminate many possible problems. The downside to doing this is that shell users will be inconvenienced by not being able to use the the commands below. This may cause some problem if your users are trying to use commands such as wget which is very popular with shell users. If you use mod_security these programs should be blocked out from access to apache which is the main concern.
-----command-----
chmod 750 /usr/bin/rcp
chmod 750 /usr/bin/wget
chmod 750 /usr/bin/lynx
chmod 750 /usr/bin/links
chmod 750 /usr/bin/scp
-----command-----
|
http://www.eth0.us/node/6
__________________
Server Systems Administration NZ
SSANZ.NET | Server Security | Hosting Systems
Experienced, Professional & Available 24/7
|