Domain Name Yahoo

Easy Help Troubleshoot Your Linux Box



  

Fight the spammer with Disable Open Relay

Yes lets fight with spam.
These days spammers are in love with my server, damn.
I just realize it, when I keep getting email bounced from the recipient guardian, such as barracuda.
When I check and recheck, the mail server is running as open relay server.
Here is what I did to protect.

Firstable, I already have Qmail + Vpopmail running properly and compiled as enabled roaming user that mean is smtp authenticate feature is enabled.

Secondly, You dont need to create secure connection using CRAMD5, AUTH PLAIN, AUTH LOGIN. Dont missunderstood, these secure connections are nothing to do with open relay, if you want to enable this feature that will be great.

Third, you must edit your /etc/tcp.smtp . tcp.smtp is a file to manage connection to your smtp port. Do google about this. You will find dozen knowledge about it.
The point is you must add these line :

127.:allow,RELAYCLIENT=”"
:allow,SMTPAUTH=”"
:deny

That means, allways allow connection from localhost and always allow incoming connection that using smtp authentication and deny the rest except the “rcpt to: ” is in the /var/qmail/control/rcpthosts file.

# service qmail stop
# service qmail cdb
# service qmail start

November 25th, 2009 Posted by admin | CentOS, Email, Ubuntu | no comments

Using rar in Linux

Q : How can I open and extract rar file ?

Rar files are compressed file, you need to decompressed it or unrar it.
There is linux software called unrar, able to read , open and extract rar files.

$ wget http://www.rarlab.com/rar/rarlinux-3.6.0.tar.gz

Untar the downloaded file
$ tar -zxvf rarlinux-3.6.0.tar.gz

Both unrar and rar commands are located in rar sub-directory. Just go to rar directory:
$ cd rar
$ ./unrar

Now copy rar and unrar to /bin directory:
# cp rar unrar /bin

To Extract Rar files use:
$ unrar x rar.file

September 29th, 2009 Posted by admin | CentOS, Ubuntu | no comments

Freeing Linux Virtual Memory

Hi,

I have Centos installed on HP Proliant Box with 13Gig of RAM Memory.
Yesterday, I was running rsync all my websites into another box in LAN.
Somehow the memory has dropped out and there is only 32Mb left on free memory.
Damn, only copying files has eating more than 12 Gigs of memory, and after rsync has finish and there is no more rsync process , the free mem won’t go back to normal. That is crazy !!.

I know you people will or even already have the same situation as I did.
Here is the tips. The secret is on /proc/sys/vm/drop_caches file.

Simply run this :

To free pagecache:
echo 1 > /proc/sys/vm/drop_caches

To free dentries and inodes:
# echo 2 > /proc/sys/vm/drop_caches

To free pagecache, dentries and inodes:
# echo 3 > /proc/sys/vm/drop_caches

Here is the example syntax and the result before and after freeing the memory.

[root@dev vm]# cd /proc/sys/vm/

[root@dev vm]# cat drop_caches
0
[root@dev vm]# free
total       used       free     shared    buffers     cached
Mem:       1132664    1085076      47588          0     194664     490084
-/+ buffers/cache:     400328     732336
Swap:      2031608          0    2031608
[root@dev vm]# sync ; echo 3 > /proc/sys/vm/drop_caches ; free
total       used       free     shared    buffers     cached
Mem:       1132664     388280     744384          0        116      48240
-/+ buffers/cache:     339924     792740
Swap:      2031608          0    2031608
You have new mail in /var/spool/mail/root
[root@dev vm]# cat drop_caches
3
[root@dev vm]# sync ; echo 0 > /proc/sys/vm/drop_caches ; free
total       used       free     shared    buffers     cached
Mem:       1132664     395952     736712          0       1336      55180
-/+ buffers/cache:     339436     793228
Swap:      2031608          0    2031608
note: don’t forget to put ‘0′ back into the drop_caches.

I still dont know if there will the any risk, until now.. everything is fine.

August 3rd, 2009 Posted by admin | CentOS, General, Ubuntu | no comments

How to login SSH without password

The answer is using private-key & public-key.
Theory is very simple, first generate pair key (Private&public key ) then put the public key into the server machine, so when another machine request login from ssh, it will compare the public key on server machine with the private-key.

Here is the example.

You want to login from computer A as root and Computer B as root.
From computer A, you generate the pair-key ( public&private key ).

[root@A ~]# mkdir .ssh
[root@A ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
11:42:12:25:16:cc:e2:5e:32:d7:72:48:20:78:25:e2 root@A

note : Just hit enter to empty the passphrase.

[root@A ~]# cat .ssh/id_rsa

Copy all the string into clipboard first.
On Machine B, create the directory .ssh , usually this folder is already exists

[root@B ~]#  mkdir .ssh

Check B authorized key file on the sshd config

[root@B ~]# cat /etc/ssh/sshd_config | less

You will find a line contains

AuthorizedKeysFile      .ssh/authorized_keys

that means the authorized_keys is in the $HOME/.ssh/authorized_keys
Therefor you need to paste the clipboard string copied from public key machine A

And you are done. You may try to login ssh from machine A. Meanwhile keep your eyes on the log of machine B

[root@B ~]# tail -f /var/log/secure
Authentication refused: bad ownership or modes for directory /root

The common failure is about the permission, you need to change the /root , .ssh and authorized_keys into 700 on machine B.

Thats it. Thanks God … I did it. :D

July 31st, 2009 Posted by admin | CentOS, General, Ubuntu, ssh | no comments

How to umount when device is busy

This question is killing you slowly even more when you are separating the code and database into different machine. And you know what, this is happening to me.

My db & code server kernel is panic, so the site is down.
Thanks GOD, the machine is still running when I do hard reset.
Second problem, the mount from the webserver is stuck and I cant do umount the nfs mounted. It is saying that “Device is busy”, then I just need restart the webserver machine. But too much restarting machine is not good.

Here is another way without restarting machine.

# fuser -m /web/html/
/web/html: 538
# ps auxw|grep 538
donncha 538 0.4 2.7 219212 56792 ? SLl Feb11 11:25 apache2

simply kill the PID then try to umount

After that re mount the nfs, and restart httpd service.
All done. But, until know I can not figure what is the problem maker making kernel panic.
There is nothing from syslog.
Anybody know wherelse I should investigate ?

July 18th, 2009 Posted by admin | CentOS, Ubuntu | no comments