Home | Data Center | Contact US | Login

Á¦¸ñ Prevent-SSH Bruteforce(¹«Â÷º° °ø°Ý) ¹æ¾î Åø
÷ºÎÆÄÀÏ Prevent - SSH Bruteforce(¹«ÀÚº°°ø°Ý) ¹æ¾îÅø.pdf ÀÛ¼ºÀÏ 2007-11-27 10:28:06
ÀÛ¼ºÀÚ : ±â¼úÁö¿øºÎ ±è »ï ¼ö kiss@nextline.net
 
Prevent
SSH Bruteforce(¹«Â÷º° °ø°Ý) ¹æ¾î Åø
 
Prevent À̶õ?
/var/log/secure ·Î±×¸¦ »ìÆ캸¸é ÀÏÁ¤ÇÑ ID¸¦ ÀÌ¿ëÇؼ­ SSH Á¢¼Ó ½Ãµµ¸¦ ÇÏ´Â °ÍÀ» º¼ ¼ö ÀÖÀ¸¸ç ÀÌ·± °ø°ÝÀº SSH Bruteforce(¹«Â÷º° °ø°Ý)·Î¼­, Æнº¿öµå »çÀü ÆÄÀÏÀ» ÀÌ¿ëÇؼ­ ¹Ì¸® ÁöÁ¤ÇÑ ¾ÆÀ̵ð¿Í ´ëÀÔÇÏ¿©, Á¢¼Ó °èÁ¤À» ¾Ë¾Æ ³»´Â ÇØÅ· ¹æ¹ýÀÔ´Ï´Ù. PreventÀº /var/log/secure ·Î±×ÀÇ ½Ç½Ã°£ ºÐ¼®ÇÏ¿© ƯÁ¤ ¾ÆÀÌÇÇ¿¡¼­ ÀÏÁ¤È½¼ö ÀÌ»ó Á¢¼Ó ½ÇÆа¡ ÀÌ·ç¾îÁö¸é °ø°Ý ¾ÆÀÌÇÇ¿¡ ´ëÇÑ clipping levelÀ» ÁöÁ¤Çؼ­ 5 levelÀÌ»ó ¿Ã¶ó°¡¸é ¾ÆÀÌÇÇÀ» ºí·Ï ½ÃÅ°´Â ÅøÀÔ´Ï´Ù.
 
prevent µ¿ÀÛ¿ø¸®
/var/log/secure ÆÄÀÏÀ» ºÐ¼®ÇÏ¿© sshd¿¡ ´ëÇÑ ·Î±×ºÐ¼® ÈÄ Æ¯Á¤ ¾ÆÀ̵ð, Æнº¿öµåÀÇ ºÒÀÏÄ¡·Î Á¢¼Ó ½ÇÆÐÇÑ ¾ÆÀÌÇǸ¦ /var/log/prevent µð·ºÅ丮¿¡ ±â·Ï ÈÄ Ä«¿îÆÃÀ» ÇÕ´Ï´Ù. Ä«¿îÆÃÀº 1~5±îÁö Àִµ¥ ÀÌ°ÍÀÌ clipping level À̸ç level 5 ÀÌ»óÀÌ µÇ¾úÀ» ½Ã /etc/denyip ÆÄÀÏ¿¡ ¾ÆÀÌÇǸ¦ µî·ÏÇÏ¿© ÇØ´ç ¾ÆÀÌÇÇ°¡ Â÷´ÜµÇµµ·Ï µ¿ÀÛÇÕ´Ï´Ù. ´Ü, level 5 ÀÌ»óÀÌ µÇ±âÀü ÇѹøÀÌ¶óµµ ·Î±×Àο¡ ¼º°øÇϸé ÇØ´ç ¾ÆÀÌÇÇ¿¡ ´ëÇÑ clipping level ±â·ÏÀÌ »èÁ¦µÇ¸ç  /etc/denyip ÆÄÀÏ¿¡ µî·ÏµÇ¾î Â÷´ÜµÈ ¾ÆÀÌÇÇ´Â /var/log/prevent µð·ºÅ丮ÀÇ ±â·Ï¿¡¼­ ÀÚµ¿ »èÁ¦µË´Ï´Ù.
 
¨ç SSH Bruteforce(¹«Â÷º° °ø°Ý) ŽÁö
 
[root@nextline log]# cat /var/log/secure



/var/log/secure ·Î±×ÆÄÀÏ¿¡ ±â·ÏµÈ SSH Bruteforce °ø°ÝÀÇ ÇüÅÂÀÔ´Ï´Ù.
 
