linuxÅþÁ¬sshʱÓÐһ̨ʼÖÕÎÞ·¨ÅþÁ¬Ôõô½â¾ö
linuxÅþÁ¬sshʱÓÐһ̨ʼÖÕÎÞ·¨ÅþÁ¬µÄ½â¾öÒªÁìÓУº1¡¢¼ì²éÄ¿µÄÖ÷»úµÄipµØµã¡¢ÍøÂçÉèÖúͷÀ»ðǽÉèÖÃÊÇ·ñ׼ȷ£»2¡¢È·ÈÏÄ¿µÄÖ÷»úÉϵÄsshЧÀÍÊÇ·ñÕýÔÚÔËÐУ»3¡¢¼ì²éÄ¿µÄÖ÷»úÉϵķÀ»ðǽÉèÖã»4¡¢¼ì²éÄ¿µÄÖ÷»úÉϵÄsshÉèÖÃÎļþÊÇ·ñ׼ȷ£»5¡¢ÈôÊÇʹÓà ssh ÃÜÔ¿¾ÙÐÐÈÏÖ¤£¬È·±£¹«Ô¿ÒѾ׼ȷÌí¼Óµ½Ä¿µÄÖ÷»ú£»6¡¢ÊµÑéͨ¹ýÌí¼Ó-v²ÎÊýÀ´Æô¶¯sshÅþÁ¬£¬ÒÔ±ãÉó²éÏêϸµÄÅþÁ¬µ÷ÊÔÐÅÏ¢¡£
±¾½Ì³Ì²Ù×÷ϵͳ£ºLinux5.18.14ϵͳ¡¢Dell G3µçÄÔ¡£
ÔÚÅþÁ¬ Linux SSH ʱÓöµ½Ò»Ì¨Ê¼ÖÕÎÞ·¨ÅþÁ¬µÄÇéÐΣ¬¿ÉÒÔʵÑéÒÔÏ°취À´½â¾öÎÊÌ⣺
1¡¢ÍøÂçÅþÁ¬¼ì²é£º
È·±£Ä¿µÄ Linux Ö÷»úºÍÄãµÄÅÌËã»úÔÚͳһÍøÂçÖУ¬²¢ÇÒÍøÂçÅþÁ¬Õý³£¡£¼ì²éÄ¿µÄÖ÷»úµÄ IP µØµã¡¢ÍøÂçÉèÖúͷÀ»ðǽÉèÖÃÊÇ·ñ׼ȷ¡£
2¡¢SSH ЧÀÍ״̬£º
È·ÈÏÄ¿µÄ Linux Ö÷»úÉ쵀 SSH ЧÀÍÊÇ·ñÕýÔÚÔËÐС£¿ÉÒÔʹÓÃÒÔÏÂÏÂÁî¼ì²é SSH ЧÀÍ״̬£º
service ssh status
µÇ¼ºó¸´ÖÆ
ÈôÊÇ SSH ЧÀÍδÔËÐУ¬¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîÆô¶¯ SSH ЧÀÍ£¨ÐèÒª root ȨÏÞ£©£º
service ssh start
µÇ¼ºó¸´ÖÆ
3¡¢Ä¿µÄÖ÷»ú·À»ðǽ£º
¼ì²éÄ¿µÄÖ÷»úÉϵķÀ»ðǽÉèÖã¬È·±£ SSH ЧÀ͵Ķ˿ڣ¨Ä¬ÒÔΪ 22£©Ã»Óб»×èÖ¹¡£¿ÉÒÔʵÑé¹Ø±Õ·À»ðǽ»òÕßÌí¼ÓÏìÓ¦µÄ¹æÔòÔÊÐí SSH ÅþÁ¬¡£
4¡¢SSH ÉèÖÃÎļþ£º
¼ì²éÄ¿µÄÖ÷»úÉ쵀 SSH ÉèÖÃÎļþ£¬È·ÈÏ SSH ЧÀ͵ÄÏà¹ØÉèÖÃÊÇ·ñ׼ȷ¡£ÉèÖÃÎļþͨ³£Î»ÓÚ /etc/ssh/sshd_config£¬¿ÉÒÔʹÓÃÎı¾±à¼Æ÷·¿ª²¢¼ì²éÏà¹ØÉèÖÃÏî¡£
5¡¢SSH ÃÜÔ¿ÈÏÖ¤£º
ÈôÊÇÄãʹÓà SSH ÃÜÔ¿¾ÙÐÐÈÏÖ¤£¬ÇëÈ·±£ÄãµÄ¹«Ô¿ÒѾ׼ȷÌí¼Óµ½Ä¿µÄÖ÷»úµÄ ~/.ssh/authorized_keys ÎļþÖС£¿ÉÒÔʹÓÃÒÔÏÂÏÂÁ¹«Ô¿Ìí¼Óµ½Ä¿µÄÖ÷»úµÄ authorized_keys ÎļþÖУº
ssh-copy-id username@target_host
µÇ¼ºó¸´ÖÆ
Ìæ»» username ΪÄãµÄÓû§Ãû£¬target_host ΪĿµÄÖ÷»úµÄ IP µØµã»òÓòÃû¡£
6¡¢SSH ²ÎÊýµ÷ÊÔ£º
ʵÑéͨ¹ýÌí¼Ó -v ²ÎÊýÀ´Æô¶¯ SSH ÅþÁ¬£¬ÒÔ±ãÉó²éÏêϸµÄÅþÁ¬µ÷ÊÔÐÅÏ¢¡£ÀýÈ磺
ssh -v username@target_host
µÇ¼ºó¸´ÖÆ
Õ⽫Êä³öÅþÁ¬Àú³ÌÖеÄÏêϸÐÅÏ¢£¬¿ÉÒÔ×ÊÖúÄãÈ·¶¨ÅþÁ¬Ê§°ÜµÄÏêϸԵ¹ÊÔÓÉ¡£
ÈôÊÇÄãÈÔÈ»ÎÞ·¨½â¾öÅþÁ¬ÎÊÌ⣬½¨Òé¼ì²éÄ¿µÄÖ÷»úµÄϵͳÈÕÖ¾£¨Èç /var/log/messages »ò /var/log/auth.log£©ÒÔ»ñÈ¡¸ü¶àµÄ¹ýʧÐÅÏ¢¡£ÁíÍ⣬ÈôÊÇ¿ÉÄܵĻ°£¬ÊµÑé´ÓÆäËûÅÌËã»ú¾ÙÐÐ SSH ÅþÁ¬ÒÔÑéÖ¤ÊÇ·ñÊÇÌض¨ÅÌËã»úµÄÎÊÌâ¡£
ÒÔÉϾÍÊÇlinuxÅþÁ¬sshʱÓÐһ̨ʼÖÕÎÞ·¨ÅþÁ¬Ôõô½â¾öµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