ÔõÑù½â¾öLinuxЧÀÍÆ÷ÉϵÄSSHÅþÁ¬ÖÐÖ¹ºÍ¾Ü¾øÎÊÌâ
ÔõÑù½â¾ölinuxЧÀÍÆ÷ÉϵÄsshÅþÁ¬ÖÐÖ¹ºÍ¾Ü¾øÎÊÌâ
ÔÚÒ»Ñùƽ³£µÄÔËάÊÂÇéÖУ¬Ê¹ÓÃSSH£¨Secure Shell£©¾ÙÐÐÔ¶³ÌÅþÁ¬ÊǷǾ³£¼ûµÄ²Ù×÷¡£Ö»¹ÜSSHÊÇÒ»ÖÖÇå¾²¿É¿¿µÄÐÒ飬µ«ÓÐʱÈÔÈ»»áÓöµ½ÅþÁ¬ÖÐÖ¹ºÍ¾Ü¾øµÄÎÊÌâ¡£ÕâЩÎÊÌâ¿ÉÄÜÓÉÓÚÖÖÖÖÔµ¹ÊÔÓÉÒýÆ𣬱¾ÎĽ«ÏÈÈÝһЩ³£¼ûµÄ½â¾öÒªÁì¡£
¼ì²éÍøÂçÅþÁ¬
Ê×ÏÈ£¬È·ÈÏЧÀÍÆ÷ºÍÍâµØ»úе֮¼äµÄÍøÂçÅþÁ¬ÊÇ·ñÕý³£¡£¿ÉÒÔͨ¹ýpingÏÂÁîÀ´²âÊÔЧÀÍÆ÷µÄ¿É´ïÐÔ¡£ÈôÊÇЧÀÍÆ÷ÎÞ·¨pingͨ£¬Ôò˵Ã÷ÍøÂçÅþÁ¬±£´æÎÊÌ⣬¿ÉÒÔ¼ì²éЧÀÍÆ÷Óë·ÓÉÆ÷Ö®¼äµÄÅþÁ¬£¬»òÁªÏµÍøÂçÖÎÀíÔ±½â¾öÍøÂçÎÊÌâ¡£
¼ì²éSSHЧÀÍÊÇ·ñÔËÐÐ
SSHÅþÁ¬ÎÊÌâ¿ÉÄÜÊÇÓÉÓÚSSHЧÀÍûÓÐÕý³£ÔËÐÐËùÖ¡£¿ÉÒÔͨ¹ýÒÔÏÂÏÂÁî¼ì²éSSHЧÀ͵Ä״̬£º
systemctl status sshd
µÇ¼ºó¸´ÖÆ
ÈôÊÇSSHЧÀÍδÔËÐУ¬ÇëʹÓÃÒÔÏÂÏÂÁîÆô¶¯Ëü£º
systemctl start sshd
µÇ¼ºó¸´ÖÆ
¼ì²éSSHÉèÖÃÎļþ
SSHÅþÁ¬ÎÊÌ⻹¿ÉÄÜÓëÉèÖÃÎļþÖеĹýʧÉèÖÃÏà¹Ø¡£¿ÉÒÔʹÓÃÎı¾±à¼Æ÷·¿ªSSHÉèÖÃÎļþ¾ÙÐмì²é¡£ÔÚ´ó´ó¶¼Linux¿¯ÐаæÉÏ£¬SSHÉèÖÃÎļþλÓÚ/etc/ssh/sshd_config¡£È·±£ÒÔÏÂÉèÖÃ׼ȷ£º
PortÉèÖÃΪ׼ȷµÄ¶Ë¿ÚºÅ£¬Ä¬ÒÔΪ22¡£
PermitRootLoginÉèÖÃΪyes£¬ÔÊÐírootÓû§µÇ¼£¨ÈôÊÇÐëÒª£©¡£
AllowUsersÉèÖÃΪ׼ȷµÄÔÊÐíµÇ¼µÄÓû§ÁÐ±í¡£
ÈôÊÇÐÞ¸ÄÁËÉèÖÃÎļþ£¬ÇëʹÓÃÒÔÏÂÏÂÁîÖØÆôSSHЧÀÍÒÔʹÉèÖÃÉúЧ£º
systemctl restart sshd
µÇ¼ºó¸´ÖÆ
·À»ðǽÉèÖÃ
·À»ðǽ¿ÉÄÜ»á×èÖ¹SSHÅþÁ¬¡£¿ÉÒÔͨ¹ýÒÔÏÂÏÂÁî¼ì²é·À»ðǽµÄ״̬£º
systemctl status firewalld
µÇ¼ºó¸´ÖÆ
ÈôÊÇ·À»ðǽÕýÔÚÔËÐУ¬ÔòÐèÒªÔÊÐíSSHÁ÷Á¿Í¨¹ý¡£¿ÉÒÔʹÓÃÒÔÏÂÏÂÁÆôSSHЧÀ͵Ķ˿ڣº
firewall-cmd --permanent --add-service=ssh firewall-cmd --reload
µÇ¼ºó¸´ÖÆ
Çë×¢ÖØ£¬ÏêϸµÄ·À»ðǽÏÂÁî¿ÉÄÜÒò²î±ðµÄLinux¿¯Ðаæ¶øÓÐËù²î±ð¡£
¼ì²éSSHÃÜÔ¿
SSHÅþÁ¬ÎÊÌ⻹¿ÉÄÜÓëÃÜÔ¿Óйء£ÔÚÍâµØ»úеÉÏ£¬ÐèҪʹÓúÏÊʵÄ˽ԿÀ´¾ÙÐÐÉí·ÝÑéÖ¤¡£È·±£Ë½Ô¿ÊÇ·ñ׼ȷ£¬²¢ÇÒÓëЧÀÍÆ÷ÉϵĹ«Ô¿Æ¥Åä¡£ÈôÊÇ˽ԿË𻵻òɥʧ£¬¿ÉÒÔÖØÐÂÌìÉúSSHÃÜÔ¿¶Ô£¬²¢½«¹«Ô¿¸´ÖƵ½Ð§ÀÍÆ÷ÉÏ¡£
¼ì²éµÇ¼ȨÏÞ
SSHÅþÁ¬ÎÊÌ⻹¿ÉÄÜÓëµÇ¼ȨÏÞÓйء£È·±£ÍâµØ»úеÉϵÄÓû§¾ßÓÐ׼ȷµÄµÇ¼ȨÏÞ¡£¿ÉÒÔÔÚЧÀÍÆ÷ÉÏʹÓÃÒÔÏÂÏÂÁîÉó²éÓû§µÄµÇ¼ȨÏÞ£º
cat /etc/passwd | grep username
µÇ¼ºó¸´ÖÆ
È·±£Óû§µÄµÇ¼ShellÉèÖÃΪ¿ÉÖ´ÐеÄShell£¬Èç/bin/bash¡£
¼ì²éЧÀÍÆ÷¸ºÔØ
ЧÀÍÆ÷¸ºÔعý¸ß¿ÉÄܵ¼ÖÂSSHÅþÁ¬±»¾Ü¾ø¡£¿ÉÒÔͨ¹ýÒÔÏÂÏÂÁîÉó²éЧÀÍÆ÷¸ºÔØ£º
uptime
µÇ¼ºó¸´ÖÆ
ÈôÊǸºÔعý¸ß£¬¿ÉÒÔʵÑéʹÓÃһЩÊʵ±µÄÒªÁìÀ´¼õÇḺÔØ£¬Èç×èֹһЩռÓÃCPU×ÊÔ´½Ï¶àµÄÀú³Ì¡£
×ܽ᣺
ÔÚ½â¾öLinuxЧÀÍÆ÷ÉϵÄSSHÅþÁ¬ÖÐÖ¹ºÍ¾Ü¾øÎÊÌâʱ£¬Ê×ÏÈÐèÒª¼ì²éÍøÂçÅþÁ¬ºÍSSHЧÀÍ״̬¡£Í¬Ê±£¬»¹Ó¦¼ì²éSSHÉèÖÃÎļþ¡¢·À»ðǽÉèÖá¢SSHÃÜÔ¿¡¢µÇ¼ȨÏÞÒÔ¼°Ð§ÀÍÆ÷¸ºÔصÈÒòËØ£¬È·±£ÕâЩÉèÖö¼ÇкÏÒªÇó¡£Í¨¹ýÕâЩҪÁ죬ÎÒÃÇ¿ÉÒÔ¸ü¿ìµØ½â¾öSSHÅþÁ¬ÎÊÌ⣬´Ó¶øÌá¸ßÊÂÇéЧÂÊ¡£
ÒÔÉϾÍÊÇÔõÑù½â¾öLinuxЧÀÍÆ÷ÉϵÄSSHÅþÁ¬ÖÐÖ¹ºÍ¾Ü¾øÎÊÌâµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