This page looks plain and unstyled because you're using a non-standard compliant browser. To see it in its best form, please upgrade to a browser that supports web standards. It's free and painless.

Blog About Dedicated Servers

« | »

HOW-TO: Secure cPanel

Luigi Ramone | 30 November, 2005 21:43

First and foremost I want to say that this is not going to make your server 100% cracker proof, there is always a possibility that somebody will find a way in. I have listed a lot of things you can do to protect your server and that will help you secure it. While securing your server you have to find a median between what is secure and what restricts your clients or websites. You can easily make your server 100% secure from remote attacks by unplugging the ethernet cable, but chances are you will not get much good with it. This is not a complete guide and I will update it when I find time or it needs it. Overall it is a very good start and it is probably more then most servers have.

If you have any problems with the guide please post them and I will try and help/update the guide. I have not included everything you can do but it is a very good start. If you need somebody to secure server please feel free to private message or email me.

All commands meant to be run in ssh will begin with "#"



--------------------------

First step is to updated your software. Make sure up2date says you are fully updated:
#up2date -u

Now update the kernel. Below I have posted the directions for a server using lilo as the bootloader. I will add in directions for grub later as I do not run grub on any of my servers. If you are using grub please skip this section and upgrade the kernel at another time.

#cd /var/spool/up2date

If you have a dual processor server:

#up2date --download --force kernel-smp
#rpm -ivh kernel-smp-2.4.21-15.0.4.EL.i686.rpm
#lilo -v -v
#lilo -R 2.4.21-15.0.4.1
#shutdown -r now

If you have a single processor server:
#up2date --download --force kernel
#rpm -ivh kernel-2.4.21-15.0.4.EL.i686.rpm
#lilo -v -v
#lilo -R 2.4.21-15.0.4.1E
#shutdown -r now


When you run lilo -v -v make sure that no errors appear, if so you probably need to look at the lilo.conf for the problem.

The lilo -R command will make it reboot only once to the new kernel. If for some reason just put in a reboot TT and it will automatically boot to the old kernel. If it comes back up fine then you can edit the /etc/lilo.conf and set "default=" the new kernel label.


--------------------------


A firewall should be the first thing installed.. 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.
http://rfxnetworks.net/apf.php
#cd /usr/src
#wget http://rfxnetworks.net/downloads/apf-current.tar.gz
#tar -zxf apf-current.tar.gz
#cd apf-0.*
#./install.sh

Now edit config file
#pico -w /etc/apf/conf.apf

Change the following:
USE_DS="1"
USE_AD="1"


Scroll down to this section:


# Common ingress (inbound) TCP ports IG_TCP_CPORTS="20,21,22,25,26,53,80,110,143,443,465,993,995,2082, 2083,2086,2087,2095,2096"
# Common ingress (inbound) UDP ports
IG_UDP_CPORTS="21,53,465,873"

# Common ICMP (inbound) types
# 'internals/icmp.types' for type definition; 'all' is wildcard for any
IG_ICMP_TYPES="3,5,11,0,30,8"


Scroll down a bit then find this section:

EGF="1"
# Common egress (outbound) TCP ports EG_TCP_CPORTS="21,22,25,26,27,37,43,53,80,110,113,443,465,873,208 9"
# Common egress (outbound) UDP ports
EG_UDP_CPORTS="20,21,53,123,465,873"


Save the file and start apf via.
apf -s
If everything still works then edit the config file and turn dev mode off.
DEVM="0"

Now restart APF
#apf -r


--------------------------


The following scripts are fairly easy to use and install, I might add documentation later but for now I will not.

Along with installing APF I would suggest installing brute force monitor (BFD) also by rfxnetworks. BFD will monitor your ssh and ftp services and automatically ban users that try to brute force a password. If you install BFD make sure you can get a separate ip to ssh into your server incase it blocks you for some reason! You can add your ip to the allow list via "apf -a IP" if you have a static ip.
http://rfxnetworks.net/bfd.php


