¼Ó¹ÌLinuxЧÀÍÆ÷£ºÔËÓÃÏÂÁîÐй¤¾ßÌá¸ßÇå¾²ÐÔ
¼Ó¹ÌLinuxЧÀÍÆ÷£ºÔËÓÃÏÂÁîÐй¤¾ßÌá¸ßÇå¾²ÐÔ
¸ÅÊö£º
ÔÚµ±½ñµÄÍøÂçÇéÐÎÏ£¬Ð§ÀÍÆ÷Çå¾²ÐÔÊÇÖÁ¹ØÖ÷ÒªµÄ¡£ÎªÁ˱£»¤Ð§ÀÍÆ÷ÃâÊܶñÒâ¹¥»÷ºÍδ¾ÊÚȨµÄ»á¼û£¬Ê¹ÓÃÏÂÁîÐй¤¾ßÀ´¼Ó¹ÌLinuxЧÀÍÆ÷ÊÇÒ»¸öÐëÒªµÄ°ì·¨¡£±¾ÎĽ«ÏÈÈÝһЩ³£ÓõÄÏÂÁîÐй¤¾ß£¬ÒÔ¼°ËüÃǵÄʹÓÃÒªÁìºÍʾÀý´úÂ룬×ÊÖúÄúÌá¸ßЧÀÍÆ÷µÄÇå¾²ÐÔ¡£
SSH¼ÓÃÜ´«Ê䣺
SSH£¨Secure Shell£©ÊÇÒ»ÖÖ¼ÓÃܵÄÍøÂçÐÒ飬ÓÃÓÚÔ¶³ÌµÇ¼ºÍÖ´ÐÐÏÂÁͨ¹ýʹÓÃSSH£¬¿ÉÒÔ±ÜÃâ¶ñÒâÓû§½ØÈ¡ºÍÇÔÌý´«ÊäÖеÄÊý¾Ý¡£ÒÔÏÂÊÇʹÓÃSSHÌìÉúºÍʹÓÃÃÜÔ¿¶ÔµÄʾÀý´úÂ룺
ÌìÉúSSHÃÜÔ¿¶Ô£º
ssh-keygen -t rsa -b 4096
µÇ¼ºó¸´ÖÆ
½«¹«Ô¿¸´ÖƵ½Ô¶³ÌЧÀÍÆ÷£º
ssh-copy-id Óû§Ãû@IPµØµã
µÇ¼ºó¸´ÖÆ
½ûÓÃÃÜÂëµÇ¼£¨¿ÉÑ¡£©£º
sudo vi /etc/ssh/sshd_config
µÇ¼ºó¸´ÖÆ
ÕÒµ½#PasswordAuthentication yesÕâÒ»ÐУ¬½«Æä¸ÄΪPasswordAuthentication no£¬È»ºóÉúÑIJ¢Í˳ö¡£
ÖØÐÂÆô¶¯SSHЧÀÍ£º
sudo systemctl restart sshd
µÇ¼ºó¸´ÖÆ
·À»ðǽÉèÖãº
·À»ðǽÊÇÒ»ÖÖÍøÂçÇå¾²×°±¸£¬ÓÃÓÚ¼à¿ØºÍ¿ØÖÆÍøÂçÉϵÄÊý¾ÝÁ÷¡£Ê¹Ó÷À»ðǽ¿ÉÒÔÏÞÖÆЧÀÍÆ÷ÉϵÄÈëÕ¾ºÍ³öÕ¾Á÷Á¿£¬Ìṩ¶Ô¶ñÒâ¹¥»÷µÄ±£»¤¡£ÒÔÏÂÊÇʹÓÃiptablesÏÂÁîÉèÖ÷À»ðǽ¹æÔòµÄʾÀý´úÂ룺
×°ÖÃiptables£º
sudo apt-get install iptables
µÇ¼ºó¸´ÖÆ
½¨ÉèеķÀ»ðǽ¹æÔòÎļþ£º
sudo touch /etc/iptables.rules sudo vi /etc/iptables.rules
µÇ¼ºó¸´ÖÆ
ÔÚÎļþÖÐÌí¼ÓÒÔϹæÔò£º
*filter # ĬÈÏÕ½ÂÔ :INPUT DROP [0:0] :FORWARD DROP [0:0] :OUTPUT ACCEPT [0:0] # ÔÊÐíÍâµØ»Ø»·½Ó¿ÚµÄ»á¼û -A INPUT -i lo -j ACCEPT # ÔÊÐíÒѾ½¨ÉèµÄ¡¢Ïà¹ØµÄÅþÁ¬½øÈë -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT # ÔÊÐíSSHÅþÁ¬ -A INPUT -p tcp --dport 22 -j ACCEPT # ÔÊÐíÆäËûÐëÒªµÄ¶Ë¿Ú # -A INPUT -p tcp --dport 80 -j ACCEPT # -A INPUT -p tcp --dport 443 -j ACCEPT # ÔÊÐíICMP (Ping)ÇëÇó -A INPUT -p icmp --icmp-type echo-request -j ACCEPT # ÔÊÐíÏÞÖƵÄIPµØµã¹æÄ£ -A INPUT -s ÔÊÐíÅþÁ¬µÄIPµØµã/×ÓÍøÑÚÂë -j ACCEPT # ÔÊÐíij¸öIPµØµã¹æÄ£µÄ»á¼û # -A INPUT -s ÔÊÐíÅþÁ¬µÄIPµØµã/×ÓÍøÑÚÂë -j ACCEPT # ¾Ü¾øËùÓÐÆäËûÈëÕ¾Á÷Á¿ -A INPUT -j DROP COMMIT
µÇ¼ºó¸´ÖÆ
¼ÓÔØ·À»ðǽ¹æÔò²¢ÉèÖÿª»úÆô¶¯£º
sudo iptables-restore < /etc/iptables.rules sudo touch /etc/network/if-pre-up.d/iptables sudo chmod +x /etc/network/if-pre-up.d/iptables sudo vi /etc/network/if-pre-up.d/iptables
µÇ¼ºó¸´ÖÆ
ÔÚÎļþÖÐÌí¼ÓÒÔÏÂÄÚÈÝ£º
#!/bin/sh /sbin/iptables-restore < /etc/iptables.rules
µÇ¼ºó¸´ÖÆ
ÖØÆôЧÀÍÆ÷ÒÔÓ¦ÓÃеķÀ»ðǽ¹æÔò£º
sudo reboot
µÇ¼ºó¸´ÖÆ
ÈÕÖ¾ºÍ¼àÊÓ£º
ÈÕÖ¾¼Í¼ºÍ¼àÊÓÊÇЧÀÍÆ÷Çå¾²ÐÔµÄÖ÷Òª×é³É²¿·Ö¡£Í¨¹ý°´ÆÚÉó²éЧÀÍÆ÷ÈÕÖ¾£¬¿ÉÒÔ·¢Ã÷Òì³£Ô˶¯²¢½ÓÄÉÏìÓ¦²½·¥¡£ÒÔÏÂÊÇʹÓó£ÓõÄÈÕÖ¾¼Í¼ºÍ¼àÊÓ¹¤¾ßµÄʾÀý´úÂ룺
Éó²éϵͳÈÕÖ¾£º
sudo tail -f /var/log/syslog
µÇ¼ºó¸´ÖÆ
Éó²éÊÚȨÓû§ÈÕÖ¾£º
sudo tail -f /var/log/auth.log
µÇ¼ºó¸´ÖÆ
¼àÊÓÍøÂçÅþÁ¬£º
sudo apt-get install nethogs sudo nethogs
µÇ¼ºó¸´ÖÆ
¼àÊÓϵͳ×ÊԴʹÓÃÇéÐΣº
sudo apt-get install htop sudo htop
µÇ¼ºó¸´ÖÆ
×ܽ᣺
ͨ¹ýʹÓÃÒÔÉÏÏÂÁîÐй¤¾ßºÍʾÀý´úÂ룬Äú¿ÉÒÔÔöÇ¿LinuxЧÀÍÆ÷µÄÇå¾²ÐÔ¡£´ÓÌìÉúSSHÃÜÔ¿¶ÔºÍ½ûÓÃÃÜÂëµÇ¼µ½ÉèÖ÷À»ðǽ¹æÔòºÍ¼àÊÓЧÀÍÆ÷ÈÕÖ¾£¬ÕâЩ°ì·¨¿ÉÒÔ×ÊÖúÄú±£»¤Ð§ÀÍÆ÷ÃâÊܶñÒâ¹¥»÷ºÍδ¾ÊÚȨµÄ»á¼û¡£ÔÚÔËάЧÀÍÆ÷ʱ£¬ÇëÎñÒ»°´ÆÚÉó²éЧÀÍÆ÷ÈÕÖ¾²¢¼àÊÓϵͳ×ÊÔ´µÄʹÓÃÇéÐΣ¬ÒÔÈ·±£Ð§ÀÍÆ÷µÄÇå¾²ÐÔºÍÎȹÌÐÔ¡£
ÒÔÉϾÍÊǼӹÌLinuxЧÀÍÆ÷£ºÔËÓÃÏÂÁîÐй¤¾ßÌá¸ßÇå¾²ÐÔµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