LinuxЧÀÍÆ÷Çå¾²ÉèÖãºÌá¸ßϵͳ·ÀÓùÄÜÁ¦
LinuxЧÀÍÆ÷Çå¾²ÉèÖãºÌá¸ßϵͳ·ÀÓùÄÜÁ¦
Ëæ×Å»¥ÁªÍøµÄ¿ìËÙÉú³¤£¬Ð§ÀÍÆ÷Çå¾²ÎÊÌâÈÕÒæÍ»³ö¡£ÎªÁ˱£»¤Ð§ÀÍÆ÷µÄÎȹÌÐÔºÍÊý¾ÝµÄÇå¾²ÐÔ£¬Ð§ÀÍÆ÷ÖÎÀíÔ±Ó¦ÔöÇ¿¶ÔLinuxЧÀÍÆ÷µÄÇå¾²ÉèÖᣱ¾ÎĽ«ÏÈÈÝһЩ³£¼ûµÄLinuxЧÀÍÆ÷Çå¾²ÉèÖÃÒªÁ죬²¢ÌṩÏà¹ØµÄ´úÂëʾÀý£¬ÒÔ×ÊÖúÖÎÀíÔ±Ìá¸ßϵͳµÄ·ÀÓùÄÜÁ¦¡£
¸üÐÂϵͳºÍÈí¼þ°ü
¼á³ÖЧÀÍÆ÷µÄ²Ù×÷ϵͳºÍÈí¼þ°ü´¦ÓÚ×îеÄ״̬ÊÇ°ü¹ÜЧÀÍÆ÷Çå¾²µÄÖ÷Òª°ì·¨Ö®Ò»¡£ÊµÊ±¸üÐÂϵͳºÍÈí¼þ°ü£¬¿ÉÒÔÐÞ¸´ÒÑ·¢Ã÷µÄÎó²î£¬²¢Ìṩ¸üÇ¿Ê¢µÄÇå¾²¹¦Ð§¡£ÒÔÏÂÊÇÔÚCentOSϵͳÖÐʹÓÃyum¸üÐÂϵͳºÍÈí¼þ°üµÄʾÀý´úÂ룺
sudo yum update
µÇ¼ºó¸´ÖÆ
½ûÓò»ÐëÒªµÄЧÀÍ
LinuxЧÀÍÆ÷ĬÈÏÆô¶¯ÁËÐí¶à²»ÐëÒªµÄЧÀÍ£¬ÕâЩЧÀÍ¿ÉÄÜ»á³ÉΪ¹¥»÷ÕßÈëÇÖϵͳµÄDZÔÚÈë¿Ú¡£Ó¦¸Ã×ÐϸÉó²éЧÀÍÆ÷¿ªÆôµÄËùÓÐЧÀÍ£¬²¢Æ¾Ö¤ÏÖʵÐèÇó½ûÓò»ÐëÒªµÄЧÀÍ¡£ÒÔÏÂÊÇÔÚCentOSϵͳÖнûÓÃij¸öЧÀ͵ÄʾÀý´úÂ룺
sudo systemctl stop <service-name> sudo systemctl disable <service-name>
µÇ¼ºó¸´ÖÆ
ÉèÖ÷À»ðǽ
·À»ðǽÊDZ£»¤Ð§ÀÍÆ÷ÃâÊÜÍøÂç¹¥»÷µÄÒªº¦×é¼þÖ®Ò»¡£Í¨¹ýÉèÖ÷À»ðǽ¹æÔò£¬¿ÉÒÔÏÞÖÆЧÀÍÆ÷ÔÊÐí»á¼ûµÄIPµØµã¡¢¶Ë¿ÚºÍÐÒé¡£ÒÔÏÂÊÇÔÚCentOSϵͳÖÐʹÓ÷À»ðǽÉèÖÃЧÀÍfirewalldµÄʾÀý´úÂ룺
# Æô¶¯·À»ðǽЧÀÍ sudo systemctl start firewalld # ¿ªÆôSSH»á¼û sudo firewall-cmd --zone=public --add-port=22/tcp --permanent sudo firewall-cmd --reload # ¿ªÆôWebЧÀÍ»á¼û sudo firewall-cmd --zone=public --add-port=80/tcp --permanent sudo firewall-cmd --reload
µÇ¼ºó¸´ÖÆ
ÉèÖÃSSH»á¼û
SSHÊÇÖÎÀíÔ±Ô¶³ÌµÇ¼ЧÀÍÆ÷µÄ³£Ó÷½·¨¡£ÎªÁËÔöÌíSSH»á¼ûµÄÇå¾²ÐÔ£¬¿ÉÒÔ¾ÙÐÐÒÔÏÂÉèÖãº
ÐÞ¸ÄSSHĬÈ϶˿ڣº½«Ä¬ÈϵÄ22¶Ë¿Ú¸ÄΪһ¸öºÜÊÇÓö˿ڣ¬¿ÉÒÔïÔ̱©Á¦ÆƽâµÄΣº¦¡£
½ûÓÃrootÓû§µÇ¼£ºÕ¥È¡rootÓû§Ö±½ÓʹÓÃSSHµÇ¼ЧÀÍÆ÷£¬¿ÉÒÔÔöÌí¹¥»÷ÕßµÄÈëÇÖÄѶȡ£
ÉèÖù«Ô¿µÇ¼£ºÊ¹ÓÃÃÜÔ¿¶ÔµÇ¼ЧÀÍÆ÷£¬¶ø²»ÊÇÃÜÂëµÇ¼£¬¿ÉÒÔÌṩ¸ü¸ßµÄÇå¾²ÐÔ¡£
ÒÔÏÂÊÇÔÚÐÞ¸ÄSSHÉèÖÃÎļþµÄʾÀý´úÂ룺
sudo vi /etc/ssh/sshd_config # ÐÞ¸ÄSSHĬÈÏ¶Ë¿Ú Port 2222 # ½ûÓÃrootÓû§µÇ¼ PermitRootLogin no # ÉèÖù«Ô¿µÇ¼ RSAAuthentication yes PubkeyAuthentication yes
µÇ¼ºó¸´ÖÆ
ÐÞ¸ÄÍê³Éºó£¬Ê¹ÓÃÒÔÏÂÏÂÁîÖØÆôSSHЧÀÍ£º
sudo systemctl restart sshd
µÇ¼ºó¸´ÖÆ
Ìí¼Ó·À±©Á¦ÆƽâµÄÏÞÖÆ
ΪÁ˱ÜÃⱩÁ¦ÆƽâSSHÃÜÂ룬¿ÉÒÔÌí¼ÓÏÞÖÆ»úÖÆ£¬ÏÞÖÆSSHʧ°ÜµÇ¼µÄ´ÎÊýºÍʱ¼ä¾àÀë¡£ÒÔÏÂÊÇʹÓÃfail2ban¹¤¾ßÏÞÖÆSSH±©Á¦ÆƽâµÄʾÀý´úÂ룺
# ×°ÖÃfail2ban sudo yum install epel-release sudo yum install fail2ban # ½¨Éè×Ô½ç˵ÉèÖÃÎļþ sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local # ±à¼ÉèÖÃÎļþ sudo vi /etc/fail2ban/jail.local # ÐÞ¸ÄSSHÏà¹ØÉèÖà [sshd] enabled = true port = ssh logpath = %(sshd_log)s backend = %(sshd_backend)s maxretry = 3 bantime = 3600 # Æô¶¯fail2banЧÀÍ sudo systemctl start fail2ban sudo systemctl enable fail2ban
µÇ¼ºó¸´ÖÆ
ÒÔÉÏÊÇһЩ³£¼ûµÄLinuxЧÀÍÆ÷Çå¾²ÉèÖÃÒªÁìºÍʾÀý´úÂë¡£ËäÈ»£¬¹ØÓÚЧÀÍÆ÷Çå¾²À´Ëµ£¬ÉÐÓÐÐí¶àÆäËû·½ÃæÐèҪעÖØ£¬ÀýÈçÉèÖúÏÊʵÄÎļþȨÏÞ¡¢Ê¹ÓÃÇ¿ÃÜÂëµÈ¡£ÖÎÀíÔ±ÔÚ¾ÙÐÐЧÀÍÆ÷Çå¾²ÉèÖÃʱ£¬ÐèÒª×ÛºÏ˼Á¿Ð§ÀÍÆ÷µÄÏÖÕæÏàÐκÍÐèÇ󣬺ÏÀíÖƶ©Çå¾²Õ½ÂÔ£¬ÒÔÌá¸ßϵͳµÄ·ÀÓùÄÜÁ¦¡£
ÒÔÉϾÍÊÇLinuxЧÀÍÆ÷Çå¾²ÉèÖãºÌá¸ßϵͳ·ÀÓùÄÜÁ¦µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