ʹÓÃÏÂÁîÐй¤¾ßÌáÉýLinuxЧÀÍÆ÷Çå¾²
ʹÓÃÏÂÁîÐй¤¾ßÌáÉýLinuxЧÀÍÆ÷Çå¾²
ÔÚÄ¿½ñ»¥ÁªÍøʱ´ú£¬Ð§ÀÍÆ÷Çå¾²¹ØÓÚÈκÎÒ»¼ÒÆóÒµ»òСÎÒ˽ÈËÓû§À´Ëµ¶¼ºÜÊÇÖ÷Òª¡£¶øLinux×÷ΪһÖÖ³£¼ûµÄЧÀÍÆ÷²Ù×÷ϵͳ£¬ÎÒÃÇ¿ÉÒÔͨ¹ýʹÓÃÏÂÁîÐй¤¾ßÀ´ÌáÉýÆäÇå¾²ÐÔ¡£±¾ÎĽ«ÏÈÈÝһЩ³£¼ûµÄÏÂÁîÐй¤¾ß£¬²¢¸ø³öÏìÓ¦µÄ´úÂëʾÀý£¬×ÊÖúÄú¸üºÃµØ±£»¤LinuxЧÀÍÆ÷¡£
SSH£¨Secure Shell£©
SSHÊÇÒ»ÖÖͨ¹ýÍøÂç¾ÙÐмÓÃÜͨѶµÄÐÒ飬ËüÄܹ»ÔÚ²»Çå¾²µÄÍøÂçÖÐÌṩÇå¾²µÄÔ¶³ÌµÇ¼ºÍÖ´ÐÐÏÂÁîµÄ¹¦Ð§¡£Í¨¹ýSSH£¬ÎÒÃÇ¿ÉÒÔ×èÖ¹Ã÷ÎÄ´«ÊäÃÜÂ룬ͬʱ»¹¿ÉÒÔʹÓù«Ô¿¼ÓÃܾÙÐÐÉí·ÝÑéÖ¤¡£
Ê×ÏÈ£¬ÎÒÃÇÐèҪȷ±£SSHЧÀÍÒѾװÖò¢¿ªÆô¡£ÔÚÖÕ¶ËÖÐÖ´ÐÐÒÔÏÂÏÂÁ
sudo apt-get install openssh-server
µÇ¼ºó¸´ÖÆ
½ÓÏÂÀ´£¬ÎÒÃÇÐèÒª±à¼SSHÉèÖÃÎļþ/etc/ssh/sshd_config£¬ÐÞ¸ÄĬÈϵĶ˿ںš¢Õ¥È¡rootÓû§Ô¶³ÌµÇ¼µÈ¡£¿ÉÒÔʹÓÃÒÔÏÂÏÂÁ
sudo nano /etc/ssh/sshd_config
µÇ¼ºó¸´ÖÆ
ÔÚÎļþÖпÉÒÔÕÒµ½ÀàËÆÈçϵÄÉèÖÃÏ
#Port 22 #PermitRootLogin prohibit-password
µÇ¼ºó¸´ÖÆ
½«ÆäÖеÄ×¢ÊÍ·ûºÅÈ¥µô²¢ÐÞ¸ÄÐèÒªµÄÉèÖá£ÐÞ¸ÄÍê³Éºó£¬ÉúÑIJ¢Í˳ö¡£
×îºó£¬ÖØÐÂÆô¶¯SSHЧÀÍ£¬Ê¹ÉèÖÃÉúЧ£º
sudo service ssh restart
µÇ¼ºó¸´ÖÆ
Fail2Ban
Fail2BanÊÇÒ»¸öÓÃÓÚ±ÜÃⱩÁ¦Æƽ⹥»÷µÄ¿ªÔ´Èí¼þ£¬Ëü¿ÉÒÔ¼ì²âµ½¶à´Îʧ°ÜµÄµÇ¼ʵÑ飬²¢ÇÒ×Ô¶¯·â½û¹¥»÷ÕßµÄIPµØµã¡£ÕâÀïÎÒÃǸø³öÒ»¸öʾÀý£¬ÓÃÓÚ¼à¿ØSSHµÇ¼ʧ°ÜµÄÇéÐΡ£
Ê×ÏÈ£¬ÎÒÃÇÐèҪװÖÃFail2Ban¡£ÔÚÖÕ¶ËÖÐÖ´ÐÐÒÔÏÂÏÂÁ
sudo apt-get install fail2ban
µÇ¼ºó¸´ÖÆ
È»ºó£¬ÎÒÃÇÐèÒª½¨ÉèÒ»¸ö×Ô½ç˵µÄÉèÖÃÎļþ/etc/fail2ban/jail.localÓÃÓÚ¼à¿ØSSHµÇ¼ʧ°Ü¡£¿ÉÖ´ÐÐÒÔÏÂÏÂÁ
sudo nano /etc/fail2ban/jail.local
µÇ¼ºó¸´ÖÆ
ÔÚÎļþÖÐÌí¼ÓÒÔÏÂÄÚÈÝ£º
[sshd] enabled = true port = ssh logpath = %(sshd_log)s findtime = 600 bantime = 3600 maxretry = 3
µÇ¼ºó¸´ÖÆ
ÉúÑIJ¢Í˳öÉèÖÃÎļþ¡£
×îºó£¬ÖØÆôFail2BanЧÀÍ£¬Ê¹ÆäÉèÖÃÉúЧ£º
sudo service fail2ban restart
µÇ¼ºó¸´ÖÆ
iptables
iptablesÊÇÒ»¸öÔÚLinuxÄÚºËÖеķÀ»ðǽ¹¤¾ß£¬¿ÉÒÔ¹ýÂ˺Íת·¢ÍøÂçÊý¾Ý°ü£¬ÓÃÓÚ¿ØÖÆÍøÂç»á¼û¹æÔò¡£ÒÔÏÂÊÇһЩ³£¼ûµÄiptablesÏÂÁîʾÀý¡£
¹Ø±ÕËùÓÐÈëÕ¾ÅþÁ¬£º
sudo iptables -P INPUT DROP
µÇ¼ºó¸´ÖÆ
ÔÊÐíÌض¨IPµØµãµÄÈëÕ¾ÅþÁ¬£º
sudo iptables -A INPUT -s <IPµØµã> -j ACCEPT
µÇ¼ºó¸´ÖÆ
ÔÊÐíij¸ö¶Ë¿ÚµÄÈëÕ¾ÅþÁ¬£º
sudo iptables -A INPUT -p tcp --dport <¶Ë¿ÚºÅ> -j ACCEPT
µÇ¼ºó¸´ÖÆ
եȡÌض¨IPµØµãµÄÈëÕ¾ÅþÁ¬£º
sudo iptables -A INPUT -s <IPµØµã> -j DROP
µÇ¼ºó¸´ÖÆ
ÉúÑÄiptablesÉèÖãº
sudo service iptables save
µÇ¼ºó¸´ÖÆ
ÒÔÉÏÊǼ¸¸ö³£¼ûµÄÏÂÁîÐй¤¾ß£¬Í¨¹ýËüÃÇÎÒÃÇ¿ÉÒÔÓÐÓõØÌáÉýLinuxЧÀÍÆ÷µÄÇå¾²ÐÔ¡£µ«Çë×¢ÖØ£¬ÔÚʹÓÃÕâЩ¹¤¾ß֮ǰ£¬Ò»¶¨ÒªÏà֪Ȥ¹ØµÄÏÂÁî¼°ÆäÓ÷¨£¬×èÖ¹Îó²Ù×÷µ¼ÖÂЧÀÍÆ÷²»¿ÉÓ᣸üÖ÷ÒªµÄÊÇ£¬Ê±¿Ì¼á³ÖϵͳºÍÈí¼þµÄ¸üУ¬ÊµÊ±ÐÞ²¹Îó²î£¬ÔöǿЧÀÍÆ÷µÄ·ÀÓùÄÜÁ¦¡£
Ï£Íû±¾ÎĶÔÄúÓÐËù×ÊÖú£¬×£ÄúµÄLinuxЧÀÍÆ÷Çå¾²ÎÞÓÇ£¡
ÒÔÉϾÍÊÇʹÓÃÏÂÁîÐй¤¾ßÌáÉýLinuxЧÀÍÆ÷Çå¾²µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