Sunday, October 24, 2010

How To Transfer Account Manually

To transfer an account using shell is as follows :-

--------------------*****************************----------------------

1)-Commands to run on the "Old Server".

/scripts/pkgacct (user name)

Change permmissions to 755.

Change owner to nobody.nobody.

move tar file to /usr/local/apache/htdocs

*********************************************************

2)-Commands to run on "New Server".

wget http://67.45.15.26/cpmove-sacrowd.tar.gz/scripts/restorepkg sacrowd

*********************************************************

Installing YUM

*Note-Please first Download the .tar source & Set it up it is not hard read the read-me file in it.

Fire this commands given below :-

As root,
cd ~
mkdir setups
cd setups
wget http://linux.duke.edu/projects/yum/download/2.0/yum-2.0.7.tar.gz
tar -xvzf yum-2.0.7.tar.gz
cd yum-2.0.7
./configure
make
make install
----------------------------------------------------------
Its so simple isn't it.

How to install spam log

***Following are the steps to install Spam_log***


-------------************************--------------
 1)- Login to your server & su - to root.

****************************************************

 2)-Turn off exim while we do this so it doesn't freak out :-

#/etc/init.d/exim stop

****************************************************

 3)-Backup your original /usr/sbin/sendmail file, On systems using Exim MTA, the sendmail file is just basically a pointer to Exim itself :-

#mv /usr/sbin/sendmail /usr/sbin/sendmail.hidden

****************************************************

4)-Create the spam monitoring-script for the new sendmail :-

#pico /usr/sbin/sendmail

Paste in the following:-

#!/usr/local/bin/perl
# use strict;
use Env;
my $date = `date`;
chomp $date;
open (INFO, ">>/var/log/spam_log") || die "Failed to open file ::$!";
my $uid = $>;
my @info = getpwuid($uid);
if($REMOTE_ADDR) {
print INFO "$date - $REMOTE_ADDR ran $SCRIPT_NAME at $SERVER_NAME n";
}
else {

print INFO "$date - $PWD - @infon";

}
my $mailprog = '/usr/sbin/sendmail.hidden';
foreach (@ARGV) {
$arg="$arg" . " $_";
}

open (MAIL,"|$mailprog $arg") || die "cannot open $mailprog: $!n";
while (<STDIN> ) {
print MAIL;
}
close (INFO);
close (MAIL);

****************************************************

 5)-Change the new sendmail permissions :-

#chmod +x /usr/sbin/sendmail

****************************************************

6)-Create a new log file to keep a history of all mail going out of the server using web scripts :-

#touch /var/log/spam_log

chmod 0777 /var/log/spam_log

****************************************************

7)-Start Exim up again :-

#/etc/init.d/exim start

****************************************************

8)-Monitor your spam_log file for spam, try using any formmail or script that uses a mail function - a message board, a contact script :

#tail - f /var/log/spam_log

Sample Log Output

Mon Apr 11 07:12:21 EDT 2005 - /home/username/public_html/directory/subdirectory - nobody x 99 99 Nobody / /sbin/nologin

Log Rotation Details :-
Your spam_log file isn't set to be rotated so it might get to be very large quickly, Keep an eye on it and consider adding it to your logrotation.

#pico /etc/logrotate.conf

FIND :-

/var/log/wtmp {
monthly
create 0664 root utmp
rotate 1
}

ADD BELOW :-

# SPAM LOG rotation
/var/log/spam_log {
monthly
create 0777 root root
rotate 1
}

****************************************************
Now Just sit and enjoy .

How to install IPtables

This are some basic steps for install IP tables:-


1)  Get the iptables tarball containing all the needed files.-

          -To get the latest version of iptables go to netfilter.org

          - Downloads are available at http://www.netfilter.org/downloads.html

          - The file should be named iptables-1.*.*.tar.bz2 where the asterisks represent the numbers of the       latest version.

          -Save this file to a temporary directory, we will use /tmp in this example.
-----------------------------------------------------------------------------

 2) Open a terminal window.

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

 3) Change your directory to where you saved iptables by typing:-

      # cd /tmp

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

4) Uncompress the archive to the /usr/src directory by typing:-

      # tar -xvjf ./iptables-1.*.*.tar.bz2 -C /usr/src

      where the asterisks represent the version number of the file you downloaded,

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

5) Change to the directory it created (typically iptables-1.*.*), by typing:-

      # cd /usr/src/iptables-1.*.*

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

6) Using the kernel directories above, type:-

      # /bin/sh -c make

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

7) To finish the install, type:-

      # /bin/sh -c make install

- Iptables should now be installed, You can test the installation as described in the beginning of this section to see if it is working.

