Friday, July 29, 2011

How to test phpmail()

Create a php script as below.

root@cpanel [~]# cat test.mail
$to      = 'username@gmail.com';
$subject = 'testing phpmail';
$message = 'hello';
$headers = 'From:yourname' . "\r\n" .
    'Reply-To: yourname' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);
?>
root@cpanel [~]#
Now execute the command as below to send mail
root@cpanel [~]# php test.mail
Thats it. Check your inbox. If everything is it, it'll be delivered successfully.

preventing root user or account from ssh

This post explains how to prevent root user to ssh directly to a linux box. This is tested in redhat rhel5 system and works on almost other linux distros.

Open the ssh configuration file
# vi /etc/ssh/sshd_config
Changethe following line
PermitRootLogin yes
To
PermitRootLogin no

Now restart the ssh demon.
/etc/init.d/sshd restart

Thursday, July 28, 2011

Allowing root account to ssh

This post explains how to allow root user to ssh directly to a linux box. This is tested in redhat rhel5 system and works on almost other linux distros.

Open the ssh configuration file
# vi /etc/ssh/sshd_config

Changethe following line
PermitRootLogin no
To
PermitRootLogin yes

Now restart the ssh demon.
/etc/init.d/sshd restart

Wednesday, July 27, 2011

How to enable brute force attack on exim

This post explains how to disable brute force attack or multiple login attempts with wrong passwords on exim using csf / lfd

open csf.conf

vi /etc/csf/csf.conf


LF_TRIGGER = "0"
LF_POP3D = "10"
LF_IMAPD = "10"
LF_POP3D_PERM ="180"

Restart csf
#csf -r

How to enable brute force detection for directadmin

This post explains how to enable brute force detection for directadmin or how to prevent multiple login attempts with wrong passwords.

open directadmin.conf

#Brutforce detection is enabled and the count is set to 5.
bruteforce=1
brutecount=5

if more than 5 attempt is done, then the ip will be added to the black list file. It will never be cleared (unless manually).
/usr/local/directadmin/data/admin/ip_blacklist

Tuesday, July 26, 2011

How to change the password of the openvz vps

Here the steps to change the password of the openvz vps or virtual private server from the command line.


[root@test ~]# vzlist -a | grep 192.168.0.100
       462        245 running   192.168.0.100    abc.xyx.com

Always take back up of configuration file before you do anything
[root@test ~]# cp /etc/sysconfig/vz-scripts/462.conf{,bfchpass}

Syntax
vzctl set VE_ID --userpasswd root:[newpasswd] --save

[root@test ~]# vzctl set 462 --userpasswd root:abc123$ --save
Changing password for user root.
passwd: all authentication tokens updated successfully.
Saved parameters for CT 462
[root@test ~]#