Sunday 29 May 2011

OpenVPN - Installation

Install Script for OpenVZ VPS - CENTOS / DEBIAN / UBUNTU

CENTOS: http://bluemodule.com/

Download Link:
http://bluemodule.com/wp-content/plugins/wp-codebox/wp-codebox.php?p=202&download=ovpn_install_script.sh


DEBIAN / UBUNTU:
http://www.putdispenserhere.com/2011/openvpn-debianubuntu-setup-script-for-openvz/

Download Link:
http://www.putdispenserhere.com/wp-content/uploads/openvpninstall.sh


After running the above scripts surfing/browsing to google.com or other sites will not allow you.

You have to execute the below commands on the VPS

#ifconfig -a | grep P-t-P

inet addr:10.9.0.1 P-t-P:10.9.0.2 Mask:255.255.255.255
inet addr:127.0.0.1 P-t-P:127.0.0.1 Bcast:0.0.0.0 Mask:255.255.255.255
inet addr:8X.8X.2XX.XX P-t-P:8X.8X.2XX.XX Bcast:8X.8X.2XX.XX Mask:255.255.255.255

Note: P-t-P:10.9.0.2 - For tun0

#iptables -t nat -A POSTROUTING -s 10.9.0.0/32 -o eth0 -j MASQUERADE
#/etc/init.d/iptables save
#/etc/init.d/iptables restart

or

#iptables -A POSTROUTING --table nat -o eth0 -j MASQUERADE
#/etc/init.d/iptables save
#/etc/init.d/iptables restart

Note: Please make sure to enable the TUN / TAP / PPPD / IPTABLES on your VPS

Wednesday 25 May 2011

Rapidleech installation for Ubuntu

Install LAMP Server;
apt-get install -y lamp-server

If you are facing any issue while installing the LAMP, you can refer the below URL
http://www.howtoforge.com/ubuntu_lamp_for_newbies


cd /var/www/
wget http://rapidleech.googlecode.com/files/rapidleech-svn322.zip
unzip rapidleech-svn322.zip
mv r322 leech
cd leech
chmod 777 -R files/ configs/

Run a browser and access the address leech, http://localhost/leech .

On the web Rapidleech content Link to Tranload dialog box with a link that will be downloaded as hotfile or rapidshare, and then click the link to transload;

Sunday 22 May 2011

Installing cPanel & WHM

Installing cPanel & WHM

Make sure you are logged in as root

To begin your installation, use the following commands:

1. Open the /home directory by typing the command cd /home

2. Fetch the latest installation file from the cPanel servers by typing the command

wget -N http://httpupdate.cpanel.net/latest

3. Open and run the installation files by typing the command

sh latest

If licensing has failed (due to a strict firewall or changed IP), execute the following command to activate your license:

* /usr/local/cpanel/cpkeyclt

Note: For FreeBSD, you need to download and untar the latest installer package from www. cpanel.net

Wednesday 11 May 2011

Monitoring/security of Exim

Number of emails in the mail queue:

#exim -bpc


Frozen mails in a Queue

#exim -bp | grep -c frozen

#exim -bpr | grep frozen | wc -l



Removing all frozen messages:

#exiqgrep -z -i | xargs exim -Mrm

or

#exim -bpru | grep “frozen” | awk {‘print $3′} | xargs exim -Mrm


Deliver forcefully emails

#exim -qff -v -C /etc/exim.conf &


Remove mails from sender

#exiqgrep -i -f (mail add here) | xargs exaim -Mrm


Remove mails from Recipient

#exiqgrep -i -r (mail add here) | xargs exaim -Mrm


Below command will display total number of emails send as well receive statistics per domain basis.

#exim -bp | exiqsumm | sort -n


Delete mails for particular domain which is largest email sender you got by previous step

#exiqgrep -i -r domainname.com | xargs exim -Mrm


Number of emails sent by perticular domain greping by date:

#grep “Sept 18″ /var/log/exim_mainlog | grep domainname.com | wc -l


Get the content of an email by message ID

#exim -Mvb messageid

Force delivery of single email

#exim -M email-id


