วันศุกร์ที่ 28 ตุลาคม พ.ศ. 2554

ป้องกัน ssh ด้วย iptables

#Brute Force Protection
iptables -N sshscan
iptables -A INPUT -p tcp --dport 22 -m state --state NEW -j sshscan
iptables -A INPUT -p tcp -m tcp --dport 22 --syn -i eth1 -j ACCEPT
iptables -A sshscan -m recent --set --name SSH
iptables -A sshscan -m recent --update --seconds 300 --hitcount 3 --name SSH -j LOG --log-level info --log-prefix "SSH brute force:"
iptables -A sshscan -m recent --update --

วิธีย้าย documentRoot ใน centos

หากเราต้องการย้าย documentroot ใน centos จาก /var/www/html เป็น /home
ต้องเข้าไปแก้ไขในไฟล์ httpd.conf ตรง documentroot /var/www/html เป็น /home
หลังจากนั้นต้องไปปิด selinux /etc/sysconfig/selinux จาก selinux=enforcing เป็น selinux=disabled
"""reboot ก็สามารถทำให้เราสามารถย้าย documentroot ได้อย่างสบายครับ..
หาก add user ไว้แล้วเรียกเวบ http://www.xxx/user ติด permission ลอง chmod 755 ดู ไม่แนะนำนะครับ.แต่กันลืม...

วันอาทิตย์ที่ 23 ตุลาคม พ.ศ. 2554

วิธีติดตั้ง phpmyadmin

ปกติ..หากเราติดตั้ง phpmyadmin แบบดาว์นโหลดมาติดตั้งเอง...บน linux หรือ unix เริ่มต้นโดยการแตกไฟล์
แล้วนำไปไว้ห้อง ducumentroot ของ web Server เช่น /var/www/html/phpmyadmin/ เป็นต้น
หลังจากนั้นให้เข้าไปในห้อง /phpmydmin/libraries หาไฟล์ชื่อ config.default.php ทำการ copy ขึ้นมาไว้ที่ห้อง
/var/www/phpmyadmin/ แล้วทำการเปลี่ยนชื่อไฟล์ เป็น config.inc.php
ทำการแก้ไข config ไฟล์ดังนี้
$cfg['blowfish_secret'] = 'ใส่รหัสความปลอดภัยอะไรก็ได้...';
$cfg['Servers'][$i]['controluser'] = 'root';
$cfg['Servers'][$i]['controlpass'] = 'passwordmysql'; ใส่รหัส mysql root
$cfg['Servers'][$i]['auth_type'] = 'http'; เปลี่ยนจาก cookie เป็น http

/**
* MySQL user
*
* @global string $cfg['Servers'][$i]['user']
*/
$cfg['Servers'][$i]['user'] = 'root';

/**
* MySQL password (only needed with 'config' auth_type)
*
* @global string $cfg['Servers'][$i]['password']
*/
$cfg['Servers'][$i]['password'] = 'passwordmysql';

/**

/**
* Database used for Relation, Bookmark and PDF Features
* (see scripts/create_tables.sql)
* - leave blank for no support
* SUGGESTED: 'phpmyadmin'
*
* @global string $cfg['Servers'][$i]['pmadb']
*/
$cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';

/**
* Bookmark table
* - leave blank for no bookmark support
* SUGGESTED: 'pma_bookmark'
*
* @global string $cfg['Servers'][$i]['bookmarktable']
*/
$cfg['Servers'][$i]['bookmarktable'] = 'pma_bookmark';

/**
* table to describe the relation between links (see doc)
* - leave blank for no relation-links support
* SUGGESTED: 'pma_relation'
* @global string $cfg['Servers'][$i]['relation']
*/
$cfg['Servers'][$i]['relation'] = 'pma_relation';

/**
* table to describe the display fields
* - leave blank for no display fields support
* SUGGESTED: 'pma_table_info'
*
* @global string $cfg['Servers'][$i]['table_info']
*/
$cfg['Servers'][$i]['table_info'] = 'pma_table_info';

/**
* table to describe the tables position for the PDF schema
* - leave blank for no PDF schema support
* SUGGESTED: 'pma_table_coords'
*
* @global string $cfg['Servers'][$i]['table_coords']
*/
$cfg['Servers'][$i]['table_coords'] = 'pma_table_coords';

/**
* table to describe pages of relationpdf
* - leave blank if you don't want to use this
* SUGGESTED: 'pma_pdf_pages'
*
* @global string $cfg['Servers'][$i]['pdf_pages']
*/
$cfg['Servers'][$i]['pdf_pages'] = 'pma_pdf_pages';

/**
* table to store column information
* - leave blank for no column comments/mime types
* SUGGESTED: 'pma_column_info'
*
* @global string $cfg['Servers'][$i]['column_info']
*/
$cfg['Servers'][$i]['column_info'] = 'pma_column_info';
/**
* table to store SQL history
* - leave blank for no SQL query history
* SUGGESTED: 'pma_history'
*
* @global string $cfg['Servers'][$i]['history']
*/
$cfg['Servers'][$i]['history'] = 'pma_history';

/**
* table to store the coordinates for Designer
* - leave blank for no Designer feature
* SUGGESTED: 'pma_designer_coords'
*
* @global string $cfg['Servers'][$i]['designer_coords']
*/
$cfg['Servers'][$i]['designer_coords'] = 'pma_designer_coords';

/**
* table to store SQL tracking
* - leave blank for no SQL tracking
* SUGGESTED: 'pma_tracking'
*
* @global string $cfg['Servers'][$i]['tracking']
*/
$cfg['Servers'][$i]['tracking'] = 'pma_tracking';

/**
* table to store user preferences
* - leave blank to disable server storage
* SUGGESTED: 'pma_userconfig'
*
* @global string $cfg['Servers'][$i]['userconfig']
*/
$cfg['Servers'][$i]['userconfig'] = 'pma_userconfig';

/**
ทำการบันทึกไฟล์ config.inc.php สั่ง chmod 755 ไฟล์ config.inc.php
เข้า http://xx.xxx.xx.xx/phpmyadmin/
ทำการสร้างฐานข้อมูลชื่อ phpmyadmin
สั่ง import script ชื่อ create_table.sql ในไฟล์ที่โหลดมา อยู่ในห้อง /script
แค่นี้ก็จะทำให้ phpmyadmin ไม่มีอะไรแจ้งเตือนให้รำคาณใจอีก..เย้ ๆ ๆ ๆ ๆ
อีกนิดสำหรับเวลาสร้างฐานข้อมูลให้ user แต่ละคน login ด้วยชื่อตัวเอง..แบบไม่มีสิทธิ์สร้างฐานอื่นมีสิทธิ์แค่ฐานข้อมูลตัวเอง..
เข้าในฐานะ root สร้างฐานข้อมูล เสร็จแล้วมาที่ privileges เลือก add user เลือก
Create database with same name and grant all privileges

วันศุกร์ที่ 21 ตุลาคม พ.ศ. 2554

การติดตั้ง mrtg บน cenos

credit"http://www.icez.net/blog/28/%E0%B8%A5%E0%B8%87-mrtg-%E0%B8%9A%E0%B8%99-centosfedora-%E0%B9%81%E0%B8%9A%E0%B8%9A%E0%B8%87%E0%B9%88%E0%B8%B2%E0%B8%A2%E0%B9%86"

yum -y install net-snmp mrtg
wget -4 -O /etc/snmp/snmpd.conf www.icez.net/files/snmpd.conf
wget -4 -O /var/www/mrtg/mrtg-load.sh www.icez.net/files/mrtg-load.sh
chmod a+x /var/www/mrtg/mrtg-load.sh
/etc/init.d/snmpd restart
cfgmaker --global 'WorkDir: /var/www/mrtg' --global 'Options[_]: bits,growright' --output /var/www/mrtg/mrtg.cfg public@localhost
wget -4 -O /tmp/mrtg.cfg www.icez.net/files/mrtg.cfg
cat /tmp/mrtg.cfg >> /var/www/mrtg/mrtg.cfg
/bin/cp -fv /var/www/mrtg/mrtg.cfg /etc/mrtg/mrtg.cfg
echo "Alias /mrtg /var/www/mrtg" > /etc/httpd/conf.d/mrtg.conf
/sbin/chkconfig snmpd on
indexmaker /etc/mrtg/mrtg.cfg > /var/www/mrtg/index.html
/etc/init.d/httpd graceful