{"id":8629,"date":"2025-04-18T16:52:28","date_gmt":"2025-04-18T08:52:28","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/8629.html"},"modified":"2025-04-18T16:52:28","modified_gmt":"2025-04-18T08:52:28","slug":"vs-code-%e8%bf%9c%e7%a8%8b%e8%bf%9e%e6%8e%a5-ssh-%e6%9c%8d%e5%8a%a1%e5%99%a8","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/8629.html","title":{"rendered":"VS Code \u8fdc\u7a0b\u8fde\u63a5 SSH \u670d\u52a1\u5668"},"content":{"rendered":"<\/p>\n<h4>\u6587\u7ae0\u76ee\u5f55<\/h4>\n<ul>\n<li>\u4e00\u3001\u5b89\u88c5 Remote &#8211; SSH \u6269\u5c55\u5e76\u8fde\u63a5\u8fdc\u7a0b\u4e3b\u673a<\/li>\n<li>\u4e8c\u3001\u514d\u5bc6\u8fde\u63a5\u8fdc\u7a0b\u4e3b\u673a<\/li>\n<li>\n<ul>\n<li>1. \u751f\u6210 SSH \u5bc6\u94a5\u5bf9<\/li>\n<li>2. \u5c06\u516c\u94a5\u590d\u5236\u5230\u8fdc\u7a0b\u670d\u52a1\u5668<\/li>\n<li>3. \u914d\u7f6e SSH \u5ba2\u670d\u7aef<\/li>\n<li>4. \u8fde\u63a5\u6d4b\u8bd5<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u968f\u7740\u6280\u672f\u7684\u4e0d\u65ad\u8fed\u4ee3\u66f4\u65b0&#xff0c;\u5728 Linux \u7cfb\u7edf\u4e2d\u4f7f\u7528 Vim\u3001nano \u7b49\u57fa\u4e8e Shell \u7ec8\u7aef\u7684\u7f16\u8f91\u5668&#xff08;\u6211\u66fe\u7ecf\u4e5f\u662f\u4e2a vimer&#xff0c;\u4f46\u662f VS Code \u5b9e\u5728\u592a\u9999\u4e86&#xff09;&#xff0c;\u5df2\u7ecf\u5f88\u96be\u9002\u5e94\u5f53\u4e0b\u7684\u5f00\u53d1\u6548\u7387\u3002\u56e0\u6b64\u5927\u591a\u6570\u5f00\u53d1\u8005\u5f00\u59cb\u4f7f\u7528 VS Code \u8fdc\u7a0b\u8fde\u63a5 Linux \u7cfb\u7edf\u6765\u89e3\u51b3\u7f16\u7a0b\u6548\u7387\u7684\u95ee\u9898&#xff0c;VS Code \u672c\u8eab\u4e5f\u662f\u4e2a\u4f18\u79c0\u7684\u4ee3\u7801\u7f16\u8f91\u5668&#xff0c;\u53ef\u4ee5\u5b89\u88c5\u5f88\u591a\u63d2\u4ef6\u6765\u6269\u5c55\u529f\u80fd&#xff0c;\u5176\u4e2d\u5c31\u6709 SSH \u5de5\u5177&#xff0c;\u8fdc\u7a0b\u8fde\u63a5\u5230 Linux \u7cfb\u7edf&#xff0c;\u53ef\u4ee5\u8bf4\u5c31\u662f\u5728 VS Code \u4e0a\u7f16\u8f91\u4ee3\u7801\u3001\u7f16\u8bd1\u4ee3\u7801\u3001\u8fd0\u884c\u7a0b\u5e8f&#xff0c;\u57fa\u672c\u5c31\u662f\u4e00\u6761\u9f99\u670d\u52a1\u3002<\/p>\n<p>\u672c\u7bc7\u5c06\u4ee5 Windows \u7cfb\u7edf\u4e0b\u7684 VS Code \u4f5c\u4e3a SSH \u5ba2\u670d\u7aef&#xff0c;\u8fde\u63a5\u8fdc\u7a0b\u7684 Ubuntu \u7cfb\u7edf\u3002\u524d\u63d0\u6761\u4ef6\u662f Ubuntu \u4e3b\u673a\u5df2\u5b89\u88c5\u4e86 SSH \u670d\u52a1\u7ec4\u4ef6&#xff0c;\u76f8\u5173\u5185\u5bb9\u53ef\u67e5\u9605\u535a\u5ba2\u300a\u57fa\u4e8e Ubuntu22.04 \u5b89\u88c5 SSH \u670d\u52a1\u300b\u3002<\/p>\n<hr \/>\n<h2>\u4e00\u3001\u5b89\u88c5 Remote &#8211; SSH \u6269\u5c55\u5e76\u8fde\u63a5\u8fdc\u7a0b\u4e3b\u673a<\/h2>\n<p>\u6253\u5f00 VS Code&#xff0c;\u70b9\u51fb\u5de6\u4fa7\u7684\u6269\u5c55\u56fe\u6807&#xff08;\u6216\u4f7f\u7528\u5feb\u6377\u952e Ctrl&#043;Shift&#043;X&#xff09;&#xff0c;\u5728\u641c\u7d22\u6846\u4e2d\u8f93\u5165 \u201cSSH\u201d&#xff0c;\u53ef\u4ee5\u770b\u5230\u5b98\u65b9\u63d0\u4f9b\u7684 \u201cRemote &#8211; SSH\u201d \u6269\u5c55&#xff0c;\u70b9\u51fb \u201cInstall\u201d \u5b89\u88c5\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418085222-680212c69ee08.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u5b89\u88c5\u597d\u63d2\u4ef6\u540e&#xff0c;\u5de6\u8fb9\u7684\u4fa7\u8fb9\u680f\u4e0a\u591a\u4e00\u4e2a\u8fdc\u7a0b\u8fde\u63a5\u7684\u56fe\u6807&#xff0c;\u70b9\u8fdb\u53bb\u4e4b\u540e&#xff0c;\u51fa\u73b0 SSH \u8fde\u63a5\u754c\u9762&#xff0c;\u70b9\u51fb\u5c0f\u52a0\u53f7\u53ef\u4ee5\u8fde\u63a5\u8fdc\u7a0b\u670d\u52a1\u5668\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418085222-680212c6b0bb7.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u70b9\u51fb\u5c0f\u52a0\u53f7\u540e&#xff0c;VS Code \u4e0a\u65b9\u7684\u8f93\u5165\u6846\u4f1a\u4e0b\u5f39\u51fa\u53e6\u4e00\u4e2a\u8f93\u5165\u6846&#xff0c;\u8fd9\u4e2a\u8f93\u5165\u6846\u7528\u4e8e\u8f93\u5165 SSH \u7684\u8fde\u63a5\u547d\u4ee4\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418085222-680212c6c2d36.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u4f7f\u7528 ssh \u547d\u4ee4\u8fde\u63a5\u5230\u8fdc\u7a0b\u670d\u52a1\u5668&#xff0c;\u4ee5\u4e0b\u662f\u547d\u4ee4\u7684\u683c\u5f0f&#xff1a;<\/p>\n<p><span class=\"token function\">ssh<\/span> username&#064;remote_host<br \/>\n<span class=\"token function\">ssh<\/span> <span class=\"token parameter variable\">-p<\/span> port_number username&#064;remote_host<\/p>\n<p>\u7b2c\u4e00\u884c\u662f\u9ed8\u8ba4\u7aef\u53e3\u4e3a 22 \u7684\u8fde\u63a5\u547d\u4ee4&#xff0c;\u7b2c\u4e8c\u884c\u662f\u81ea\u5b9a\u4e49\u7aef\u53e3\u53f7&#xff0c;port_number \u4e3a\u7aef\u53e3\u53f7&#xff0c;username \u4e3a\u7528\u6237\u540d&#xff0c;remote_host \u4e3a IP \u5730\u5740\u3002\u4e0b\u9762\u7684\u4f8b\u5b50\u662f SSH \u8fde\u63a5\u6211\u7684 Ubuntu \u4e3b\u673a\u7684\u547d\u4ee4&#xff08;\u7aef\u53e3\u53f7\u88ab\u6211\u4fee\u6539\u4e3a 2222&#xff09;&#xff1a;<\/p>\n<p><span class=\"token function\">ssh<\/span> <span class=\"token parameter variable\">-p<\/span> <span class=\"token number\">2222<\/span> grayson&#064;192.168.31.90<\/p>\n<p>\u8f93\u5165\u540e\u56de\u8f66\u6267\u884c&#xff0c; \u4f1a\u5f39\u51fa\u9009\u62e9\u66f4\u65b0\u914d\u7f6e\u6587\u4ef6&#xff0c;\u70b9\u51fb\u7b2c\u4e00\u4e2a\u8def\u5f84\u5373\u53ef\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418085223-680212c7401f0.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u7136\u540e\u8f6f\u4ef6\u7684\u53f3\u4e0b\u89d2\u4f1a\u51fa\u73b0\u63d0\u793a\u4fe1\u606f&#xff0c;\u70b9\u51fb \u201cOpen Config\u201d \u6253\u5f00\u914d\u7f6e\u6587\u4ef6\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418085223-680212c753781.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u786e\u8ba4\u914d\u7f6e\u6587\u4ef6\u6ca1\u9519\u7684\u8bdd&#xff0c;\u5c31\u53ef\u4ee5\u4fdd\u5b58\u5173\u95ed\u4e86\u3002\u6211\u8fd9\u91cc\u628a Host \u540e\u9762\u7684\u5185\u5bb9\u6539\u6210\u4e86 Ubuntu&#xff0c;\u539f\u5148\u662f\u663e\u793a IP \u5730\u5740\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418085223-680212c75f7d3.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u7b80\u5355\u7684\u89e3\u91ca\u4e00\u4e0b\u8fd9\u6bb5\u4fe1\u606f&#xff1a;<\/p>\n<ul>\n<li>Host&#xff1a;\u8fd9\u662f\u4e00\u4e2a\u7528\u6237\u5b9a\u4e49\u7684\u522b\u540d&#xff0c;\u7528\u4e8e\u6307\u4ee3\u8fdc\u7a0b\u4e3b\u673a\u3002\u53ef\u4ee5\u5728\u5728\u7ec8\u7aef\u4e2d\u6267\u884c ssh \u52a0\u4e0a\u8fd9\u4e2a\u522b\u540d\u6765\u4ee3\u66ff\u66ff\u4ee3 ssh username&#064;remote_host\u3002<\/li>\n<li>HostName&#xff1a;\u6307\u5b9a\u8fdc\u7a0b\u4e3b\u673a\u7684\u5b9e\u9645\u5730\u5740\u6216\u4e3b\u673a\u540d\u3002<\/li>\n<li>Port&#xff1a;\u6307\u5b9a SSH \u8fde\u63a5\u4f7f\u7528\u7684\u7aef\u53e3\u53f7\u3002<\/li>\n<li>User&#xff1a;\u6307\u5b9a\u8fde\u63a5\u5230\u8fdc\u7a0b\u4e3b\u673a\u65f6\u4f7f\u7528\u7684\u7528\u6237\u540d\u3002<\/li>\n<\/ul>\n<p>\u4e00\u822c\u8fd9\u65f6\u5019\u53ef\u4ee5\u770b\u5230\u5de6\u8fb9\u6811\u72b6\u56fe\u4e2d\u7684 SSH \u5206\u652f\u4e0a&#xff0c;\u4f1a\u591a\u51fa\u4e00\u4e2a Ubuntu&#xff0c;\u5982\u679c\u6ca1\u51fa\u73b0&#xff0c;\u53ef\u4ee5\u70b9\u4e00\u4e0b\u4e0a\u9762\u7684\u5237\u65b0\u6309\u94ae\u3002\u70b9\u51fb Ubuntu \u65c1\u8fb9\u7684\u5c0f\u7a97\u53e3&#xff0c;\u5c31\u53ef\u4ee5\u8fde\u63a5\u5230 Ubuntu \u4e86\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418085223-680212c76d1f7.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u65b0\u5f39\u7a97\u4e2d\u9009\u62e9 \u201cLinux\u201d\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418085223-680212c77b46b.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u7136\u540e\u8f93\u5165\u8fdc\u7a0b\u4e3b\u673a\u7684\u5bc6\u7801\u5e76\u56de\u8f66\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418085224-680212c8b0d1f.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u8fde\u63a5\u6210\u529f\u7684\u8bdd&#xff0c;\u53f3\u4e0b\u89d2\u4f1a\u51fa\u73b0\u5982\u4e0b\u56fe\u6240\u793a\u7684\u5b57\u6837\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418085224-680212c8d1061.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u70b9\u51fb\u65c1\u8fb9\u7684\u5c0f\u4e09\u89d2\u5f62&#xff0c;\u518d\u70b9\u51fb \u201c TERMINAL\u201d&#xff0c;\u53ef\u4ee5\u770b\u5230 Ubuntu \u7684\u7ec8\u7aef\u754c\u9762&#xff0c;\u5728\u8fd9\u91cc\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4\u884c\u64cd\u4f5c Ubuntu\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418085224-680212c8dc566.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h2>\u4e8c\u3001\u514d\u5bc6\u8fde\u63a5\u8fdc\u7a0b\u4e3b\u673a<\/h2>\n<p>\u6bcf\u6b21\u8fde\u63a5\u90fd\u9700\u8981\u8f93\u5165\u5bc6\u7801\u6709\u7a0d\u8bb8\u9ebb\u70e6&#xff0c;\u4e00\u53f0\u673a\u5668\u60f3\u8981\u514d\u5bc6\u8bbf\u95ee\u5176\u4ed6\u673a\u5668&#xff0c;\u9700\u8981\u628a\u81ea\u5df1\u7684\u516c\u94a5\u5185\u5bb9\u53d1\u9001\u5230\u522b\u7684\u673a\u5668\u7684 authorized_keys \u4e2d&#xff0c;\u5e76\u5728\u672c\u673a config \u6587\u4ef6\u4e2d\u914d\u7f6e\u79c1\u94a5\u6587\u4ef6\u4f4d\u7f6e\u3002\u4ee5\u4e0b\u662f\u5b9e\u73b0\u514d\u5bc6\u7801\u8fde\u63a5\u7684\u4e00\u822c\u6b65\u9aa4&#xff1a;<\/p>\n<h3>1. \u751f\u6210 SSH \u5bc6\u94a5\u5bf9<\/h3>\n<p>\u5728\u672c\u5730\u7cfb\u7edf\u4e0a&#xff0c;\u4e5f\u5c31\u662f Windous \u7cfb\u7edf\u751f\u6210 SSH \u5bc6\u94a5\u5bf9\u3002\u6309\u7ec4\u5408\u952e Win &#043; r \u6253\u5f00\u547d\u4ee4\u884c\u8fd0\u884c\u7a97\u53e3&#xff0c;\u8f93\u5165 cmd \u5e76\u56de\u8f66\u6253\u5f00 CMD \u547d\u4ee4\u7a97\u53e3\u3002\u4f7f\u7528 ssh-keygen \u547d\u4ee4\u751f\u6210\u5bc6\u94a5\u5bf9\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b&#xff0c;\u8fd9\u5c06\u5728 ~\/.ssh\/ \u76ee\u5f55\u4e0b&#xff08;~ \u662f\u4e3b\u76ee\u5f55&#xff0c;CMD \u6253\u5f00\u540e\u9ed8\u8ba4\u5c31\u662f\u4e3b\u76ee\u5f55&#xff09;\u751f\u6210\u4e00\u4e2a\u516c\u94a5\u6587\u4ef6&#xff08;id_rsa.pub&#xff09;\u548c\u4e00\u4e2a\u79c1\u94a5\u6587\u4ef6&#xff08;id_rsa&#xff09;\u3002\u5f53\u7136&#xff0c;\u6211\u4eec\u53ef\u4ee5\u9009\u62e9\u5728\u751f\u6210\u5bc6\u94a5\u5bf9\u65f6\u4e3a\u5176\u6307\u5b9a\u4e0d\u540c\u7684\u6587\u4ef6\u540d&#xff0c;\u5982\u4e0b\u547d\u4ee4&#xff0c;-f \u9009\u9879\u540e\u9762\u7684 .\/.ssh\/id_rsa_windows \u5c31\u5305\u542b\u4e86\u8def\u5f84\u4ee5\u53ca\u6700\u540e\u751f\u6210\u7684\u5bc6\u94a5\u5bf9\u540d\u5b57\u3002<\/p>\n<p>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\">&#034;your_email&#064;example.com&#034;<\/span> <span class=\"token parameter variable\">-f<\/span> .\/.ssh\/id_rsa_windows<\/p>\n<p>\u4e0a\u9762\u7684\u547d\u4ee4\u53ea\u6709\u5728 CMD \u88ab\u6253\u5f00\u65f6\u9ed8\u8ba4\u4e3a\u4e3b\u76ee\u5f55\u7684\u65f6\u5019\u624d\u80fd\u4f7f\u7528&#xff0c;\u8981\u4fdd\u9669\u4e00\u4e9b\u7684\u8bdd&#xff0c;\u5efa\u8bae\u7528\u4e0b\u9762\u7684\u547d\u4ee4&#xff1a;<\/p>\n<p>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\">&#034;your_email&#064;example.com&#034;<\/span> <span class=\"token parameter variable\">-f<\/span> C:<span class=\"token punctuation\">\\\\<\/span>Users<span class=\"token punctuation\">\\\\<\/span><span class=\"token operator\">&lt;<\/span>YourUsername<span class=\"token operator\">&gt;<\/span><span class=\"token punctuation\">\\\\<\/span>.ssh<span class=\"token punctuation\">\\\\<\/span>id_rsa_windows<\/p>\n<p>\u5176\u4e2d\u7684 &lt;YourUsername&gt; \u662f Windows \u7684\u7528\u6237\u540d\u3002<\/p>\n<p>\u5982\u4e0b\u56fe\u6240\u793a&#xff0c;\u6211\u8fd9\u91cc\u662f\u8f93\u5165\u4e86\u4e0a\u4e00\u6761\u547d\u4ee4&#xff0c;\u7136\u540e\u8981\u8f93\u5165\u5bc6\u94a5\u5bf9\u7684\u5bc6\u7801&#xff0c;\u6211\u9009\u62e9\u6572\u5165\u4e24\u4e2a\u56de\u8f66\u8df3\u8fc7\u5bc6\u7801\u8bbe\u7f6e&#xff0c;\u6bd5\u7adf\u4e0d\u662f\u505a\u4ec0\u4e48\u4fdd\u5bc6\u9879\u76ee\u3002\u5982\u679c\u5bc6\u94a5\u5bf9\u751f\u6210\u4e86&#xff0c;\u4f1a\u6253\u5370\u51fa\u4e00\u4e2a\u56fe\u6848&#xff0c;\u6b64\u65f6\u8fdb\u5165 .ssh \u6587\u4ef6\u5939&#xff0c;\u53ef\u4ee5\u770b\u5230\u5bc6\u94a5\u5bf9\u5df2\u7ecf\u751f\u6210\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418085225-680212c902d13.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>[!CAUTION]<\/p>\n<p>\u5047\u5982\u5728\u591a\u4e2a\u5e73\u53f0\u4e0a\u4f7f\u7528 SSH \u8fde\u63a5\u5230\u4e0d\u540c\u7684\u8fdc\u7a0b\u670d\u52a1\u5668\u65f6&#xff0c;\u53ef\u80fd\u9700\u8981\u4e3a\u6bcf\u4e2a\u5e73\u53f0\u751f\u6210\u548c\u4f7f\u7528\u4e0d\u540c\u7684\u5bc6\u94a5\u5bf9\u3002\u8fd9\u662f\u56e0\u4e3a\u6bcf\u4e2a\u5e73\u53f0&#xff08;\u4f8b\u5982&#xff0c;Windows\u3001Linux\u3001Mac&#xff09;\u53ef\u80fd\u6709\u4e0d\u540c\u7684\u6587\u4ef6\u7cfb\u7edf\u548c\u5bc6\u94a5\u6587\u4ef6\u4f4d\u7f6e&#xff0c;\u540c\u65f6\u5728\u5b89\u5168\u6027\u7684\u8003\u8651\u4e0b&#xff0c;\u4e0d\u540c\u5e73\u53f0\u4e0a\u7684\u5bc6\u94a5\u5bf9\u6700\u597d\u662f\u72ec\u7acb\u7684\u3002<\/p>\n<h3>2. \u5c06\u516c\u94a5\u590d\u5236\u5230\u8fdc\u7a0b\u670d\u52a1\u5668<\/h3>\n<p>\u5c06\u672c\u5730\u7cfb\u7edf\u4e0a\u751f\u6210\u7684\u516c\u94a5\u6587\u4ef6\u5185\u5bb9\u590d\u5236\u5230\u8fdc\u7a0b\u670d\u52a1\u5668\u7684&#xff0c;\u8981\u5c06\u516c\u94a5\u7684\u5185\u5bb9\u8ffd\u52a0\u5230 authorized_keys \u6587\u4ef6&#xff0c;\u53d1\u9001\u5230\u8fdc\u7a0b\u4e3b\u673a\u3002<\/p>\n<p>\u540c\u6837\u5728 CMD \u7a97\u53e3\u4f7f\u7528 scp \u547d\u4ee4\u628a id_rsa_windows.pud \u62f7\u8d1d\u5230 Ubuntu \u7cfb\u7edf&#xff0c;\u5177\u4f53\u547d\u4ee4\u5982\u4e0b&#xff08;\u522b\u4ec0\u4e48\u90fd\u7167\u6284&#xff0c;\u8fd9\u4e2a\u662f\u6211\u7684\u8fdc\u7a0b\u4e3b\u673a\u548c\u7aef\u53e3\u53f7&#xff09;&#xff1a;<\/p>\n<p><span class=\"token function\">scp<\/span> <span class=\"token parameter variable\">-P<\/span> <span class=\"token number\">2222<\/span> .\/.ssh\/id_rsa_windows.pub garyson&#064;192.168.31.90:~<\/p>\n<p>\u56de\u5230 VS Code \u4e0a&#xff0c;\u70b9\u51fb\u4fa7\u8fb9\u7b2c\u4e00\u4e2a\u56fe\u6807&#xff0c;\u7136\u540e\u70b9\u51fb \u201cOpen Folder\u201d&#xff0c;\u8fd9\u65f6\u4e2d\u95f4\u7684\u8f93\u5165\u6846\u5c31\u4f1a\u5f39\u51fa\u8fdc\u7a0b\u4e3b\u673a\u7684\u4e3b\u76ee\u5f55&#xff0c;\u76f4\u63a5\u70b9\u65c1\u8fb9\u7684 \u201cOK\u201d \u6309\u94ae&#xff0c;\u7136\u540e\u8f93\u5165 Ubuntu \u7684\u5bc6\u7801\u56de\u8f66\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418085225-680212c942586.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u968f\u540e\u7684\u5f39\u7a97\u4e2d\u5148\u52fe\u4e0a \u201cTrust the authors of all files in the parent folder \u2018home\u2019\u201d&#xff0c;\u7136\u540e\u518d\u70b9 \u201cYes, I trust the authors\u201d\u3002<\/p>\n<p>\u53ef\u4ee5\u770b\u5230\u6587\u4ef6\u5df2\u7ecf\u4f20\u8fc7\u53bb\u4e86\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418085225-680212c9968d7.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u7136\u540e\u5728\u7ec8\u7aef\u7a97\u53e3\u8f93\u5165 cat id_rsa_windows.pub &gt;&gt; .\/.ssh\/authorized_keys&#xff0c; \u628a\u516c\u94a5\u7684\u5185\u5bb9\u590d\u5236\u5230 .ssh\/authorized_keys \u91cc\u9762&#xff0c;<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418085225-680212c9a7bbf.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u7136\u540e\u5728\u7ec8\u7aef\u8f93\u5165\u4e0b\u9762\u7684\u547d\u4ee4&#xff0c;\u4fee\u6539\u8fd9\u4e24\u4e2a\u6587\u4ef6\u7684\u6743\u9650\u3002<\/p>\n<p><span class=\"token function\">chmod<\/span> <span class=\"token number\">700<\/span> ~\/.ssh<br \/>\n<span class=\"token function\">chmod<\/span> <span class=\"token number\">600<\/span> ~\/.ssh\/authorized_keys<\/p>\n<p>\u5982\u679c\u6ca1\u6709 .ssh \u8fd9\u4e2a\u6587\u4ef6\u5939&#xff0c;\u53ef\u4ee5\u624b\u52a8\u521b\u5efa\u4e00\u4e0b\u3002<\/p>\n<h3>3. \u914d\u7f6e SSH \u5ba2\u670d\u7aef<\/h3>\n<p>\u4fee\u6539 Ubuntu \u7cfb\u7edf\/etc\/ssh\/sshd_config\u914d\u7f6e\u6587\u4ef6&#xff0c;\u6dfb\u52a0\u4e0a\u4ee5\u4e0b\u914d\u7f6e\u4fe1\u606f&#xff1a;<\/p>\n<p>RSAAuthentication yes<br \/>\nPubkeyAuthentication yes<br \/>\nAuthorizedKeysFile      .ssh\/authorized_keys<\/p>\n<p>\u5b8c\u6210\u4ee5\u4e0a\u6b65\u9aa4\u540e&#xff0c;\u91cd\u542fSSH\u670d\u52a1\u4ee5\u5e94\u7528\u66f4\u6539&#xff1a;<\/p>\n<p><span class=\"token function\">sudo<\/span> systemctl restart sshd<\/p>\n<h3>4. \u8fde\u63a5\u6d4b\u8bd5<\/h3>\n<p>\u5173\u6389 VS Code \u91cd\u65b0\u6253\u5f00&#xff0c;\u5176\u5b9e\u5df2\u7ecf\u662f\u514d\u5bc6\u767b\u5f55\u4e86&#xff0c;\u56e0\u4e3a\u6253\u5f00 VS Code \u4e4b\u540e&#xff0c;\u5de6\u4e0b\u89d2\u51fa\u73b0\u4e86 \u201cSSH: Ubuntu\u201d&#xff0c;\u8bf4\u660e\u5df2\u7ecf\u81ea\u52a8\u8138\u4e0a\u4e86 Ubuntu \u4e3b\u673a\u4e86\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418085225-680212c9d49cc.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u6211\u4eec\u70b9\u51fb\u8fd9\u4e2a\u84dd\u8272\u7684\u56fe\u6807&#xff0c;\u7136\u540e\u5728\u4e2d\u95f4\u5f39\u51fa\u7684\u83dc\u5355\u4e2d\u9009\u62e9 Connext to Host\u2026\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418085225-680212c9dd766.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u9009\u62e9 Ubuntu\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418085225-680212c9ed595.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u8fd9\u65f6\u5c31\u4e0d\u9700\u8981\u8f93\u5165\u5bc6\u7801&#xff0c;\u4e5f\u53ef\u4ee5\u8fde\u63a5\u4e86&#xff0c;\u540c\u6837\u7684\u65b9\u6cd5\u9002\u7528\u4e8e\u4efb\u4f55 Linux \u8bbe\u7f6e\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418085226-680212ca09a19.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb2.3w\u6b21\uff0c\u70b9\u8d5e59\u6b21\uff0c\u6536\u85cf234\u6b21\u3002\u672c\u6587\u8be6\u7ec6\u4ecb\u7ecd\u4e86\u5982\u4f55\u5728Windows\u7cfb\u7edf\u4e2d\u4f7f\u7528VSCode\u7684Remote-SSH\u63d2\u4ef6\uff0c\u901a\u8fc7\u751f\u6210SSH\u5bc6\u94a5\u5bf9\u3001\u914d\u7f6eSSH\u5ba2\u6237\u7aef\uff0c\u5b9e\u73b0\u514d\u5bc6\u8fde\u63a5\u8fdc\u7a0bUbuntu\u7cfb\u7edf\uff0c\u5305\u62ec\u5b89\u88c5\u6269\u5c55\u3001\u8fde\u63a5\u6d41\u7a0b\u3001\u514d\u5bc6\u7b56\u7565\u548c\u914d\u7f6eSSH\u670d\u52a1\u3002<\/p>\n","protected":false},"author":2,"featured_media":8610,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[174,58,173,77,103,76,43],"topic":[],"class_list":["post-8629","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-c","tag-linux","tag-linux-","tag-ssh","tag-ubuntu","tag-vscode","tag-43"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>VS Code \u8fdc\u7a0b\u8fde\u63a5 SSH \u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/8629.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"VS Code \u8fdc\u7a0b\u8fde\u63a5 SSH \u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb2.3w\u6b21\uff0c\u70b9\u8d5e59\u6b21\uff0c\u6536\u85cf234\u6b21\u3002\u672c\u6587\u8be6\u7ec6\u4ecb\u7ecd\u4e86\u5982\u4f55\u5728Windows\u7cfb\u7edf\u4e2d\u4f7f\u7528VSCode\u7684Remote-SSH\u63d2\u4ef6\uff0c\u901a\u8fc7\u751f\u6210SSH\u5bc6\u94a5\u5bf9\u3001\u914d\u7f6eSSH\u5ba2\u6237\u7aef\uff0c\u5b9e\u73b0\u514d\u5bc6\u8fde\u63a5\u8fdc\u7a0bUbuntu\u7cfb\u7edf\uff0c\u5305\u62ec\u5b89\u88c5\u6269\u5c55\u3001\u8fde\u63a5\u6d41\u7a0b\u3001\u514d\u5bc6\u7b56\u7565\u548c\u914d\u7f6eSSH\u670d\u52a1\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/8629.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-04-18T08:52:28+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418085222-680212c69ee08.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/8629.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/8629.html\",\"name\":\"VS Code \u8fdc\u7a0b\u8fde\u63a5 SSH \u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-04-18T08:52:28+00:00\",\"dateModified\":\"2025-04-18T08:52:28+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/8629.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/8629.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/8629.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"VS Code \u8fdc\u7a0b\u8fde\u63a5 SSH \u670d\u52a1\u5668\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"VS Code \u8fdc\u7a0b\u8fde\u63a5 SSH \u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/8629.html","og_locale":"zh_CN","og_type":"article","og_title":"VS Code \u8fdc\u7a0b\u8fde\u63a5 SSH \u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb2.3w\u6b21\uff0c\u70b9\u8d5e59\u6b21\uff0c\u6536\u85cf234\u6b21\u3002\u672c\u6587\u8be6\u7ec6\u4ecb\u7ecd\u4e86\u5982\u4f55\u5728Windows\u7cfb\u7edf\u4e2d\u4f7f\u7528VSCode\u7684Remote-SSH\u63d2\u4ef6\uff0c\u901a\u8fc7\u751f\u6210SSH\u5bc6\u94a5\u5bf9\u3001\u914d\u7f6eSSH\u5ba2\u6237\u7aef\uff0c\u5b9e\u73b0\u514d\u5bc6\u8fde\u63a5\u8fdc\u7a0bUbuntu\u7cfb\u7edf\uff0c\u5305\u62ec\u5b89\u88c5\u6269\u5c55\u3001\u8fde\u63a5\u6d41\u7a0b\u3001\u514d\u5bc6\u7b56\u7565\u548c\u914d\u7f6eSSH\u670d\u52a1\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/8629.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-04-18T08:52:28+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418085222-680212c69ee08.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/8629.html","url":"https:\/\/www.wsisp.com\/helps\/8629.html","name":"VS Code \u8fdc\u7a0b\u8fde\u63a5 SSH \u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-04-18T08:52:28+00:00","dateModified":"2025-04-18T08:52:28+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/8629.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/8629.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/8629.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"VS Code \u8fdc\u7a0b\u8fde\u63a5 SSH \u670d\u52a1\u5668"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/8629","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=8629"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/8629\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/8610"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=8629"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=8629"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=8629"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=8629"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}