{"id":255,"date":"2026-03-23T15:14:15","date_gmt":"2026-03-23T07:14:15","guid":{"rendered":"https:\/\/home.snu1e.top\/index.php\/2026\/03\/23\/windows-%e7%8e%af%e5%a2%83%e4%b8%8b%e9%85%8d%e7%bd%ae-ssh-%e7%ab%af%e5%8f%a3%e8%bd%ac%e5%8f%91%e5%bc%80%e6%9c%ba%e9%9a%90%e8%94%bd%e8%87%aa%e5%90%af%e6%8c%87%e5%8d%97\/"},"modified":"2026-03-23T15:14:15","modified_gmt":"2026-03-23T07:14:15","slug":"windows-%e7%8e%af%e5%a2%83%e4%b8%8b%e9%85%8d%e7%bd%ae-ssh-%e7%ab%af%e5%8f%a3%e8%bd%ac%e5%8f%91%e5%bc%80%e6%9c%ba%e9%9a%90%e8%94%bd%e8%87%aa%e5%90%af%e6%8c%87%e5%8d%97","status":"publish","type":"post","link":"https:\/\/home.snu1e.top\/index.php\/2026\/03\/23\/windows-%e7%8e%af%e5%a2%83%e4%b8%8b%e9%85%8d%e7%bd%ae-ssh-%e7%ab%af%e5%8f%a3%e8%bd%ac%e5%8f%91%e5%bc%80%e6%9c%ba%e9%9a%90%e8%94%bd%e8%87%aa%e5%90%af%e6%8c%87%e5%8d%97\/","title":{"rendered":"Windows \u73af\u5883\u4e0b\u914d\u7f6e SSH \u7aef\u53e3\u8f6c\u53d1\u5f00\u673a\u9690\u853d\u81ea\u542f\u6307\u5357"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u6587\u6863\u8bf4\u660e<\/h2>\n\n\n\n<p>\u672c\u6307\u5357\u7528\u4e8e\u5728 Windows \u7535\u8111\u4e0a\uff0c\u901a\u8fc7 SSH \u96a7\u9053\u5c06\u672c\u5730\u7aef\u53e3\u8f6c\u53d1\u81f3\u8fdc\u7a0b\u670d\u52a1\u5668\u7684\u672c\u5730\u7aef\u53e3\uff0c\u5e76\u914d\u7f6e\u8be5\u8fde\u63a5\u5728 Windows \u5f00\u673a\u65f6\u81ea\u52a8\u3001\u65e0\u9ed1\u6846\u5728\u540e\u53f0\u8fd0\u884c\uff0c\u4e14\u5177\u5907\u65ad\u7ebf\u81ea\u52a8\u91cd\u8fde\u529f\u80fd\u3002<\/p>\n\n\n\n<p><strong>\u9002\u7528\u73af\u5883\uff1a<\/strong>Windows 10 \/ Windows 11 (\u5185\u7f6e OpenSSH)<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u7b2c\u4e00\u9636\u6bb5\uff1a\u914d\u7f6e SSH \u514d\u5bc6\u767b\u5f55<\/h2>\n\n\n\n<p><strong>\u8bf4\u660e\uff1a<\/strong>\u5f00\u673a\u81ea\u52a8\u8fd0\u884c\u7684\u7a0b\u5e8f\u65e0\u6cd5\u8fdb\u884c\u5f39\u7a97\u4ea4\u4e92\uff0c\u56e0\u6b64\u5fc5\u987b\u914d\u7f6e\u57fa\u4e8e\u5bc6\u94a5\u7684\u514d\u5bc6\u767b\u5f55\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1. \u751f\u6210 SSH \u5bc6\u94a5\u5bf9<\/h3>\n\n\n\n<p>\u6253\u5f00 Windows \u7684\u547d\u4ee4\u63d0\u793a\u7b26 (CMD)\u3002\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u5e76\u56de\u8f66\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">ssh-keygen -t rsa -b 4096<\/pre>\n\n\n\n<p>\u9047\u5230\u6240\u6709\u63d0\u793a\uff08\u5982\u4fdd\u5b58\u8def\u5f84\u3001\u5bc6\u7801\u8bbe\u7f6e\u7b49\uff09\uff0c\u4e00\u5f8b\u76f4\u63a5\u6309\u56de\u8f66\u952e\uff0c\u4f7f\u7528\u9ed8\u8ba4\u8bbe\u7f6e\u4e14\u4e0d\u8bbe\u7f6e\u5bc6\u7801\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2. \u5c06\u516c\u94a5\u53d1\u9001\u81f3\u8fdc\u7a0b\u670d\u52a1\u5668<\/h3>\n\n\n\n<p>\u7ee7\u7eed\u5728 CMD \u4e2d\u8f93\u5165\u4ee5\u4e0b\u5b8c\u6574\u547d\u4ee4\u5e76\u56de\u8f66\uff08\u5c06 <code>user@remote_host<\/code> \u66ff\u6362\u4e3a\u4f60\u7684\u5b9e\u9645\u7528\u6237\u540d\u548c\u670d\u52a1\u5668\u5730\u5740\uff09\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">type %USERPROFILE%\\.ssh\\id_rsa.pub | ssh user@remote_host \"mkdir -p ~\/.ssh && chmod 700 ~\/.ssh && cat >> ~\/.ssh\/authorized_keys && chmod 600 ~\/.ssh\/authorized_keys\"<\/pre>\n\n\n\n<p><strong>\u6ce8\u610f\uff1a<\/strong>\u6267\u884c\u6b64\u547d\u4ee4\u65f6\uff0c\u7cfb\u7edf\u4f1a\u8981\u6c42\u8f93\u5165\u4e00\u6b21\u8fdc\u7a0b\u670d\u52a1\u5668\u7684\u767b\u5f55\u5bc6\u7801\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3. \u6d4b\u8bd5\u514d\u5bc6\u8fde\u63a5<\/h3>\n\n\n\n<p>\u5728 CMD \u4e2d\u8f93\u5165\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">ssh user@remote_host<\/pre>\n\n\n\n<p>\u5982\u679c\u65e0\u9700\u8f93\u5165\u5bc6\u7801\u5373\u53ef\u6210\u529f\u767b\u5f55\u670d\u52a1\u5668\u7ec8\u7aef\uff0c\u5219\u8bf4\u660e\u514d\u5bc6\u914d\u7f6e\u6210\u529f\u3002\u8f93\u5165 <code>exit<\/code> \u9000\u51fa\u8fde\u63a5\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u7b2c\u4e8c\u9636\u6bb5\uff1a\u521b\u5efa\u81ea\u52a8\u91cd\u8fde\u6279\u5904\u7406\u811a\u672c<\/h2>\n\n\n\n<p><strong>\u8bf4\u660e\uff1a<\/strong>\u7f16\u5199\u4e00\u4e2a .bat \u811a\u672c\uff0c\u7528\u4e8e\u5efa\u7acb SSH \u96a7\u9053\u5e76\u5728\u7f51\u7edc\u65ad\u5f00\u65f6\u81ea\u52a8\u91cd\u8fde\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1. \u521b\u5efa\u5de5\u4f5c\u76ee\u5f55<\/h3>\n\n\n\n<p>\u5728 <code>C:\\<\/code> \u6839\u76ee\u5f55\uff08\u6216\u5176\u4ed6\u4e0d\u6613\u88ab\u8bef\u5220\u7684\u4f4d\u7f6e\uff09\u65b0\u5efa\u4e00\u4e2a\u6587\u4ef6\u5939\uff0c\u547d\u540d\u4e3a <code>SSH_Tunnel<\/code>\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2. \u7f16\u5199\u811a\u672c\u6587\u4ef6<\/h3>\n\n\n\n<p>\u5728\u8be5\u6587\u4ef6\u5939\u5185\u65b0\u5efa\u4e00\u4e2a\u6587\u672c\u6587\u6863\uff0c\u91cd\u547d\u540d\u4e3a <code>ssh-tunnel.bat<\/code>\uff08\u8bf7\u786e\u4fdd\u5728\u7cfb\u7edf\u89c6\u56fe\u4e2d\u5f00\u542f\u4e86&#8221;\u663e\u793a\u6587\u4ef6\u6269\u5c55\u540d&#8221;\uff0c\u52a1\u5fc5\u5220\u6389\u9690\u85cf\u7684 .txt \u540e\u7f00\uff09\u3002<\/p>\n\n\n\n<p>\u53f3\u952e\u7f16\u8f91\u8be5\u6587\u4ef6\uff0c\u7c98\u8d34\u4ee5\u4e0b\u4ee3\u7801\u5e76\u4fdd\u5b58\uff08\u8bf7\u6839\u636e\u4f60\u7684\u5b9e\u9645\u60c5\u51b5\u4fee\u6539\u7aef\u53e3\u548c\u670d\u52a1\u5668\u5730\u5740\uff09\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">@echo off\n:loop\n:: -N: \u4ec5\u8f6c\u53d1\u7aef\u53e3\uff0c\u4e0d\u6253\u5f00\u8fdc\u7a0b\u7ec8\u7aef\n:: ServerAlive \u53c2\u6570: \u7528\u4e8e\u68c0\u6d4b\u65ad\u7ebf\uff0c\u8d85\u65f6\u540e\u81ea\u52a8\u7ed3\u675f\u5f53\u524d\u8fde\u63a5\n:: \u672c\u5730\u7aef\u53e3:LOCAL_PORT\uff0c\u8fdc\u7a0b\u7aef\u53e3:REMOTE_PORT\nssh -N -o ServerAliveInterval=30 -o ServerAliveCountMax=3 -L LOCAL_PORT:localhost:REMOTE_PORT user@remote_host\n:: \u65ad\u5f00\u540e\u7b49\u5f85 10 \u79d2\u91cd\u65b0\u53d1\u8d77\u8fde\u63a5\ntimeout 10\ngoto loop<\/pre>\n\n\n\n<p><strong>\u53c2\u6570\u8bf4\u660e\uff1a<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>-L LOCAL_PORT:localhost:REMOTE_PORT<\/code>\uff1a\u5c06\u672c\u5730\u7aef\u53e3\u8f6c\u53d1\u5230\u8fdc\u7a0b\u670d\u52a1\u5668\u7684\u7aef\u53e3<\/li>\n<li><code>user@remote_host<\/code>\uff1a\u66ff\u6362\u4e3a\u4f60\u7684 SSH \u7528\u6237\u540d\u548c\u670d\u52a1\u5668\u5730\u5740<\/li>\n<li><code>ServerAliveInterval=30<\/code>\uff1a\u6bcf 30 \u79d2\u53d1\u9001\u4e00\u6b21\u5fc3\u8df3\u5305<\/li>\n<li><code>ServerAliveCountMax=3<\/code>\uff1a\u8fde\u7eed 3 \u6b21\u65e0\u54cd\u5e94\u5219\u5224\u5b9a\u65ad\u7ebf<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">\u7b2c\u4e09\u9636\u6bb5\uff1a\u914d\u7f6e\u5f00\u673a\u9690\u853d\u542f\u52a8<\/h2>\n\n\n\n<p><strong>\u8bf4\u660e\uff1a<\/strong>\u5229\u7528 VBS \u811a\u672c\u8c03\u7528 .bat \u6587\u4ef6\uff0c\u5b9e\u73b0\u5f00\u673a\u81ea\u542f\u5e76\u9690\u85cf\u8fd0\u884c\u65f6\u7684\u9ed1\u8272\u547d\u4ee4\u63d0\u793a\u7b26\u7a97\u53e3\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1. \u8fdb\u5165 Windows \u542f\u52a8\u6587\u4ef6\u5939<\/h3>\n\n\n\n<p>\u6309\u4e0b\u952e\u76d8\u5feb\u6377\u952e <code>Win + R<\/code> \u6253\u5f00&#8221;\u8fd0\u884c&#8221;\u7a97\u53e3\u3002\u8f93\u5165 <code>shell:startup<\/code> \u5e76\u56de\u8f66\uff0c\u7cfb\u7edf\u5c06\u6253\u5f00\u5f53\u524d\u7528\u6237\u7684&#8221;\u542f\u52a8&#8221;\u6587\u4ef6\u5939\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2. \u7f16\u5199 VBS \u5f15\u5bfc\u811a\u672c<\/h3>\n\n\n\n<p>\u5728&#8221;\u542f\u52a8&#8221;\u6587\u4ef6\u5939\u4e2d\u65b0\u5efa\u4e00\u4e2a\u6587\u672c\u6587\u6863\uff0c\u91cd\u547d\u540d\u4e3a <code>start-tunnel.vbs<\/code>\uff08\u540c\u6837\u9700\u6ce8\u610f\u6e05\u9664 .txt \u540e\u7f00\uff09\u3002<\/p>\n\n\n\n<p>\u53f3\u952e\u7f16\u8f91\u8be5\u6587\u4ef6\uff0c\u7c98\u8d34\u4ee5\u4e0b\u4ee3\u7801\u5e76\u4fdd\u5b58\uff08\u82e5\u7b2c\u4e8c\u9636\u6bb5\u7684\u6587\u4ef6\u5939\u8def\u5f84\u4e0d\u540c\uff0c\u8bf7\u81ea\u884c\u4fee\u6539\u4ee3\u7801\u4e2d\u7684\u8def\u5f84\uff09\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Set ws = CreateObject(\"Wscript.Shell\")\n' vbhide \u53c2\u6570\u5b9e\u73b0\u540e\u53f0\u9690\u853d\u8fd0\u884c\nws.run \"cmd \/c C:\\SSH_Tunnel\\ssh-tunnel.bat\", vbhide<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u5b8c\u6210\uff01<\/h2>\n\n\n\n<p>\u81f3\u6b64\u914d\u7f6e\u5168\u90e8\u7ed3\u675f\u3002\u4f60\u53ef\u4ee5\u76f4\u63a5\u53cc\u51fb <code>start-tunnel.vbs<\/code> \u6587\u4ef6\u7acb\u5373\u8fd0\u884c\u6d4b\u8bd5\u3002\u4ee5\u540e\u6bcf\u6b21 Windows \u5f00\u673a\uff0cSSH \u96a7\u9053\u90fd\u4f1a\u5728\u540e\u53f0\u81ea\u52a8\u6253\u901a\u5e76\u4fdd\u6301\u8fde\u63a5\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5e38\u89c1\u95ee\u9898\u6392\u67e5<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u65e0\u6cd5\u81ea\u52a8\u91cd\u8fde\uff1a<\/strong>\u68c0\u67e5 ServerAlive \u53c2\u6570\u662f\u5426\u6b63\u786e\u914d\u7f6e<\/li>\n<li><strong>\u9ed1\u6846\u4ecd\u7136\u663e\u793a\uff1a<\/strong>\u786e\u8ba4 VBS \u811a\u672c\u4e2d\u7684\u8def\u5f84\u662f\u5426\u6b63\u786e\uff0c\u4e14\u4f7f\u7528\u4e86 vbhide \u53c2\u6570<\/li>\n<li><strong>\u5f00\u673a\u672a\u81ea\u52a8\u542f\u52a8\uff1a<\/strong>\u786e\u8ba4 VBS \u6587\u4ef6\u5df2\u653e\u5165\u542f\u52a8\u6587\u4ef6\u5939\uff08<code>shell:startup<\/code>\uff09<\/li>\n<li><strong>\u8fde\u63a5\u88ab\u62d2\u7edd\uff1a<\/strong>\u68c0\u67e5\u8fdc\u7a0b\u670d\u52a1\u5668 SSH \u670d\u52a1\u662f\u5426\u8fd0\u884c\uff0c\u7aef\u53e3\u662f\u5426\u6b63\u786e<\/li>\n<\/ul>\n\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u6863\u8bf4\u660e \u672c\u6307\u5357\u7528\u4e8e\u5728 Windows \u7535\u8111\u4e0a\uff0c\u901a\u8fc7 SSH \u96a7\u9053\u5c06\u672c\u5730\u7aef\u53e3\u8f6c\u53d1\u81f3\u8fdc\u7a0b\u670d\u52a1\u5668\u7684\u672c\u5730\u7aef\u53e3\uff0c\u5e76\u914d\u7f6e [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[26],"tags":[64,63,65,66],"class_list":["post-255","post","type-post","status-publish","format-standard","hentry","category-26","tag-ssh","tag-windows","tag-65","tag-66"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/home.snu1e.top\/index.php\/wp-json\/wp\/v2\/posts\/255","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/home.snu1e.top\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/home.snu1e.top\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/home.snu1e.top\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/home.snu1e.top\/index.php\/wp-json\/wp\/v2\/comments?post=255"}],"version-history":[{"count":0,"href":"https:\/\/home.snu1e.top\/index.php\/wp-json\/wp\/v2\/posts\/255\/revisions"}],"wp:attachment":[{"href":"https:\/\/home.snu1e.top\/index.php\/wp-json\/wp\/v2\/media?parent=255"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/home.snu1e.top\/index.php\/wp-json\/wp\/v2\/categories?post=255"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/home.snu1e.top\/index.php\/wp-json\/wp\/v2\/tags?post=255"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}