Yet another very handy tool by rfxnetworks is socket monitor (PMON). This tool will alert you whenever a new port is opened on the server. This is very helpful in detecting any users running weird processes or attempting to run backdoors. When any program that it does not recognized is started it will email you with the information.
http://rfxnetworks.net/pmon.php


Another tool I would suggest, but that is not really part of securing your server, is system integrity monitor (SIM) which is also by rfxnetworks. SIM will automatically detect when a service is down and restarts it.
http://rfxnetworks.net/sim.php


I always recommend to turn off compilers. Most rootkits come precompiled but not all of them do. It will also prevent shell users from trying to compile any irc related programs. To turn the compilers on switch the off to on.
/scripts/compilers off


--------------------------


mod_security

First we will download and unzip mod_security. This guide compiles for apache1.3.x which is what cPanel currently uses.
#wget http://www.modsecurity.org/download...ty-1.8.4.tar.gz
#tar zxf mod_security-1.8.4.tar.gz
#cd mod_security-1.8.4/apache1


Next compile mod_security at a module:
#/etc/httpd//bin/apxs -cia mod_security.c

Make a backup of your httpd.conf before touching anything so you have something to go back to if it does not work.
#cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf-mod_sec

Now edit the httpd.conf
pico -w /etc/httpd/conf/httpd.conf


Scroll down below the following line:
AddModule mod_security.c
The rules listed in the text file below can just be pasted in. They are a collection of rules, many of them taken from snort, that block most of the common attacks while still letting normal requests by.
http://eth0.us/faq/modsec.txt

Create the error log file:
#touch /var/log/httpd/audit_log

Restart apache
#service httpd restart

If sites start to have problems look at error log.
/var/log/httpd/audit_log


--------------------------


The /tmp partition is one the common places for script kiddies and crackers alike to place trojans or scripts. Because of that you should have the /tmp partition mounted noexec. First we need to check if your /tmp is secure.
#df -h |grep tmp

If that displays nothing then go below to create a tmp partition. If you do have a tmp partition you need to see if it mounted with noexec.
#cat /etc/fstab |grep tmp

If there is a line that includes /tmp and noexec then it is already mounted as non-executable. You will also want to check if /var/tmp is linked to /tmp.
ls -alh /var/ |grep tmp

If it shows something to the effect of "tmp -> /tmp/" then you are ok. If not go ahead an remove the old /var/tmp and replace it with a sym link to /tmp.
#rm -rf /var/tmp/
#ln -s /tmp/ /var/


If you do not have any /tmp partition you will need to follow the directions below to create and mount a partition.

Create a 190Mb partition
#cd /dev/; dd if=/dev/zero of=tmpMnt bs=1024 count=200000

Format the partion
#mke2fs /dev/tmpMnt


Make a backup of the old data
#cp -Rp /tmp /tmp_backup

Mount the temp filesystem
#mount -o loop,noexec,nosuid,rw /dev/tmpMnt /tmp

Set the permissions
#chmod 0777 /tmp

Copy the old files back
#cp -Rp /tmp_backup/* /tmp/

Once you do that go ahead and start mysql and make sure it works ok. If it does you can add this line to the bottom of the /etc/fstab to automatically have it mounted:
/dev/tmpMnt /tmp ext2 loop,noexec,nosuid,rw 0 0

Next delete the old /var/tmp and create a link to /tmp
#rm -rf /var/tmp/
#ln -s /tmp/ /var/

If everything still works fine you can go ahead and delete the /tmp_backup directory.
#rm -rf /tmp_backup


--------------------------


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. Mod_security really removes the need to chmod this, but it is an added layer of protection.

#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

--------------------------


Now we will install rkhunter so we will atleast know if the server has been cracked.

Download and unzip rkhunter
#cd /usr/local/src/
#wget http://downloads.rootkit.nl/rkhunter-1.1.4.tar.gz
#tar -zxf rkhunter-1.1.4.tar.gz
#cd rkhunter

