{"id":1211,"date":"2025-04-08T13:56:07","date_gmt":"2025-04-08T13:56:07","guid":{"rendered":"https:\/\/linuxjk.cn\/?p=1211"},"modified":"2025-04-09T03:40:20","modified_gmt":"2025-04-09T03:40:20","slug":"ssh","status":"publish","type":"post","link":"https:\/\/linuxjk.cn\/?p=1211","title":{"rendered":"ssh\u4e4b\u5bc6\u94a5\u767b\u5f55"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"1211\" class=\"elementor elementor-1211\">\n\t\t\t\t<div class=\"elementor-element elementor-element-c9ac469 e-flex e-con-boxed e-con e-parent\" data-id=\"c9ac469\" data-element_type=\"container\" data-e-type=\"container\">\n\t\t\t\t\t<div class=\"e-con-inner\">\n\t\t\t\t<div class=\"elementor-element elementor-element-07ab248 elementor-widget elementor-widget-text-editor\" data-id=\"07ab248\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>\u00a0 \u00a0 \u7528ssh\u79d8\u94a5\u8fde\u63a5\u975e\u5e38\u65b9\u4fbf\uff0c\u4e00\u65b9\u9762\u53ef\u4ee5\u8bbe\u7f6e\u53c2\u6570\u63d0\u9ad8\u7cfb\u7edf\u5b89\u5168\u6027\uff08PermitRootLogin prohibit-password root\u7528\u6237\u53ea\u80fd\u79d8\u94a5\u767b\u5f55\uff09\uff0c\u4e00\u65b9\u9762\u5728\u4e24\u4e2a\u670d\u52a1\u5668\u4e4b\u95f4\u8fde\u63a5\u65f6\u7701\u53bb\u4e86\u8f93\u5bc6\u7801\u7684\u9ebb\u70e6\uff0c\u5217\u4e3e\u4e24\u4e2assh\u79d8\u94a5\u7684\u914d\u7f6e\u65b9\u6cd5<\/p><div><p>\u5728SSH\u5bc6\u94a5\u5bf9\u4e2d\uff0c<strong><em class=\"rd_inl_code\">id_rsa<\/em><\/strong>\u00a0\u548c\u00a0<strong><em class=\"rd_inl_code\">id_rsa.pub<\/em><\/strong>\u00a0\u5206\u522b\u4ee3\u8868\u79c1\u94a5\u548c\u516c\u94a5\u3002\u5177\u4f53\u6765\u8bf4\uff1a<\/p><\/div><div><ul class=\"b_vList b_divsec b_bullet\"><li data-priority=\"\"><p><strong><em class=\"rd_inl_code\">id_rsa<\/em><\/strong> \u662f\u79c1\u94a5\u3002\u79c1\u94a5\u5e94\u5f53\u4fdd\u5bc6\uff0c\u4e0d\u5e94\u4e0e\u4efb\u4f55\u4eba\u6216\u4efb\u4f55\u670d\u52a1\u5171\u4eab\u3002\u5b83\u4fdd\u5b58\u5728\u672c\u5730\u8ba1\u7b97\u673a\u4e0a\uff0c\u7528\u4e8e\u5339\u914d\u516c\u94a5\u5e76\u9a8c\u8bc1\u8eab\u4efd\u3002\u79c1\u94a5\u7684\u6743\u9650\u5e94\u4e25\u683c\u9650\u5236\u4e3a\u53ea\u6709\u6240\u6709\u8005\u53ef\u4ee5\u8bfb\u53d6\uff08\u5728Unix\/Linux\u7cfb\u7edf\u4e2d\uff0c\u6743\u9650\u901a\u5e38\u8bbe\u7f6e\u4e3a600\uff09<\/p><\/li><li data-priority=\"\"><p><strong><em class=\"rd_inl_code\">id_rsa.pub<\/em><\/strong>\u00a0\u662f\u516c\u94a5\u3002\u516c\u94a5\u53ef\u4ee5\u5206\u4eab\u7ed9\u4efb\u4f55\u9700\u8981\u9a8c\u8bc1\u4f60\u8eab\u4efd\u7684\u7cfb\u7edf\uff0c\u4f8b\u5982SSH\u670d\u52a1\u5668\u6216GitHub\u7b49\u4ee3\u7801\u6258\u7ba1\u5e73\u53f0\u3002\u5f53\u4f60\u5c1d\u8bd5\u8fde\u63a5\u8fd9\u4e9b\u7cfb\u7edf\u65f6\uff0c\u7cfb\u7edf\u4f1a\u5229\u7528\u4f60\u7684\u516c\u94a5\u9a8c\u8bc1\u4f60\u662f\u5426\u6301\u6709\u76f8\u5e94\u7684\u79c1\u94a5<\/p><\/li><\/ul><\/div>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-96a1287 elementor-widget elementor-widget-text-editor\" data-id=\"96a1287\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">\u76ee\u5f55<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-1'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/linuxjk.cn\/?p=1211\/#%E7%AC%AC0%E6%AD%A5%E2%80%93%E6%A3%80%E6%9F%A5%E6%9D%83%E9%99%90\" >\u7b2c0\u6b65&#8211;\u68c0\u67e5\u6743\u9650<\/a><ul class='ez-toc-list-level-2' ><li class='ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/linuxjk.cn\/?p=1211\/#xshell%E7%AD%89%E5%AE%A2%E6%88%B7%E7%AB%AF%E5%B7%A5%E5%85%B7%E8%BF%9E%E6%8E%A5%E6%9C%8D%E5%8A%A1%E5%99%A8\" >xshell\u7b49\u5ba2\u6237\u7aef\u5de5\u5177\u8fde\u63a5\u670d\u52a1\u5668<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/linuxjk.cn\/?p=1211\/#%E2%91%A0%E9%A6%96%E5%85%88%E5%9C%A8%E6%9C%8D%E5%8A%A1%E5%99%A8%E4%B8%8A%E4%BD%BF%E7%94%A8ssh_-keygen%E7%94%9F%E6%88%90%E7%A7%98%E9%92%A5\" >\u2460\u9996\u5148\u5728\u670d\u52a1\u5668\u4e0a\u4f7f\u7528ssh -keygen\u751f\u6210\u79d8\u94a5<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/linuxjk.cn\/?p=1211\/#SSH_%E5%AF%86%E9%92%A5%E5%AF%B9%E7%9A%84%E5%88%9B%E5%BB%BA%E6%96%B9%E6%B3%95\" >SSH \u5bc6\u94a5\u5bf9\u7684\u521b\u5efa\u65b9\u6cd5<\/a><ul class='ez-toc-list-level-5' ><li class='ez-toc-heading-level-5'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/linuxjk.cn\/?p=1211\/#1_%E9%BB%98%E8%AE%A4%E7%94%9F%E6%88%90_RSA_%E5%AF%86%E9%92%A5%E2%80%93ssh-keygen\" >1. \u9ed8\u8ba4\u751f\u6210 RSA \u5bc6\u94a5&#8211;ssh-keygen<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/linuxjk.cn\/?p=1211\/#2_%E7%94%9F%E6%88%90_ED25519_%E5%AF%86%E9%92%A5%EF%BC%88%E6%9B%B4%E5%AE%89%E5%85%A8%EF%BC%89\" >2. \u751f\u6210 ED25519 \u5bc6\u94a5\uff08\u66f4\u5b89\u5168\uff09<\/a><ul class='ez-toc-list-level-5' ><li class='ez-toc-heading-level-5'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/linuxjk.cn\/?p=1211\/#3_%E7%94%9F%E6%88%90_ECDSA_%E5%AF%86%E9%92%A5\" >3. \u751f\u6210 ECDSA \u5bc6\u94a5<\/a><\/li><\/ul><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/linuxjk.cn\/?p=1211\/#%E2%91%A1%E6%9C%8D%E5%8A%A1%E5%99%A8%E7%AB%AF%E8%BF%9B%E5%85%A5ssh%E7%9B%AE%E5%BD%95%E6%89%A7%E8%A1%8C\" >\u2461\u670d\u52a1\u5668\u7aef\u8fdb\u5165.ssh\u76ee\u5f55\u6267\u884c<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/linuxjk.cn\/?p=1211\/#%E2%91%A2%E5%88%A9%E7%94%A8%E5%90%84%E7%A7%8D%E6%96%B9%E5%BC%8F%E6%8A%8A%E7%A7%81%E9%92%A5id_rsa%E4%BC%A0%E8%BE%93%E5%88%B0%E7%94%B5%E8%84%91%E4%B8%AD\" >\u2462\u5229\u7528\u5404\u79cd\u65b9\u5f0f\u628a\u79c1\u94a5id_rsa\u4f20\u8f93\u5230\u7535\u8111\u4e2d<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/linuxjk.cn\/?p=1211\/#%E2%91%A3%E6%89%93%E5%BC%80xshell%E7%AB%AF%E5%B7%A5%E5%85%B7%E2%86%92%E7%94%A8%E6%88%B7%E5%AF%86%E9%92%A5%E7%AE%A1%E7%90%86%E8%80%85%E2%86%92%E6%8A%8A%E6%9C%8D%E5%8A%A1%E5%99%A8%E5%88%9A%E7%94%9F%E6%88%90%E5%A5%BD%E7%9A%84id_rsa%E5%AF%86%E9%92%A5%E5%AF%BC%E5%85%A5%E8%BF%9B%E5%8E%BB%EF%BC%8C%E5%AF%BC%E5%85%A5%E4%B9%8B%E5%89%8D%E5%8F%AF%E4%BB%A5%E5%85%88%E7%BB%99%E6%96%87%E4%BB%B6%E6%94%B9%E4%B8%AA%E5%90%8D%E6%96%B9%E4%BE%BF%E8%BE%A8%E8%AE%A4\" >\u2463\u6253\u5f00xshell\u7aef\u5de5\u5177\u2192\u7528\u6237\u5bc6\u94a5\u7ba1\u7406\u8005\u2192\u628a\u670d\u52a1\u5668\u521a\u751f\u6210\u597d\u7684id_rsa\u5bc6\u94a5\u5bfc\u5165\u8fdb\u53bb\uff0c\u5bfc\u5165\u4e4b\u524d\u53ef\u4ee5\u5148\u7ed9\u6587\u4ef6\u6539\u4e2a\u540d\u65b9\u4fbf\u8fa8\u8ba4<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/linuxjk.cn\/?p=1211\/#%E5%AE%A2%E6%88%B7%E7%AB%AF%E8%BF%9E%E6%8E%A5%E6%9C%8D%E5%8A%A1%E7%AB%AF%EF%BC%88%E4%B8%A4%E5%8F%B0%E6%9C%8D%E5%8A%A1%E5%99%A8%EF%BC%89\" >\u5ba2\u6237\u7aef\u8fde\u63a5\u670d\u52a1\u7aef\uff08\u4e24\u53f0\u670d\u52a1\u5668\uff09<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/linuxjk.cn\/?p=1211\/#%E5%AE%A2%E6%88%B7%E7%AB%AF%E8%BF%9C%E7%A8%8B%E8%BF%9E%E6%8E%A5%E6%9C%8D%E5%8A%A1%E7%AB%AF%E5%AF%86%E9%92%A5%E9%85%8D%E7%BD%AE\" >\u5ba2\u6237\u7aef\u8fdc\u7a0b\u8fde\u63a5\u670d\u52a1\u7aef\u5bc6\u94a5\u914d\u7f6e<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/linuxjk.cn\/?p=1211\/#1_%E5%B0%86%E5%AE%A2%E6%88%B7%E7%AB%AFpub%E5%85%AC%E9%92%A5%E4%B8%8A%E4%BC%A0%E8%87%B3%E6%9C%8D%E5%8A%A1%E7%AB%AF\" >1. \u5c06\u5ba2\u6237\u7aef.pub\u516c\u94a5\u4e0a\u4f20\u81f3\u670d\u52a1\u7aef<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/linuxjk.cn\/?p=1211\/#2_%E9%85%8D%E7%BD%AE%E5%AE%A2%E6%88%B7%E7%AB%AF%E5%BF%AB%E6%8D%B7%E8%BF%9E%E6%8E%A5%E5%8F%AF%E4%BB%A5%E6%9B%B4%E5%A5%BD%E7%9A%84%E5%8C%BA%E5%88%86%E4%BD%BF%E7%94%A8%E5%93%AA%E4%B8%AA%E7%A7%81%E9%92%A5%E6%96%87%E4%BB%B6%E8%BF%9E%E6%8E%A5%E4%B8%8D%E5%90%8C%E7%9A%84%E6%9C%8D%E5%8A%A1%E7%AB%AF\" >2. \u914d\u7f6e\u5ba2\u6237\u7aef\u5feb\u6377\u8fde\u63a5(\u53ef\u4ee5\u66f4\u597d\u7684\u533a\u5206\u4f7f\u7528\u54ea\u4e2a\u79c1\u94a5\u6587\u4ef6\u8fde\u63a5\u4e0d\u540c\u7684\u670d\u52a1\u7aef)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/linuxjk.cn\/?p=1211\/#3_%E9%AA%8C%E8%AF%81%E8%BF%9E%E6%8E%A5\" >3. \u9a8c\u8bc1\u8fde\u63a5<\/a><\/li><\/ul><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-16\" href=\"https:\/\/linuxjk.cn\/?p=1211\/#%E5%8F%8C%E6%9C%BA%E4%BA%92%E4%BF%A1%E9%85%8D%E7%BD%AE%EF%BC%88Server_A_%E2%86%94_Server_B%EF%BC%89\" >\u53cc\u673a\u4e92\u4fe1\u914d\u7f6e\uff08Server A \u2194 Server B\uff09<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-17\" href=\"https:\/\/linuxjk.cn\/?p=1211\/#1_%E5%9C%A8_Server_A_%E7%94%9F%E6%88%90%E5%AF%86%E9%92%A5\" >1. \u5728 Server A \u751f\u6210\u5bc6\u94a5<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-18\" href=\"https:\/\/linuxjk.cn\/?p=1211\/#2_%E5%B0%86_Server_A_%E5%85%AC%E9%92%A5%E9%83%A8%E7%BD%B2%E5%88%B0_Server_B\" >2. \u5c06 Server A \u516c\u94a5\u90e8\u7f72\u5230 Server B<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-19\" href=\"https:\/\/linuxjk.cn\/?p=1211\/#3_%E5%9C%A8_Server_B_%E7%94%9F%E6%88%90%E5%AF%86%E9%92%A5\" >3. \u5728 Server B \u751f\u6210\u5bc6\u94a5<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-20\" href=\"https:\/\/linuxjk.cn\/?p=1211\/#4_%E5%B0%86_Server_B_%E5%85%AC%E9%92%A5%E9%83%A8%E7%BD%B2%E5%88%B0_Server_A\" >4. \u5c06 Server B \u516c\u94a5\u90e8\u7f72\u5230 Server A<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-21\" href=\"https:\/\/linuxjk.cn\/?p=1211\/#5Server_A_%E9%85%8D%E7%BD%AEsshconfig\" >5.Server A \u914d\u7f6e.ssh\/config<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-22\" href=\"https:\/\/linuxjk.cn\/?p=1211\/#6Server_B_%E9%85%8D%E7%BD%AEsshconfig\" >6.Server B \u914d\u7f6e.ssh\/config<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-23\" href=\"https:\/\/linuxjk.cn\/?p=1211\/#5_%E9%AA%8C%E8%AF%81%E5%8F%8C%E5%90%91%E5%85%8D%E5%AF%86%E7%99%BB%E5%BD%95\" >5. \u9a8c\u8bc1\u53cc\u5411\u514d\u5bc6\u767b\u5f55<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-24\" href=\"https:\/\/linuxjk.cn\/?p=1211\/#%E5%85%B3%E9%94%AE%E5%AE%89%E5%85%A8%E6%B3%A8%E6%84%8F%E4%BA%8B%E9%A1%B9\" >\u5173\u952e\u5b89\u5168\u6ce8\u610f\u4e8b\u9879<\/a><\/li><\/ul><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h1><span class=\"ez-toc-section\" id=\"%E7%AC%AC0%E6%AD%A5%E2%80%93%E6%A3%80%E6%9F%A5%E6%9D%83%E9%99%90\"><\/span><strong>\u7b2c0\u6b65&#8211;\u68c0\u67e5\u6743\u9650<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h1><p><strong>\u8981\u60f3\u987a\u5229\u4f7f\u7528\u5bc6\u94a5\u767b\u5f55\u670d\u52a1\u5668\uff0c\u9996\u5148\u68c0\u67e5\u88ab\u767b\u5f55\u670d\u52a1\u5668\u7684.ssh\u6587\u4ef6\u5939\u6743\u9650<\/strong><\/p><p>SSH\u8981\u6c42\u4e25\u683c\u6743\u9650\u8bbe\u7f6e\uff1a<\/p><ul><li><code>\/root\/.ssh<\/code>\u00a0\u76ee\u5f55\u6743\u9650\u5fc5\u987b\u4e3a\u00a0<strong>700<\/strong>\uff08<code>drwx------<\/code>\uff09<\/li><li><code>authorized_keys<\/code>\u00a0\u6587\u4ef6\u6743\u9650\u5fc5\u987b\u4e3a\u00a0<strong>600<\/strong>\uff08<code>-rw-------<\/code>\uff09<br \/><strong>\u82e5\u6743\u9650\u8fc7\u677e\uff08\u5982\u5176\u4ed6\u7528\u6237\u53ef\u5199\uff09<\/strong>\uff0cSSH\u4f1a\u4e3b\u52a8\u62d2\u7edd\u5bc6\u94a5\u8ba4\u8bc1\u3002<\/li><\/ul>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-9a9118c elementor-widget elementor-widget-heading\" data-id=\"9a9118c\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\"><span class=\"ez-toc-section\" id=\"xshell%E7%AD%89%E5%AE%A2%E6%88%B7%E7%AB%AF%E5%B7%A5%E5%85%B7%E8%BF%9E%E6%8E%A5%E6%9C%8D%E5%8A%A1%E5%99%A8\"><\/span>xshell\u7b49\u5ba2\u6237\u7aef\u5de5\u5177\u8fde\u63a5\u670d\u52a1\u5668<span class=\"ez-toc-section-end\"><\/span><\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-cea0cbe elementor-widget elementor-widget-text-editor\" data-id=\"cea0cbe\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>\u00a0 \u00a0 \u8fd9\u79cd\u6bd4\u8f83\u7b80\u5355\uff0c\u53ea\u9700\u8981\u5148\u914d\u7f6esshd_config\u7684\u8fd9\u4e24\u4e2a\u53c2\u6570\uff0c1.\u628a\u5bc6\u94a5\u767b\u5f55\u6253\u5f002.\u8bbe\u7f6e\u5b58\u653e\u5bc6\u94a5\u7684\u6587\u4ef6\u4f4d\u7f6e\uff1a<\/p><p>PubkeyAuthentication yes<\/p><p>AuthorizedKeysFile .ssh\/authorized_keys<\/p><p>\u628a\u5728\u670d\u52a1\u5668\u4e0a\u751f\u6210\u597d\u7684.pub\u516c\u94a5\u6587\u4ef6\u5185\u5bb9\u8ffd\u52a0\u5230\/root\/.ssh\u6587\u4ef6\u5939\u4e2d\u7684authorized_keys\u6587\u4ef6\u4e2d\uff0c\u79c1\u94a5\u6587\u4ef6\uff08\u4e0d\u5e26.pub\uff09\u4f20\u5230\u7535\u8111\u4e0a\u5c31\u53ef\u4ee5\u4f7f\u7528\u5ba2\u6237\u7aef\u914d\u7f6e\u8fde\u63a5\u4e86\uff0c\u4ee5xshell\u4e3a\u4f8b<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-4d26b77 elementor-widget elementor-widget-text-editor\" data-id=\"4d26b77\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<h3><span class=\"ez-toc-section\" id=\"%E2%91%A0%E9%A6%96%E5%85%88%E5%9C%A8%E6%9C%8D%E5%8A%A1%E5%99%A8%E4%B8%8A%E4%BD%BF%E7%94%A8ssh_-keygen%E7%94%9F%E6%88%90%E7%A7%98%E9%92%A5\"><\/span><strong>\u2460\u9996\u5148\u5728\u670d\u52a1\u5668\u4e0a\u4f7f\u7528ssh -keygen\u751f\u6210\u79d8\u94a5<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3><h4><span class=\"ez-toc-section\" id=\"SSH_%E5%AF%86%E9%92%A5%E5%AF%B9%E7%9A%84%E5%88%9B%E5%BB%BA%E6%96%B9%E6%B3%95\"><\/span><strong>SSH \u5bc6\u94a5\u5bf9\u7684\u521b\u5efa\u65b9\u6cd5<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h4><h5><span class=\"ez-toc-section\" id=\"1_%E9%BB%98%E8%AE%A4%E7%94%9F%E6%88%90_RSA_%E5%AF%86%E9%92%A5%E2%80%93ssh-keygen\"><\/span><strong>1. \u9ed8\u8ba4\u751f\u6210 RSA \u5bc6\u94a5&#8211;ssh-keygen<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h5><div class=\"md-code-block\"><pre><strong>ssh-keygen <span class=\"token parameter variable\">-t<\/span> rsa <span class=\"token parameter variable\">-b<\/span> <span class=\"token number\">4096<\/span> <span class=\"token parameter variable\">-C<\/span> <span class=\"token string\">\"your_comment\"<\/span>\n<span class=\"token comment\"># \u6309\u63d0\u793a\u9009\u62e9\u4fdd\u5b58\u8def\u5f84\uff08\u9ed8\u8ba4 ~\/.ssh\/id_rsa\uff09<\/span>\n<span class=\"token comment\"># \u8f93\u5165\u5bc6\u94a5\u5bc6\u7801\uff08\u53ef\u9009\uff0c\u76f4\u63a5\u56de\u8f66\u8df3\u8fc7\uff09<br \/>#-t\u9009\u62e9\u7c7b\u578b -b \u8bbe\u7f6e\u5bc6\u94a5\u957f\u5ea6  -C <span class=\"hljs-string\">\"\u6ce8\u91ca\u6587\u5b57\"  <br \/><\/span><\/span><\/strong><\/pre><\/div><h4><span class=\"ez-toc-section\" id=\"2_%E7%94%9F%E6%88%90_ED25519_%E5%AF%86%E9%92%A5%EF%BC%88%E6%9B%B4%E5%AE%89%E5%85%A8%EF%BC%89\"><\/span><strong>2. \u751f\u6210 ED25519 \u5bc6\u94a5\uff08\u66f4\u5b89\u5168\uff09<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h4><div class=\"md-code-block\"><pre><strong>ssh-keygen <span class=\"token parameter variable\">-t<\/span> ed25519 <span class=\"token parameter variable\">-a<\/span> <span class=\"token number\">100<\/span> <span class=\"token parameter variable\">-C<\/span> <span class=\"token string\">\"your_comment\"<\/span><\/strong><\/pre><\/div><h5><span class=\"ez-toc-section\" id=\"3_%E7%94%9F%E6%88%90_ECDSA_%E5%AF%86%E9%92%A5\"><\/span><strong>3. \u751f\u6210 ECDSA \u5bc6\u94a5<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h5><div class=\"md-code-block\"><pre><strong>ssh-keygen <span class=\"token parameter variable\">-t<\/span> ecdsa <span class=\"token parameter variable\">-b<\/span> <span class=\"token number\">521<\/span> <span class=\"token parameter variable\">-C<\/span> <span class=\"token string\">\"your_comment\"<\/span><\/strong><\/pre><h3><span class=\"ez-toc-section\" id=\"%E2%91%A1%E6%9C%8D%E5%8A%A1%E5%99%A8%E7%AB%AF%E8%BF%9B%E5%85%A5ssh%E7%9B%AE%E5%BD%95%E6%89%A7%E8%A1%8C\"><\/span><strong>\u2461\u670d\u52a1\u5668\u7aef\u8fdb\u5165.ssh\u76ee\u5f55\u6267\u884c<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3><pre><strong>cat id_rsa.pub &gt;&gt; authorized_keys<\/strong><\/pre><h3><span class=\"ez-toc-section\" id=\"%E2%91%A2%E5%88%A9%E7%94%A8%E5%90%84%E7%A7%8D%E6%96%B9%E5%BC%8F%E6%8A%8A%E7%A7%81%E9%92%A5id_rsa%E4%BC%A0%E8%BE%93%E5%88%B0%E7%94%B5%E8%84%91%E4%B8%AD\"><\/span><strong>\u2462\u5229\u7528\u5404\u79cd\u65b9\u5f0f\u628a\u79c1\u94a5id_rsa\u4f20\u8f93\u5230\u7535\u8111\u4e2d<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3><p><strong>\u4e2a\u4eba\u63a8\u8350\u5728\u670d\u52a1\u5668\u4e0a\u5b89\u88c5lrzsz\uff0c\u7528xshell\u5bc6\u7801\u8fde\u63a5\u670d\u52a1\u5668\uff0c\u4f7f\u7528sz\u547d\u4ee4\u4f20\u8f93\uff0c\u683c\u5f0f sz + \u6587\u4ef6\u540d\uff08\u89c1\u4e0b\u56fe\uff09<img fetchpriority=\"high\" decoding=\"async\" class=\"alignnone size-full wp-image-1218\" src=\"https:\/\/linuxjk.cn\/wp-content\/uploads\/2025\/04\/lrzsz\u4f20\u8f93.png\" alt=\"\" width=\"1277\" height=\"424\" srcset=\"https:\/\/linuxjk.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2025\/04\/lrzsz\u4f20\u8f93.png 1277w, https:\/\/linuxjk.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2025\/04\/lrzsz\u4f20\u8f93-300x100.png 300w, https:\/\/linuxjk.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2025\/04\/lrzsz\u4f20\u8f93-1024x340.png 1024w, https:\/\/linuxjk.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2025\/04\/lrzsz\u4f20\u8f93-768x255.png 768w\" sizes=\"(max-width: 1277px) 100vw, 1277px\" \/><\/strong><\/p><h3><span class=\"ez-toc-section\" id=\"%E2%91%A3%E6%89%93%E5%BC%80xshell%E7%AB%AF%E5%B7%A5%E5%85%B7%E2%86%92%E7%94%A8%E6%88%B7%E5%AF%86%E9%92%A5%E7%AE%A1%E7%90%86%E8%80%85%E2%86%92%E6%8A%8A%E6%9C%8D%E5%8A%A1%E5%99%A8%E5%88%9A%E7%94%9F%E6%88%90%E5%A5%BD%E7%9A%84id_rsa%E5%AF%86%E9%92%A5%E5%AF%BC%E5%85%A5%E8%BF%9B%E5%8E%BB%EF%BC%8C%E5%AF%BC%E5%85%A5%E4%B9%8B%E5%89%8D%E5%8F%AF%E4%BB%A5%E5%85%88%E7%BB%99%E6%96%87%E4%BB%B6%E6%94%B9%E4%B8%AA%E5%90%8D%E6%96%B9%E4%BE%BF%E8%BE%A8%E8%AE%A4\"><\/span><strong>\u2463\u6253\u5f00xshell\u7aef\u5de5\u5177\u2192\u7528\u6237\u5bc6\u94a5\u7ba1\u7406\u8005\u2192\u628a\u670d\u52a1\u5668\u521a\u751f\u6210\u597d\u7684id_rsa\u5bc6\u94a5\u5bfc\u5165\u8fdb\u53bb\uff0c\u5bfc\u5165\u4e4b\u524d\u53ef\u4ee5\u5148\u7ed9\u6587\u4ef6\u6539\u4e2a\u540d\u65b9\u4fbf\u8fa8\u8ba4<img decoding=\"async\" class=\"alignnone size-full wp-image-1217\" src=\"https:\/\/linuxjk.cn\/wp-content\/uploads\/2025\/04\/xshell\u5bc6\u94a5.png\" alt=\"\" width=\"918\" height=\"380\" srcset=\"https:\/\/linuxjk.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2025\/04\/xshell\u5bc6\u94a5.png 918w, https:\/\/linuxjk.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2025\/04\/xshell\u5bc6\u94a5-300x124.png 300w, https:\/\/linuxjk.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2025\/04\/xshell\u5bc6\u94a5-768x318.png 768w\" sizes=\"(max-width: 918px) 100vw, 918px\" \/><\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3><p><strong>\u5728\u8fd9\u91cc\u70b9\u51fb\u8bbe\u7f6e\u8fdb\u53bb\u5c31\u53ef\u4ee5\u9009\u62e9\u521a\u624d\u5bfc\u5165\u7684id_rsa\u914d\u7f6e\u5bc6\u94a5\u8fde\u63a5<img decoding=\"async\" class=\"alignnone size-full wp-image-1219\" src=\"https:\/\/linuxjk.cn\/wp-content\/uploads\/2025\/04\/xshell\u8fde\u63a5\u914d\u7f6e.png\" alt=\"\" width=\"1203\" height=\"610\" srcset=\"https:\/\/linuxjk.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2025\/04\/xshell\u8fde\u63a5\u914d\u7f6e.png 1203w, https:\/\/linuxjk.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2025\/04\/xshell\u8fde\u63a5\u914d\u7f6e-300x152.png 300w, https:\/\/linuxjk.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2025\/04\/xshell\u8fde\u63a5\u914d\u7f6e-1024x519.png 1024w, https:\/\/linuxjk.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2025\/04\/xshell\u8fde\u63a5\u914d\u7f6e-768x389.png 768w\" sizes=\"(max-width: 1203px) 100vw, 1203px\" \/><\/strong><\/p><\/div>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-76c6fa3 elementor-widget elementor-widget-heading\" data-id=\"76c6fa3\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\"><span class=\"ez-toc-section\" id=\"%E5%AE%A2%E6%88%B7%E7%AB%AF%E8%BF%9E%E6%8E%A5%E6%9C%8D%E5%8A%A1%E7%AB%AF%EF%BC%88%E4%B8%A4%E5%8F%B0%E6%9C%8D%E5%8A%A1%E5%99%A8%EF%BC%89\"><\/span>\u5ba2\u6237\u7aef\u8fde\u63a5\u670d\u52a1\u7aef\uff08\u4e24\u53f0\u670d\u52a1\u5668\uff09<span class=\"ez-toc-section-end\"><\/span><\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-d014a60 elementor-widget elementor-widget-text-editor\" data-id=\"d014a60\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<h3><span class=\"ez-toc-section\" id=\"%E5%AE%A2%E6%88%B7%E7%AB%AF%E8%BF%9C%E7%A8%8B%E8%BF%9E%E6%8E%A5%E6%9C%8D%E5%8A%A1%E7%AB%AF%E5%AF%86%E9%92%A5%E9%85%8D%E7%BD%AE\"><\/span>\u5ba2\u6237\u7aef\u8fdc\u7a0b\u8fde\u63a5\u670d\u52a1\u7aef\u5bc6\u94a5\u914d\u7f6e<span class=\"ez-toc-section-end\"><\/span><\/h3><h4><span class=\"ez-toc-section\" id=\"1_%E5%B0%86%E5%AE%A2%E6%88%B7%E7%AB%AFpub%E5%85%AC%E9%92%A5%E4%B8%8A%E4%BC%A0%E8%87%B3%E6%9C%8D%E5%8A%A1%E7%AB%AF\"><\/span>1. \u5c06\u5ba2\u6237\u7aef.pub\u516c\u94a5\u4e0a\u4f20\u81f3\u670d\u52a1\u7aef<span class=\"ez-toc-section-end\"><\/span><\/h4><div class=\"md-code-block\"><pre><span class=\"token comment\"># \u65b9\u6cd5\u4e00\uff1a\u4f7f\u7528 ssh-copy-id\uff08\u63a8\u8350\uff09<\/span>\nssh-copy-id <span class=\"token parameter variable\">-i<\/span> ~\/.ssh\/id_rsa.pub user@remote_server <span class=\"token parameter variable\">-p<\/span> <span class=\"token number\">22<\/span>\n\n<span class=\"token comment\"># \u65b9\u6cd5\u4e8c\uff1a\u624b\u52a8\u8ffd\u52a0\u516c\u94a5<\/span>\n<span class=\"token function\">cat<\/span> ~\/.ssh\/id_rsa.pub <span class=\"token operator\">|<\/span> <span class=\"token function\">ssh<\/span> user@remote_server <span class=\"token string\">\"mkdir -p ~\/.ssh &amp;&amp; chmod 700 ~\/.ssh &amp;&amp; cat &gt;&gt; ~\/.ssh\/authorized_keys &amp;&amp; chmod 600 ~\/.ssh\/authorized_keys\"<\/span><\/pre><\/div><h4><span class=\"ez-toc-section\" id=\"2_%E9%85%8D%E7%BD%AE%E5%AE%A2%E6%88%B7%E7%AB%AF%E5%BF%AB%E6%8D%B7%E8%BF%9E%E6%8E%A5%E5%8F%AF%E4%BB%A5%E6%9B%B4%E5%A5%BD%E7%9A%84%E5%8C%BA%E5%88%86%E4%BD%BF%E7%94%A8%E5%93%AA%E4%B8%AA%E7%A7%81%E9%92%A5%E6%96%87%E4%BB%B6%E8%BF%9E%E6%8E%A5%E4%B8%8D%E5%90%8C%E7%9A%84%E6%9C%8D%E5%8A%A1%E7%AB%AF\"><\/span>2. \u914d\u7f6e\u5ba2\u6237\u7aef\u5feb\u6377\u8fde\u63a5(\u53ef\u4ee5\u66f4\u597d\u7684\u533a\u5206\u4f7f\u7528\u54ea\u4e2a\u79c1\u94a5\u6587\u4ef6\u8fde\u63a5\u4e0d\u540c\u7684\u670d\u52a1\u7aef)<span class=\"ez-toc-section-end\"><\/span><\/h4><p>\u7f16\u8f91\u00a0<code>~\/.ssh\/config<\/code> \u6587\u4ef6\uff1a<\/p><div class=\"md-code-block\"><pre>Host \u4e3b\u673a\u540d\uff08\u63d0\u524d\u914d\u7f6e\/etc\/hosts\uff09\n    HostName <span class=\"token number\">192.168<\/span>.1.100  \u670d\u52a1\u7aefip\/\u57df\u540d\n    User root\n    Port <span class=\"token number\">22<\/span>\n    IdentityFile ~\/.ssh\/id_rsa\n    IdentitiesOnly <span class=\"token function\">yes#\u786e\u4fddSSH\u53ea\u4f7f\u7528\u547d\u4ee4\u884c\u6216\u914d\u7f6e\u6587\u4ef6\u4e2d\u6307\u5b9a\u7684\u5bc6\u94a5\uff0c<br \/>\u4e0d\u4f1a\u81ea\u52a8\u5c1d\u8bd5\u5176\u4ed6\u53ef\u7528\u5bc6\u94a5\uff0c\u8fd9\u5728\u591a\u5bc6\u94a5\u73af\u5883\u4e0b\u5f88\u6709\u7528\uff0c\u907f\u514d\u8ba4\u8bc1\u9519\u8bef\u3002<\/span><\/pre><\/div><h4><span class=\"ez-toc-section\" id=\"3_%E9%AA%8C%E8%AF%81%E8%BF%9E%E6%8E%A5\"><\/span>3. \u9a8c\u8bc1\u8fde\u63a5<span class=\"ez-toc-section-end\"><\/span><\/h4><div class=\"md-code-block\"><pre><span class=\"token function\">ssh<\/span> myserver\uff08\u670d\u52a1\u7aef\uff09  <span class=\"token comment\"># \u65e0\u9700\u8f93\u5165\u5bc6\u7801\u5373\u8868\u793a\u6210\u529f<\/span><\/pre><\/div>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-7c37be4 elementor-widget elementor-widget-heading\" data-id=\"7c37be4\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\"><span class=\"ez-toc-section\" id=\"%E5%8F%8C%E6%9C%BA%E4%BA%92%E4%BF%A1%E9%85%8D%E7%BD%AE%EF%BC%88Server_A_%E2%86%94_Server_B%EF%BC%89\"><\/span>\u53cc\u673a\u4e92\u4fe1\u914d\u7f6e\uff08Server A \u2194 Server B\uff09<span class=\"ez-toc-section-end\"><\/span><\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-2332e14 elementor-widget elementor-widget-text-editor\" data-id=\"2332e14\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<h4><span class=\"ez-toc-section\" id=\"1_%E5%9C%A8_Server_A_%E7%94%9F%E6%88%90%E5%AF%86%E9%92%A5\"><\/span><strong>1. \u5728 Server A \u751f\u6210\u5bc6\u94a5<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h4><div class=\"md-code-block\"><pre><strong>ssh-keygen -t ed25519 -f ~\/.ssh\/server_a -C \"\u6ce8\u91ca\"<\/strong><\/pre><\/div><h4><span class=\"ez-toc-section\" id=\"2_%E5%B0%86_Server_A_%E5%85%AC%E9%92%A5%E9%83%A8%E7%BD%B2%E5%88%B0_Server_B\"><\/span><strong>2. \u5c06 Server A \u516c\u94a5\u90e8\u7f72\u5230 Server B<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h4><div class=\"md-code-block\"><pre><strong>ssh-copy-id -i ~\/.ssh\/server_a.pub user@server_b<\/strong><\/pre><\/div><h4><span class=\"ez-toc-section\" id=\"3_%E5%9C%A8_Server_B_%E7%94%9F%E6%88%90%E5%AF%86%E9%92%A5\"><\/span><strong>3. \u5728 Server B \u751f\u6210\u5bc6\u94a5<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h4><div class=\"md-code-block\"><pre><strong>ssh-keygen -t ed25519 -f ~\/.ssh\/server_b -C \"\u6ce8\u91ca\"<\/strong><\/pre><\/div><h4><span class=\"ez-toc-section\" id=\"4_%E5%B0%86_Server_B_%E5%85%AC%E9%92%A5%E9%83%A8%E7%BD%B2%E5%88%B0_Server_A\"><\/span><strong>4. \u5c06 Server B \u516c\u94a5\u90e8\u7f72\u5230 Server A<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h4><div class=\"md-code-block\"><pre><strong>ssh-copy-id -i ~\/.ssh\/server_b.pub user@server_a<\/strong><\/pre><\/div><h4><span class=\"ez-toc-section\" id=\"5Server_A_%E9%85%8D%E7%BD%AEsshconfig\"><\/span><strong>5.Server A \u914d\u7f6e.ssh\/config<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h4><pre><strong>HOST server_b<\/strong><br \/><strong>HostName ip_serverb<\/strong><br \/><strong>User root<\/strong><br \/><strong>IdentityFile \/root\/.ssh\/server_a_rsa<\/strong><\/pre><h4><span class=\"ez-toc-section\" id=\"6Server_B_%E9%85%8D%E7%BD%AEsshconfig\"><\/span><strong>6.Server B \u914d\u7f6e.ssh\/config<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h4><pre><strong>HOST server_a<\/strong><br \/><strong>HostName ip_server_a<\/strong><br \/><strong>User root<\/strong><br \/><strong>IdentityFile \/root\/.ssh\/server_b_rsa<\/strong><\/pre><h4><span class=\"ez-toc-section\" id=\"5_%E9%AA%8C%E8%AF%81%E5%8F%8C%E5%90%91%E5%85%8D%E5%AF%86%E7%99%BB%E5%BD%95\"><\/span><strong>5. \u9a8c\u8bc1\u53cc\u5411\u514d\u5bc6\u767b\u5f55<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h4><div class=\"md-code-block\"><pre><strong><span class=\"token comment\"># \u4ece A \u8fde\u63a5 B<\/span>\n<span class=\"token function\">ssh<\/span> user@server_b\n\n<span class=\"token comment\"># \u4ece B \u8fde\u63a5 A<\/span>\n<span class=\"token function\">ssh<\/span> user@server_a<\/strong><\/pre><\/div>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-33fd246 elementor-widget elementor-widget-text-editor\" data-id=\"33fd246\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<h3><span class=\"ez-toc-section\" id=\"%E5%85%B3%E9%94%AE%E5%AE%89%E5%85%A8%E6%B3%A8%E6%84%8F%E4%BA%8B%E9%A1%B9\"><\/span>\u5173\u952e\u5b89\u5168\u6ce8\u610f\u4e8b\u9879<span class=\"ez-toc-section-end\"><\/span><\/h3><ol start=\"1\"><li><p><strong>\u6587\u4ef6\u6743\u9650\u8981\u6c42<\/strong>\uff1a<\/p><ul><li><p><code>~\/.ssh<\/code>\u00a0\u76ee\u5f55\u6743\u9650\u5fc5\u987b\u4e3a\u00a0<code>700<\/code><\/p><\/li><li><p><code>authorized_keys<\/code>\u00a0\u6587\u4ef6\u6743\u9650\u5fc5\u987b\u4e3a\u00a0<code>600<\/code><\/p><\/li><li><p>\u79c1\u94a5\u6587\u4ef6\u6743\u9650\u5fc5\u987b\u4e3a\u00a0<code>600<\/code><\/p><\/li><\/ul><\/li><li><p><strong>\u670d\u52a1\u7aef\u914d\u7f6e\u68c0\u67e5<\/strong>\uff1a<\/p><div class=\"md-code-block\"><div class=\"md-code-block-banner-wrap\">\u00a0<\/div><pre><span class=\"token comment\"># \u786e\u4fdd\u4ee5\u4e0b\u914d\u7f6e\u5728 \/etc\/ssh\/sshd_config \u4e2d<\/span>\nPubkeyAuthentication <span class=\"token function\">yes<\/span>\nAuthorizedKeysFile .ssh\/authorized_keys\nPasswordAuthentication no  <span class=\"token comment\"># \u5efa\u8bae\u7981\u7528\u5bc6\u7801\u8ba4\u8bc1<\/span>\n\nsystemctl restart sshd<\/pre><\/div><p>\u8fde\u63a5\u5931\u8d25\u65f6\u6dfb\u52a0\u00a0<code>-v<\/code>\u00a0\u53c2\u6570\u67e5\u770b\u8be6\u7ec6\u65e5\u5fd7\uff1a<\/p><div class=\"md-code-block\"><div class=\"md-code-block-banner-wrap\"><div class=\"md-code-block-banner\">\u00a0<\/div><\/div><pre><span class=\"token function\">ssh<\/span> <span class=\"token parameter variable\">-v<\/span> user@remote_server<\/pre><\/div><\/li><\/ol>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t<div class=\"elementor-element elementor-element-339e1fb e-flex e-con-boxed e-con e-parent\" data-id=\"339e1fb\" data-element_type=\"container\" data-e-type=\"container\">\n\t\t\t\t\t<div class=\"e-con-inner\">\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>\u00a0 \u00a0 \u7528ssh\u79d8\u94a5\u8fde\u63a5\u975e\u5e38\u65b9\u4fbf\uff0c\u4e00\u65b9\u9762\u53ef\u4ee5\u8bbe\u7f6e\u53c2\u6570\u63d0\u9ad8\u7cfb\u7edf\u5b89\u5168\u6027\uff08PermitRootLogin prohi [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[1],"tags":[15],"class_list":["post-1211","post","type-post","status-publish","format-standard","hentry","category-vxhs888p","tag-check_error"],"_links":{"self":[{"href":"https:\/\/linuxjk.cn\/index.php?rest_route=\/wp\/v2\/posts\/1211","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxjk.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxjk.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxjk.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxjk.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1211"}],"version-history":[{"count":10,"href":"https:\/\/linuxjk.cn\/index.php?rest_route=\/wp\/v2\/posts\/1211\/revisions"}],"predecessor-version":[{"id":1228,"href":"https:\/\/linuxjk.cn\/index.php?rest_route=\/wp\/v2\/posts\/1211\/revisions\/1228"}],"wp:attachment":[{"href":"https:\/\/linuxjk.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1211"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxjk.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1211"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxjk.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1211"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}