Delete particular message ID

#exim -Mg messageid


Delete the entire mail queue

#exim -bpru | awk {‘print $3′} | xargs exim -Mrm


Check all mails by username

#exigrep -u username /var/log/exim_mainlog


View an email’s header

#exim -Mvh message-id


View an email’s body

#exim -Mvb message-id


Deliver all emails in mailqueue forcefully

#exiqgrep -i | xargs exim -M

How to repair all MySQL Databases on a cPanel/WHM Server

There can be different reasons why one wants to repair a MySQL database. Database corruption maybe due to a lack of disk space or an unexpected server shutdown that caused the database to go bad. Queries that worked before suddenly stopped working and overall the database is not behaving anymore as expected. This guide shall not be a full database troubleshooting guide, but rather give you a hand on doing a MySQL repair on all databases on a cPanel/WHM server (or any other server running MySQL).

The situation: Your server crashed hard and when it is back up the MySQL side of the house is not working anymore. You do your normal troubleshooting. If all other troubleshooting and verifications are done, you come to the conclusion that you will need to run a repair as the next step. A full database restore from a (hopefully existing) good database backup would be your last choice.

Repairing one MySQL database is fairly easy, but how do you do this for an entire server holding20, 30, 50 or over 100 databases? You will need SSH access as the root user to the server running MySQL. So, log in as the root user and then do the following to repair your MySQL databases:

Please be advised that you should backup critical databases before running any of the commands below:

Option #1

Check if you any need DB repair:

#myisamchk –check /var/lib/mysql/*/*.MYI

Then try a ‘safe-recover’ as the first step:

#myisamchk –safe-recover /var/lib/mysql/*/*.MYI

If the ‘safe-recover’ does not work, run a full recover:

#myisamchk –recover /var/lib/mysql/*/*.MYI

Then use the ‘force’ flag to get things back to normal:

#myisamchk –safe-recover –extend-check –force /var/lib/mysql/*/*.MYI
or

#myisamchk –recover –extend-check –force /var/lib/mysql/*/*.MYI


Option #2

Use the mysqlcheck tool to repair your databases.
#mysqlcheck -–all-databases -r #repair

#mysqlcheck -–all-databases -a #analyze

#mysqlcheck -–all-databases -o #optimize

There you have it. By using one of these two options you should be able to repair and recover your databases. Please be advised that you should backup critical databases before running any of the commands above. If something goes wrong you can revert back and try again.

Rapidleech installation on VPS Centos 5

Install apache + php5

yum install httpd
yum install php php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc
service httpd start
chkconfig httpd on

cd /var/www/html
wget http://rapidleech.googlecode.com/files/rapidleech-svn322.zip
unzip *.zip
cp -r r322/* /var/www/html/
rm -r -f r322
chmod 777 files
chmod 777 configs
cd configs
chmod 777 files.lst

Restart

Done

http://Ip_address

Chkrootkit Installation

Chkrootkit is a tool to locally check for signs of a rootkit. It contains a chkrootkit: shell script that checks system binaries for rootkit modification.


Installation:– Login to your server as root. (SSH)

cd /usr/local/src
– Down load the chkrootkit.# wget ftp://ftp.pangeia.com.br/pub/seg/pac/chkrootkit.tar.gz
- Unpack the chkrootkit you just downloaded.# tar -xvzf chkrootkit.tar.gz
- Change to new directory# cd chkrootkit*
- Compile chkrootkit# make sense
- Run chkrootkit# ./chkrootkit

How to setup a daily scan report?
- Load crontab# crontab -e
- Add this line to the top:==========================================================================
0 1 * * * (cd /path/to/chkrootkit; ./chkrootkit 2>&1 | mail -s “chkrootkit output” email@domain.com)
==========================================================================

E.G:0 1 * * * (cd /usr/local/src/chkrootkit-0.49; ./chkrootkit | mail -s “chkrootkit output” test@unixnethost.com )

This will run CHKROOTKIT at 1am every day, and e-mail the output to root. (you need change the time whenever you want it to run and the email id according to your needs.)

Save and exit