Install it
#./install.sh

Now create a cronjob so it will email you with notifications to the root mailbox:
#crontab -e

At the bottom add the following line
16 0 * * * /usr/local/bin/rkhunter -c --nocolors --cronjob --report-mode --createlogfile --skip-keypress --quiet

Press control x to save


--------------------------

Credits: John W - Security and general linux how-to's

スワッピング [Reply]

スワッピングセックス童貞童貞セフレナンパアダルトエロ不倫セックス出会いエロSEXセックスおっぱい不倫熟女エッチ風俗セックス

スワッピング | 09/10/2008, 01:44

スワッピング [Reply]

スワッピングセックス童貞熟女人妻セフレナンパエロセックス出会いセックス童貞風俗アダルトセックス巨乳エッチ童貞童貞おっぱいセフレ

スワッピング | 30/10/2008, 02:10

SEO [Reply]

SEOとは、SEO対策検索エンジン最適化)とも呼ばれ、検索エンジンでより上位に表示させる技術のこと。Yahoo! SEOが日本ではシェアを持っていることもあり、重要。SEM(検索エンジンマーケティング)とはよく比較される。家庭教師に依頼して受験勉強に合格できるように派遣してもらいましょう。東京大阪を中心に全国どこでも派遣できます。バイク査定を依頼するなら一括査定ができるサイトを選びましょう。中古のバイクも高値で買取してくれます。簡単に収益の高いWEBサイトを買うならサイト売買を利用しましょうオークション形式で購入することも可能です。仲介になってくれるので簡単査定スピード買取が可能です。ビジネスマナービジネスマンにとって必須です。ビジネス文書が書けるように研修などを受けて自己啓発に励みましょう。クレジットカードランキングで徹底比較しています。審査がスピーディーで簡単。クレジットローンをご利用の方におすすめ。美容整形が今注目を集めています。美容人気で値段も安価なので今がチャンス!美容形成美容外科選びは口コミ情報で探す方がいいですね。占い無料で使える占い総合サイト。恋愛占いから相性動物占いまで様々な占いコンテンツが充実しています。訪問者の数を計測できるアクセスカウンターは、簡単ですぐにはじめられるアクセスカウンタを使ってみてはいかがですか。無料カウンターなので、余計な手続きは必要ありません。無料カウンタですぐにホームページのアクセス数を計測しましょう。生命保険を検討されている方は一括見積もりをしてみましょう。ランキングによる比較をしてオススメ生命保険を格付け!あなたに合った生命保険プランが見つかります。

SEO | 13/11/2008, 07:33

SEO [Reply]

SEOSEO対策検索エンジン最適化SEMYahoo! SEO家庭教師受験派遣東京大阪バイク査定一括中古買取サイト売買オークション仲介WEBサイト査定ビジネスマナービジネスビジネス文書研修自己啓発クレジットカードランキング審査比較ローン美容整形美容美容形成美容外科口コミ占い無料恋愛相性動物アクセスカウンターアクセスカウンタ無料カウンター無料カウンタ簡単生命保険一括見積もりランキング比較格付け

SEO | 13/11/2008, 10:28

SEO [Reply]