¨è log rotation ¼³Á¤
prevent ¿î¿µ ½Ã /var/log/secureÀÇ ·Î±×°¡ log rotation µÇ¸é secure ·Î±×¸¦ ºÐ¼®ÇÏÁö ¸øÇÏ´Â Çö»óÀÌ ³ªÅ¸³ª¹Ç·Î /etc/logrotate.d/syslog ÆÄÀÏÀ» ¾Æ·¡¿Í °°ÀÌ ¼öÁ¤ÇϽñ⠹ٶø´Ï´Ù.
[root@nextline ~]# cat /etc/logrotate.d/syslog
/var/log/messages /var/log/secure /var/log/maillog /var/log/spooler /var/log/boot.log /var/log/cron {
    sharedscripts
    postrotate
        /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
        /bin/sleep 1 # 1ÃÊ°£ ´ë±âÇÑ
        /root/bin/prevent stop  # prevent°¡ ¼³Ä¡µÈ Àý´ë°æ·Î ÀÔ·Â
        /root/bin/prevent stop  # prevent°¡ ¼³Ä¡µÈ Àý´ë°æ·Î ÀÔ·Â
        /root/bin/prevent start &  # prevent°¡ ¼³Ä¡µÈ Àý´ë°æ·Î ÀÔ·Â
    endscript
}

 
¨é  ´Ù¿î·Îµå
wget http://manpage.co.kr/zboard/data/down/prevent_0.7.2.tar.gz
wget http://manpage.co.kr/zboard/data/down/prevent2_64bit.tgz

 
¨ê  ¾ÐÃàÇØÁ¦
[root@ns ~]# tar zxf prevent_0.7.2.tar.gz

 
¨ë ÆÛ¹Ì¼Ç º¯°æ
root ±ÇÇÑÀ¸·Î¸¸ ½ÇÇàµÉ ¼ö ÀÖµµ·Ï Æ۹̼ÇÀ» º¯°æÇÕ´Ï´Ù.
[root@ns ~]# chmod 700 prevent
[root@ns ~]# ll prevent
-rwx------  1 root root 376812  3¿ù 22  2005 prevent

 
¨ì °æ·Îº¯°æ
preventÀÌ À§Ä¡ÇÒ Àû´çÇÑ °æ·Î·Î ÆÄÀÏÀ» À̵¿ÇÕ´Ï´Ù.
[root@ns ~]# mv prevent /root/bin/
[root@nextline ~]# ll /root/bin/prevent

 
¨í /etc/hosts.deny ¼³Á¤
preventÀº ¾ÆÀÌÇÇ Â÷´ÜÀ» À§ÇØ /etc/hosts.deny ÆÄÀÏÀ» »ç¿ëÇϹǷΠ/etc/hosts.deny ÆÄÀÏ¿¡ ¾Æ·¡¿Í °°ÀÌ ¼³Á¤µÇ¾îÀÖ¾î¾ß ÇÕ´Ï´Ù.
[root@ns ~]# vi /etc/hosts.deny
 
 
/etc/denyip ÆÄÀÏ¿¡ µî·ÏµÈ ¾ÆÀÌÇÇ´Â ssh Á¢±ÙÀ» Â÷´Ü½ÃÅ°°Ú´Ù´Â ¼³Á¤À̸ç denyip ÆÄÀÏÀº prevent ½ÇÇà ½Ã ÀÚµ¿ »ý¼ºµË´Ï´Ù.
¾Æ·¡ÀÇ ³»¿ëÀ» ÀÔ·ÂÇÕ´Ï´Ù.
sshd: . /etc/denyip
 
 
¨î prevent ½ÃÀÛ
½Ç½Ã°£À¸·Î /var/log/secure ÆÄÀÏÀ» ºÐ¼®ÇÒ ¼ö ÀÖµµ·Ï ¹é±×¶ó¿î·Î preventÀ» ½ÇÇàÇÕ´Ï´Ù.
[root@nextline ~]# /root/bin/prevent start &

 
¹é±×¶ó¿îµå·Î Á¤»óÀûÀ¸·Î ½ÇÇàµÇ°í ÀÖ´ÂÁö È®ÀÎÇÕ´Ï´Ù.
[root@nextline ~]# jobs

  
¨ï prevent ÁßÁö
[root@nextline ~]# /root/bin/prevent stop

  
¨ð denyip ÆÄÀÏ»ý¼º È®ÀÎ
[root@nextline ~]# ll /etc/denyip
denyip ÆÄÀÏÀÇ Æ۹̼ÇÀº root¸¸ Àаí, ¾²±â°¡ °¡´ÉÇϵµ·Ï 0600À¸·Î ¼³Á¤µÇ¾î ÀÖ½À´Ï´Ù.

 
¨ñ ¾ÆÀÌÇÇ Â÷´ÜÅ×½ºÆ®
prevent ½ÇÇà½Ã ÀÚµ¿»ý¼ºµÇ´Â /var/log/prevent µð·ºÅ丮·Î À̵¿ÇÕ´Ï´Ù.
[root@ns ~]# cd /var/log/prevent/
ssh Á¢¼Ó½Ã ÀÏÄ¡ÇÏÁö ¾ÊÀº Æнº¿öµå·Î 1~2Â÷·Ê Á¢¼Ó½Ãµµ¸¦ ÇÏ¸é ¾Æ·¡¿Í °°ÀÌ Ä«¿îÆ®°¡ ½ÃÀ۵Ǹç count 1Àº clipping level 1À» ÀǹÌÇÕ´Ï´Ù.
[root@ns prevent]# count 1
ssh Á¢¼Ó ½ÇÆÐÇÑ ¾ÆÀÌÇÇ°¡ clipping level¿¡ µî·ÏµÇ¸é ÇØ´ç ¾ÆÀÌÇÇ°¡ /var/log/prevent µð·ºÅ丮¿¡ ¾ÆÀÌÇǸíÀ¸·Î ÆÄÀÏÀÌ »ý¼ºµË´Ï´Ù.
[root@ns prevent]# ls
xxx.xxx.xxx.xxx
ÇØ´ç ÆÄÀÏÀ» vi ¿¡µðÅͳª cat ¸í·É¾î·Î È®ÀÎÇϸç ÇØ´ç ¾ÆÀÌÇÇ¿¡ ´ëÇÑ clipping level À» È®ÀÎ ÇÏ½Ç ¼ö ÀÖ½À´Ï´Ù.
[root@ns prevent]# cat xxx.xxx.xxx.xxx

 
Áö¼ÓÀûÀÎ Á¢¼Ó½ÇÆзΠclipping level 5 ÀÌ»óÀ̵Ǹé /etc/denyip ÆÄÀÏ¿¡ µî·ÏµÇ¸é¼­ ÇØ´ç ¾ÆÀÌÇÇ°¡ Â÷´ÜµÇ¸ç /var/log/prevent µð·ºÅ丮¿¡´Â ÇØ´ç ¾ÆÀÌÇÇ¿¡ ´ëÇÑ ±â·ÏÀÌ »èÁ¦µË´Ï´Ù.
/etc/denyip ÆÄÀÏ¿¡ ¾ÆÀÌÇÇ°¡ µî·ÏµÇ¸é¼­ ÄÜ¼Ö»ó¿¡ »Ñ·ÁÁÖ´Â ¸Þ½ÃÁö ÀÔ´Ï´Ù.
 
 
Â÷´Ü ¾ÆÀÌÇÇÈ®ÀÎ
[root@ns prevent]# cat /etc/denyip
 
 
¨ò Á¢¼ÓÅ×½ºÆ®
Prevent¿¡ ÀÇÇØ Â÷´ÜµÈ ¾ÆÀÌÇÇ·Î ssh Á¢¼ÓÀ» ½ÃµµÇÏ¸é ¾Æ·¡¿Í °°Àº ¿¡·¯¸Þ½ÃÁö¸¦ Ãâ·ÂÇϸç Á¢¼ÓÀÌ ÀÌ·ç¾îÁöÁö ¾Ê½À´Ï´Ù.

 
 
 
 
 
  »çÀÌÆ®°¡ ´À·ÁÁú¶§ Á¡°Ë»çÇ×
  lshw ¶õ?





ȸ»ç¼Ò°³ °³ÀÎÁ¤º¸Ãë±Þ¹æħ ÀÌ¿ë¾à°ü À̸ÞÀÏÁÖ¼Ò ¹«´Ü¼öÁý°ÅºÎ CONTACT US IDC ¾àµµ
ȸ»ç¼Ò°³ °³ÀÎÁ¤º¸Ãë±Þ¹æħ ÀÌ¿ë¾à°ü À̸ÞÀÏÁÖ¼Ò ¹«´Ü¼öÁý°ÅºÎ CONTACT US IDC ¾àµµ ȸ»ç¼Ò°³ °³ÀÎÁ¤º¸Ãë±Þ¹æħ ÀÌ¿ë¾à°ü À̸ÞÀÏÁÖ¼Ò ¹«´Ü¼öÁý°ÅºÎ CONTACT US IDC ¾àµµ