尊龙凯时人生就是博

Linux SysOps SSHµÇ¼ÎÊÌâÅŲéÓë½â¾öÒªÁì

Linux SysOps SSHµÇ¼ÎÊÌâÅŲéÓë½â¾öÒªÁì

СÐò£º

ÔÚLinuxϵͳÔËάÖУ¬SSHÊÇÎÒÃǾ­³£Ê¹ÓõÄÔ¶³ÌµÇ¼¹¤¾ß£¬µ«ÓÐʱÎÒÃÇ»áÓöµ½SSHµÇ¼ÎÊÌ⣬Õâ¸øÎÒÃǵÄÊÂÇé´øÀ´ÁËÀ§ÈÅ¡£±¾ÎĽ«ÏÈÈݼ¸ÖÖ³£¼ûµÄSSHµÇ¼ÎÊÌâ²¢ÌṩÏìÓ¦µÄ½â¾öÒªÁ죬ͬʱ¸ø³öÏêϸµÄ´úÂëʾÀý¡£

Ò»¡¢Ô¶³ÌÅþÁ¬±»¾Ü¾øÎÊÌâ

ÎÊÌâÐÎò£º

µ±ÎÒÃÇʵÑéͨ¹ýSSHÔ¶³ÌÅþÁ¬LinuxЧÀÍÆ÷ʱ£¬¿ÉÄÜ»áÓöµ½”Connection refused”»ò”Connection timed out”µÄ¹ýʧÌáÐÑ¡£

½â¾öÒªÁ죺

Ҫȷ±£SSHЧÀÍÒѾ­Æô¶¯£¬¿ÉÒÔʹÓÃÒÔÏÂÏÂÁî¼ì²é£º

systemctl status sshd

µÇ¼ºó¸´ÖÆ

ÈôÊÇЧÀÍûÓÐÆô¶¯£¬¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîÆô¶¯Ð§ÀÍ£º

systemctl start sshd

µÇ¼ºó¸´ÖÆ

¼ì²éЧÀÍÆ÷¶Ë·À»ðǽÉèÖ㬱ÜÃâ·ºÆð¶Ë¿Ú±»×èÖ¹µÄÇéÐΡ£¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîÉó²éÄ¿½ñ·À»ðǽ¹æÔò£º

iptables -L

µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ

ÈôÊÇ·¢Ã÷SSHµÄ¶Ë¿ÚºÅ±»Õ¥È¡£¬¿ÉÒÔʹÓÃÒÔÏÂÏÂÁî·­¿ªÏìÓ¦µÄ¶Ë¿Ú£º

iptables -I INPUT -p tcp --dport 22 -j ACCEPT
iptables-save

µÇ¼ºó¸´ÖÆ

¶þ¡¢ÃÜÔ¿Ñé֤ʧ°ÜÎÊÌâ

ÎÊÌâÐÎò£º

µ±ÎÒÃÇʹÓÃÃÜÔ¿µÇ¼SSHʱ£¬ÓÐʱ»áÓöµ½”Permission denied (publickey)”µÄ¹ýʧÌáÐÑ¡£

½â¾öÒªÁ죺

¼ì²éÃÜÔ¿ÎļþµÄȨÏÞÉèÖã¬È·±£Ö»ÓÐÓµÓÐÕ߿ɶÁ£¬ÆäËûÈËûÓÐȨÏÞ¡£¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîÐÞ¸ÄÃÜÔ¿ÎļþȨÏÞ£º

chmod 600 ~/.ssh/id_rsa

µÇ¼ºó¸´ÖÆ

È·ÈÏЧÀÍÆ÷¶ËÒѾ­Ìí¼ÓÁËÏìÓ¦µÄ¹«Ô¿¡£¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîÉó²éЧÀÍÆ÷ÉÏÒѾ­Ìí¼ÓµÄ¹«Ô¿ÁÐ±í£º

cat ~/.ssh/authorized_keys

µÇ¼ºó¸´ÖÆ

ÈôÊÇЧÀÍÆ÷¶ËûÓÐ׼ȷÉèÖù«Ô¿£¬¿ÉÒÔʹÓÃÒÔÏÂÏÂÁÍâµØÅÌËã»úµÄ¹«Ô¿¸´ÖƵ½Ð§ÀÍÆ÷ÉÏ£º