- If the above install steps seemed to execute without any error, but typing:-

# iptables -V

- Brings up an error, it is possible that the program did'n install itself to the sbin directory, To fix this type the following command from the iptables-1.*.* directory:

ComputerName:~# cp ./iptables /sbin

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

How To change IP in server

*Note:- Hey Remember < You need to set RDNS for the IP then and then Only you can proceed further.>
-------------------------------------------------------------------------------------
If you are in the danger of getting your main server IP block by SpamCop because you had a few anoying spamers abusing your server, then you could simply change your exim mailserver IP to avoid the effect of your main IP beeing blacklisted.

--Below there are some simple steps of changing your exim IP:---

Inside both incoming & outgoing exim mail server you will need to add an interface :-
( So just edit )

pico /etc/exim_outgoing.conf

and

pico /etc/exim.conf

find
remote_smtp:
driver = smtp

& add interface = ip.you.want.to.use

--------------------------------
Example is as shown below:-

remote_smtp:
driver = smtp
interface = 22.22.22.22
-------------------------------

IP needs to be on server in order for this to work, hopefully this will help.
BTW: Just a reminder - If there is an exim update when you upgrade your cpanel server you will need to re-enter the interface again.

How to install postgresql

Follow this step:-

*Not:- C-Panel requires Postgresql 7.3.x or later. 7.2.x will not work.
---------------------------------------------------------------------------

--Step 1--

Upgrade to cPanel 7.4.0 build 45 or later,

--Step 1a --(If you do not have 7.2.x or earlier installed skip this step)

Login to a root shell via ssh or the console,

If you have Postgres 7.2.x installed, backup your databases using pg_dumpall or some other method,

Move the postgres data directory somewhere else. ie,

mv /var/lib/pgsql /var/lib/pgsql.old

---------------------------------------------------------------------------
--Step 2--

Login to a root shell via ssh or the console and run,

/scripts/installpostgres


--Step 2a-- (skip this step if you are not upgrading from postgres 7.2 or earlier)

Restore your sql dump created with pg_dumpall or by some other method using psql or some other method



---------------------------------------------------------------------------
--Step 3--

Login to Web Host Manager & choose "Postgres Config" under Server Setup,

Set a postgres password to anything of your choosing, You should avoid using any non-alpha numeric charaters as these cause problems.


---------------------------------------------------------------------------
--Step 4--

Use the "Postgres Config" option in WHM to install a postgres pg_hba.conf file, You can skip this step if you would like to setup your pg_hba.conf file manually, cPanel should work fine with md5 passwords or plaintext passwords.

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


--Step 5--

Login to cPanel and click on Postgres .. Enjoy!
---------------------------------------------------------------------------

How to clean Exim's Mail queue

Solution How to clean an Exim queue is as follows :-

1) How to clean an Exim queue
2) Using WebHost Manager
3) Advanced Users
4) Very Advanced Users
--------------------------------------------------------------------------------------------

--Using WebHost Manager--

1. Login to WHM.
2. On the Main page, click on the email icon.
3. In the mail menu, select "Manage Mail Queue".
* Note:-( Instead of steps 2 & 3, you can select "Manage Mail Queue from the left margin.)
4. Find the message you wish to delete & select "Delete".

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

--Advanced Users--

There are many times when a mail queue may become filled with what is essentially junk mail, At extreme levels, this can cause high load & delayed mail delivery.
You can use a variation of the following command via a shell prompt to delete only these junk messages from the mail queue.

grep -lR KEYWORD /var/spool/exim/input/* | xargs rm -f

(This will purge the mail queue of any messages that contain KEYWORD.
Any messages deleted in this manner are IRRETRIEVABLE (aka: Gone for good)
Is this dangerous? You bet it CAN be.)

Let's look at an example:-

Imagine a case in which users are abusing a bad FormMail.pl installation on server.fastservers.net. Almost all of these messages will contain the username "nobody@server.fastservers.net". We want to delete ALL of these messages, so we would insert "nobody@server.fastservers.net" in place of "KEYWORD" in the command above.
This will delete all messages in the exim queue that contain the keyword "nobody@server.fastservers.net".

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

--Very Advanced Users--

Grep does regular expressions, This means you can catch tricky spammers with a little mind power.

 For example:-

grep -lRP Vz*Az*Lz*Iz*Uz*M /var/spool/exim/input/* | xargs rm -f

This command will delete any message containing the letters V, A, L, I, U, M, in that order, And with 0 or more "z" characters between them. A few of the keywords it will match are listed:
VALIUM
VzALIUM
VAzLIzUzM
VALzIUM
VzALzIUM
You get the idea.
--------------------------------------------------------------------------------------------