Powered By Blogger

Search This Blog

04 October, 2010

install configure server firewall on your cPanel Server

Installation
============
Installation is quite straightforward:

rm -fv csf.tgz
wget http://www.configserver.com/free/csf.tgz
tar -xzf csf.tgz
cd csf
sh install.sh

Next, test whether you have the required iptables modules:

perl /etc/csf/csftest.pl

Don't worry if you cannot run all the features, so long as the script doesn't
report any FATAL errors

You should not run any other iptables firewall configuration script. For
example, if you previously used APF+BFD you can remove the combination (which
you will need to do if you have them installed otherwise they will conflict
horribly):

sh /etc/csf/remove_apf_bfd.sh

That's it. You can then configure csf and lfd by edit the files
directly in /etc/csf/*, or on cPanel servers use the WHM UI

csf installation for cPanel is preconfigured to work on a cPanel server with all
the standard cPanel ports open.

csf installation for DirectAdmin is preconfigured to work on a DirectAdmin
server with all the standard DirectAdmin ports open.

csf auto-configures your SSH port on installation where it's running on a non-
standard port.

csf auto-whitelists your connected IP address where possible on installation.

You should ensure that kernel logging daemon (klogd) is enabled. Typically, VPS
servers have this disabled and you should check /etc/init.d/syslog and make
sure that any klogd lines are not commented out. If you change the file,
remember to restart syslog.

See the readme.txt file for more information.

Webmin Module Installation/Upgrade
==================================

To install or upgrade the csf webmin module:

Install csf as above
Install the csf webmin module in:
Webmin > Webmin Configuration > Webmin Modules >
From local file > /etc/csf/csfwebmin.tgz > Install Module


Uninstallation
==============
Removing csf and lfd is even more simple:

On cPanel servers:

cd /etc/csf
sh uninstall.sh

On DirectAdmin servers:

cd /etc/csf
sh uninstall.directadmin.sh

On generic linux servers:

cd /etc/csf
sh uninstall.generic.sh

Rename package names on cPanel server.

Many time we like to rename package name for our hosting accounts but as hosting account is assigned to large number of user and we can’t reassign package one by one to all users as its time consuming process at that time we can refer following steps to secure time.

First login in to shell as root user.

root@server [~]# cd /var/cpanel/packages/

Now rename package for test purpose, we are renaming test_test package to test_support package.

root@server [/var/cpanel/packages]# mv test_test test_support

Now make sure that you reassign package to your users who are currently using test_test package.

root@server [/var/cpanel/packages]# cd /var/cpanel/users

Now search users who are currently using test_test package.

root@server [/var/cpanel/users]# grep test_test * -R
admin12:PLAN=test_test
test12:PLAN=test_test

Now simply run following command to replace all instance for test_test package in users file with new package name test_support

root@server[/var/cpanel/users]# grep test_test * -R -l > rename-packages

The above command will store all users name who currently using test_test package in rename-packages file.

root@server [/var/cpanel/users]# cat rename-packages
admin12
test12

Now create new file packages.sh with the following code.

root@server [/var/cpanel/users]# pico packages.sh

#!/bin/sh
dir=”/var/cpanel/users/”
fstr=”test_test”
rstr=”test_support”
exec 3<&0
exec 0<”/var/cpanel/users/rename-packages”
while read LINE ; do
sed -i “s/$fstr/$rstr/” “$LINE”
done

Set executable permission to file packages.sh file.

root@server [/var/cpanel/users]#chmod 755 packages.sh

Before running packages.sh file check one of the users file and check package name.

root@server [/var/cpanel/users]# cat admin12
# cPanel — If you edit this file directly you must run /scripts/updateuserdomains afterwards to rebuild the system caches
BWLIMIT=unlimited
CONTACTEMAIL=
CONTACTEMAIL2=
DEMO=0
DNS=server.com
FEATURELIST=default
HASCGI=1
IP=xx.xx.xx.xx
LANG=english
LOCALE=en
MAXADDON=5
MAXFTP=0
MAXLST=0
MAXPARK=0
MAXPOP=0
MAXSQL=0
MAXSUB=0
MTIME=1283914039
MXCHECK-server.com=0
OWNER=root
PLAN=test_test
RS=x3
STARTDATE=1269778722
USER=admin12

Now run file packages.sh

root@server [/var/cpanel/users]#./packages.sh

After running packages.sh file you can check user file name and found out that package name is changed.

root@server [/var/cpanel/users]# cat admin12
# cPanel — If you edit this file directly you must run /scripts/updateuserdomains afterwards to rebuild the system caches
BWLIMIT=unlimited
CONTACTEMAIL=
CONTACTEMAIL2=
DEMO=0
DNS=server.com
FEATURELIST=default
HASCGI=1
IP=xx.xx.xx.xx
LANG=english
LOCALE=en
MAXADDON=5
MAXFTP=0
MAXLST=0
MAXPARK=0
MAXPOP=0
MAXSQL=0
MAXSUB=0
MTIME=1283914039
MXCHECK-server.com=0
OWNER=root
PLAN=test_support
RS=x3
STARTDATE=1269778722
USER=admin12

Note : The above steps useful to rename packages for users , it will not change any value like addon , parked domain limit etc.