ssh-copy-id user@server-ip

µÇ¼ºó¸´ÖÆ

Èý¡¢ÅþÁ¬³¬Ê±ÎÊÌâ

ÎÊÌâÐÎò£º

µ±ÎÒÃÇʵÑéÅþÁ¬LinuxЧÀÍÆ÷ʱ£¬¿ÉÄÜ»áÓöµ½Áè¼Ýָ׼ʱ¼äûÓÐÏìÓ¦µÄÎÊÌâ¡£

½â¾öÒªÁ죺

¼ì²éÍøÂçÅþÁ¬ÊÇ·ñÕý³£¡£¿ÉÒÔʹÓÃÒÔÏÂÏÂÁî¼ì²éÍøÂçÅþÁ¬×´Ì¬£º

ping server-ip

µÇ¼ºó¸´ÖÆ

ÐÞ¸ÄSSH¿Í»§¶ËµÄÅþÁ¬³¬Ê±Ê±¼ä¡£¿ÉÒÔÔÚSSH¿Í»§¶ËµÄÉèÖÃÎļþÖоÙÐÐÏìÓ¦ÉèÖ᣷­¿ªÉèÖÃÎļþ”/etc/ssh/ssh_config”£¬ÕÒµ½”ServerAliveInterval”ºÍ”ServerAliveCountMax”Á½¸ö²ÎÊý£¬»®·ÖÉèÖÃΪºÏÊʵÄÊýÖµ£¬ÀýÈ磺

ServerAliveInterval 60
ServerAliveCountMax 3

µÇ¼ºó¸´ÖÆ

ËÄ¡¢µÇ¼ʧ°Ü´ÎÊýÏÞÖÆÎÊÌâ

ÎÊÌâÐÎò£º

µ±ÎÒÃǶà´ÎʵÑéµÇ¼ʧ°Üºó£¬ÏµÍ³¿ÉÄÜ»á¶ÔµÇ¼¾ÙÐÐÏÞÖÆ¡£

½â¾öÒªÁ죺

¼ì²éÊÇ·ñÓÐiptables¹æÔò¶ÔµÇ¼¾ÙÐÐÁËÏÞÖÆ¡£¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîÉó²éiptables¹æÔò£º

iptables -L

µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ

ÈôÊÇÓÐÏÞÖƹæÔò±£´æ£¬¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîɾ³ýÏìÓ¦¹æÔò£º

iptables -D INPUT -p tcp --dport 22 -m state --state NEW -m recent --set
iptables -D INPUT -p tcp --dport 22 -m state --state NEW -m recent --update --seconds 60 --hitcount 3 -j DROP
iptables-save

µÇ¼ºó¸´ÖÆ

½áÓ

ͨ¹ý±¾ÎÄ£¬ÎÒÃÇѧϰÁËһЩ³£¼ûµÄSSHµÇ¼ÎÊÌâÒÔ¼°½â¾öÒªÁ죬²¢ÌṩÁËÏêϸµÄ´úÂëʾÀý¡£Ï£ÍûÕâЩҪÁìÄÜ×ÊÖú¶ÁÕ߸üÓÐÓõØÅŲéÏ¢Õù¾öSSHµÇ¼ÎÊÌ⣬Ìá¸ßÔËάÊÂÇéµÄЧÂÊ¡£Í¬Ê±£¬Ò²ÌáÐѸ÷ÈËÔÚ²Ù×÷ϵͳÖоÙÐÐÉèÖñ任ʱ£¬Îñ±ØСÐÄÉóÉ÷£¬×èÖ¹¶ÔϵͳÔì³ÉÎÞ·¨ÐÞ¸´µÄË𻵡£

ÒÔÉϾÍÊÇLinux SysOps SSHµÇ¼ÎÊÌâÅŲéÓë½â¾öÒªÁìµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í尊龙凯时人生就是博ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ尊龙凯时人生就是博ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是博

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎ壬9:30-18:30£¬½ÚãåÈÕÐÝÏ¢

QR code
sitemap¡¢ÍøÕ¾µØͼ