SEOとは、SEO対策検索エンジン最適化)とも呼ばれ、検索エンジンでより上位に表示させる技術のこと。Yahoo! SEOが日本ではシェアを持っていることもあり、重要。SEM(検索エンジンマーケティング)とはよく比較される。家庭教師に依頼して受験勉強に合格できるように派遣してもらいましょう。東京大阪を中心に全国どこでも派遣できます。バイク査定を依頼するなら一括査定ができるサイトを選びましょう。中古のバイクも高値で買取してくれます。簡単に収益の高いWEBサイトを買うならサイト売買を利用しましょうオークション形式で購入することも可能です。仲介になってくれるので簡単査定スピード買取が可能です。ビジネスマナービジネスマンにとって必須です。ビジネス文書が書けるように研修などを受けて自己啓発に励みましょう。クレジットカードランキングで徹底比較しています。審査がスピーディーで簡単。クレジットローンをご利用の方におすすめ。美容整形が今注目を集めています。美容人気で値段も安価なので今がチャンス!美容形成美容外科選びは口コミ情報で探す方がいいですね。占い無料で使える占い総合サイト。恋愛占いから相性動物占いまで様々な占いコンテンツが充実しています。訪問者の数を計測できるアクセスカウンターは、簡単ですぐにはじめられるアクセスカウンタを使ってみてはいかがですか。無料カウンターなので、余計な手続きは必要ありません。無料カウンタですぐにホームページのアクセス数を計測しましょう。生命保険を検討されている方は一括見積もりをしてみましょう。ランキングによる比較をしてオススメ生命保険を格付け!あなたに合った生命保険プランが見つかります。

SEO | 03/12/2008, 02:35

SEO [Reply]

SEOSEO対策検索エンジン最適化SEMYahoo! SEO家庭教師受験派遣東京大阪バイク査定一括中古買取サイト売買オークション仲介WEBサイト査定ビジネスマナービジネスビジネス文書研修自己啓発クレジットカードランキング審査比較ローン美容整形美容美容形成美容外科口コミ占い無料恋愛相性動物アクセスカウンターアクセスカウンタ無料カウンター無料カウンタ簡単生命保険一括見積もりランキング比較格付け

SEO | 03/12/2008, 02:36

SEO [Reply]

SEOSEO対策検索エンジン最適化SEMYahoo! SEO家庭教師受験派遣東京大阪バイク査定一括中古買取サイト売買オークション仲介WEBサイト査定ビジネスマナービジネスビジネス文書研修自己啓発クレジットカードランキング審査比較ローン美容整形美容美容形成美容外科口コミ占い無料恋愛相性動物アクセスカウンターアクセスカウンタ無料カウンター無料カウンタ簡単生命保険一括見積もりランキング比較格付け

SEO | 31/12/2008, 01:31

SEO [Reply]

SEOとは、SEO対策検索エンジン最適化)とも呼ばれ、検索エンジンでより上位に表示させる技術のこと。Yahoo! SEOが日本ではシェアを持っていることもあり、重要。SEM(検索エンジンマーケティング)とはよく比較される。家庭教師に依頼して受験勉強に合格できるように派遣してもらいましょう。東京大阪を中心に全国どこでも派遣できます。バイク査定を依頼するなら一括査定ができるサイトを選びましょう。中古のバイクも高値で買取してくれます。簡単に収益の高いWEBサイトを買うならサイト売買を利用しましょうオークション形式で購入することも可能です。仲介になってくれるので簡単査定スピード買取が可能です。ビジネスマナービジネスマンにとって必須です。ビジネス文書が書けるように研修などを受けて自己啓発に励みましょう。クレジットカードランキングで徹底比較しています。審査がスピーディーで簡単。クレジットローンをご利用の方におすすめ。美容整形が今注目を集めています。美容人気で値段も安価なので今がチャンス!美容形成美容外科選びは口コミ情報で探す方がいいですね。占い無料で使える占い総合サイト。恋愛占いから相性動物占いまで様々な占いコンテンツが充実しています。訪問者の数を計測できるアクセスカウンターは、簡単ですぐにはじめられるアクセスカウンタを使ってみてはいかがですか。無料カウンターなので、余計な手続きは必要ありません。無料カウンタですぐにホームページのアクセス数を計測しましょう。生命保険を検討されている方は一括見積もりをしてみましょう。ランキングによる比較をしてオススメ生命保険を格付け!あなたに合った生命保険プランが見つかります。

SEO | 31/12/2008, 01:51

Add comment

Topic

Text

Your name

Your email address (if any)

Your personal page (if any)


authimage




Powered by Boonic, Bloogo & pLog
This Blog does not have any affiliation nor relation with the mentioned companies. All the logotipos, trade names and images are property of the companies that registered them.