{"id":20429,"date":"2025-04-19T03:22:05","date_gmt":"2025-04-18T19:22:05","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/20429.html"},"modified":"2025-04-19T03:22:05","modified_gmt":"2025-04-18T19:22:05","slug":"vs-code-%e9%80%9a%e8%bf%87-ssh-%e8%bf%9e%e6%8e%a5%e6%9c%8d%e5%8a%a1%e5%99%a8-ssh-%e4%bc%9a%e8%af%9d%e6%96%ad%e5%bc%80%e5%af%bc%e8%87%b4%e6%9c%8d%e5%8a%a1%e5%99%a8%e8%bf%90%e8%a1%8c%e7%9a%84%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/20429.html","title":{"rendered":"VS Code \u901a\u8fc7 SSH \u8fde\u63a5\u670d\u52a1\u5668, SSH \u4f1a\u8bdd\u65ad\u5f00\u5bfc\u81f4\u670d\u52a1\u5668\u8fd0\u884c\u7684\u7a0b\u5e8f\u4e2d\u65ad"},"content":{"rendered":"<h2>1. \u907f\u514d\u7a0b\u5e8f\u4e2d\u65ad<\/h2>\n<p>\u5373\u4f7f\u7f51\u7edc\u4e2d\u65ad&#xff0c;\u4f60\u4e5f\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\u8ba9\u7a0b\u5e8f\u7ee7\u7eed\u8fd0\u884c&#xff1a;<\/p>\n<h3>(1) \u4f7f\u7528 tmux \u6216 screen<\/h3>\n<p>tmux \u548c screen \u662f Linux \u4e0b\u7684\u7ec8\u7aef\u590d\u7528\u5de5\u5177&#xff0c;\u5141\u8bb8\u4f60\u5728\u670d\u52a1\u5668\u4e0a\u5f00\u542f\u4e00\u4e2a\u4f1a\u8bdd\u5e76\u4fdd\u6301\u8fd0\u884c\u72b6\u6001&#xff0c;\u5373\u4f7f SSH \u4f1a\u8bdd\u65ad\u5f00&#xff0c;\u7a0b\u5e8f\u4ecd\u7136\u7ee7\u7eed\u8fd0\u884c\u3002<\/p>\n<p>\u6b65\u9aa4&#xff1a;<\/p>\n<li>\u5728\u670d\u52a1\u5668\u4e0a\u5b89\u88c5 tmux \u6216 screen\u3002 sudo apt install tmux # Debian\/Ubuntu sudo yum install tmux # CentOS\/RHEL\n<\/p>\n<\/li>\n<li>\u542f\u52a8\u4e00\u4e2a tmux \u4f1a\u8bdd&#xff1a;  tmux new -s mysession\n<\/p>\n<\/li>\n<li>\u5728 tmux \u4f1a\u8bdd\u4e2d\u8fd0\u884c\u4f60\u7684\u7a0b\u5e8f\u3002<\/li>\n<li>\u65ad\u5f00 SSH \u540e&#xff0c;\u91cd\u65b0\u8fde\u63a5\u65f6\u53ef\u4ee5\u6062\u590d tmux \u4f1a\u8bdd&#xff1a;  tmux attach -t mysession\n<\/p>\n<\/li>\n<h3>(2) \u4f7f\u7528 nohup<\/h3>\n<p>nohup&#xff08;No Hangup&#xff09;\u53ef\u4ee5\u8ba9\u7a0b\u5e8f\u5728\u540e\u53f0\u8fd0\u884c&#xff0c;\u9632\u6b62\u5b83\u56e0\u7ec8\u7aef\u65ad\u5f00\u800c\u505c\u6b62\u3002<\/p>\n<p>\u793a\u4f8b&#xff1a;<\/p>\n<p>nohup python your_script.py &gt; output.log 2&gt;&amp;1 &amp; <\/p>\n<ul>\n<li>&amp;&#xff1a;\u8868\u793a\u7a0b\u5e8f\u5728\u540e\u53f0\u8fd0\u884c\u3002<\/li>\n<li>output.log&#xff1a;\u5c06\u8f93\u51fa\u91cd\u5b9a\u5411\u5230\u65e5\u5fd7\u6587\u4ef6\u3002<\/li>\n<\/ul>\n<h2>2. \u4fdd\u6301 VS Code SSH \u4f1a\u8bdd\u7a33\u5b9a<\/h2>\n<p>\u5982\u679c\u60f3\u5c3d\u53ef\u80fd\u907f\u514d SSH \u4f1a\u8bdd\u65ad\u5f00&#xff0c;\u53ef\u4ee5\u8fdb\u884c\u4ee5\u4e0b\u914d\u7f6e&#xff1a;<\/p>\n<h3>(1) \u914d\u7f6e SSH \u7684 ServerAliveInterval<\/h3>\n<p>\u5728 SSH \u914d\u7f6e\u6587\u4ef6\u4e2d\u589e\u52a0\u5fc3\u8df3\u673a\u5236&#xff0c;\u8ba9\u5ba2\u6237\u7aef\u4e0e\u670d\u52a1\u5668\u4fdd\u6301\u6d3b\u8dc3\u8fde\u63a5&#xff1a;<\/p>\n<p>\u7f16\u8f91 SSH \u914d\u7f6e\u6587\u4ef6&#xff1a;<\/p>\n<p>vim ~\/.ssh\/config <\/p>\n<p>\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9&#xff1a;<\/p>\n<p>Host * ServerAliveInterval 60 ServerAliveCountMax 3 <\/p>\n<ul>\n<li>ServerAliveInterval 60&#xff1a;\u6bcf 60 \u79d2\u53d1\u9001\u4e00\u6b21\u5fc3\u8df3\u5305\u3002<\/li>\n<li>ServerAliveCountMax 3&#xff1a;\u5982\u679c\u8fde\u7eed 3 \u6b21\u5fc3\u8df3\u5931\u8d25&#xff08;3 \u5206\u949f&#xff09;&#xff0c;SSH \u4f1a\u65ad\u5f00\u8fde\u63a5\u3002<\/li>\n<\/ul>\n<h3>(2) \u914d\u7f6e\u670d\u52a1\u5668\u7aef SSHD<\/h3>\n<p>\u5728\u670d\u52a1\u5668\u4e0a&#xff0c;\u4fee\u6539 \/etc\/ssh\/sshd_config \u6587\u4ef6&#xff0c;\u589e\u52a0\u5ba2\u6237\u7aef\u4fdd\u6301\u6d3b\u8dc3\u914d\u7f6e&#xff1a;<\/p>\n<p>ClientAliveInterval 60 ClientAliveCountMax 3 <\/p>\n<p>\u7136\u540e\u91cd\u542f SSH \u670d\u52a1&#xff1a;<\/p>\n<p>sudo systemctl restart sshd <\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.2k\u6b21\uff0c\u70b9\u8d5e6\u6b21\uff0c\u6536\u85cf9\u6b21\u3002\u662f Linux \u4e0b\u7684\u7ec8\u7aef\u590d\u7528\u5de5\u5177\uff0c\u5141\u8bb8\u4f60\u5728\u670d\u52a1\u5668\u4e0a\u5f00\u542f\u4e00\u4e2a\u4f1a\u8bdd\u5e76\u4fdd\u6301\u8fd0\u884c\u72b6\u6001\uff0c\u5373\u4f7f SSH \u4f1a\u8bdd\u65ad\u5f00\uff0c\u7a0b\u5e8f\u4ecd\u7136\u7ee7\u7eed\u8fd0\u884c\u3002\uff08No Hangup\uff09\u53ef\u4ee5\u8ba9\u7a0b\u5e8f\u5728\u540e\u53f0\u8fd0\u884c\uff0c\u9632\u6b62\u5b83\u56e0\u7ec8\u7aef\u65ad\u5f00\u800c\u505c\u6b62\u3002_vscode\u65ad\u5f00ssh\u8fde\u63a5<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[77,43,44],"topic":[],"class_list":["post-20429","post","type-post","status-publish","format-standard","hentry","category-server","tag-ssh","tag-43","tag-44"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>VS Code \u901a\u8fc7 SSH \u8fde\u63a5\u670d\u52a1\u5668, SSH \u4f1a\u8bdd\u65ad\u5f00\u5bfc\u81f4\u670d\u52a1\u5668\u8fd0\u884c\u7684\u7a0b\u5e8f\u4e2d\u65ad - \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\/20429.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"VS Code \u901a\u8fc7 SSH \u8fde\u63a5\u670d\u52a1\u5668, SSH \u4f1a\u8bdd\u65ad\u5f00\u5bfc\u81f4\u670d\u52a1\u5668\u8fd0\u884c\u7684\u7a0b\u5e8f\u4e2d\u65ad - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.2k\u6b21\uff0c\u70b9\u8d5e6\u6b21\uff0c\u6536\u85cf9\u6b21\u3002\u662f Linux \u4e0b\u7684\u7ec8\u7aef\u590d\u7528\u5de5\u5177\uff0c\u5141\u8bb8\u4f60\u5728\u670d\u52a1\u5668\u4e0a\u5f00\u542f\u4e00\u4e2a\u4f1a\u8bdd\u5e76\u4fdd\u6301\u8fd0\u884c\u72b6\u6001\uff0c\u5373\u4f7f SSH \u4f1a\u8bdd\u65ad\u5f00\uff0c\u7a0b\u5e8f\u4ecd\u7136\u7ee7\u7eed\u8fd0\u884c\u3002\uff08No Hangup\uff09\u53ef\u4ee5\u8ba9\u7a0b\u5e8f\u5728\u540e\u53f0\u8fd0\u884c\uff0c\u9632\u6b62\u5b83\u56e0\u7ec8\u7aef\u65ad\u5f00\u800c\u505c\u6b62\u3002_vscode\u65ad\u5f00ssh\u8fde\u63a5\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/20429.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-18T19:22:05+00:00\" \/>\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=\"1 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/20429.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/20429.html\",\"name\":\"VS Code \u901a\u8fc7 SSH \u8fde\u63a5\u670d\u52a1\u5668, SSH \u4f1a\u8bdd\u65ad\u5f00\u5bfc\u81f4\u670d\u52a1\u5668\u8fd0\u884c\u7684\u7a0b\u5e8f\u4e2d\u65ad - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-04-18T19:22:05+00:00\",\"dateModified\":\"2025-04-18T19:22:05+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/20429.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/20429.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/20429.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"VS Code \u901a\u8fc7 SSH \u8fde\u63a5\u670d\u52a1\u5668, SSH \u4f1a\u8bdd\u65ad\u5f00\u5bfc\u81f4\u670d\u52a1\u5668\u8fd0\u884c\u7684\u7a0b\u5e8f\u4e2d\u65ad\"}]},{\"@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 \u901a\u8fc7 SSH \u8fde\u63a5\u670d\u52a1\u5668, SSH \u4f1a\u8bdd\u65ad\u5f00\u5bfc\u81f4\u670d\u52a1\u5668\u8fd0\u884c\u7684\u7a0b\u5e8f\u4e2d\u65ad - \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\/20429.html","og_locale":"zh_CN","og_type":"article","og_title":"VS Code \u901a\u8fc7 SSH \u8fde\u63a5\u670d\u52a1\u5668, SSH \u4f1a\u8bdd\u65ad\u5f00\u5bfc\u81f4\u670d\u52a1\u5668\u8fd0\u884c\u7684\u7a0b\u5e8f\u4e2d\u65ad - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.2k\u6b21\uff0c\u70b9\u8d5e6\u6b21\uff0c\u6536\u85cf9\u6b21\u3002\u662f Linux \u4e0b\u7684\u7ec8\u7aef\u590d\u7528\u5de5\u5177\uff0c\u5141\u8bb8\u4f60\u5728\u670d\u52a1\u5668\u4e0a\u5f00\u542f\u4e00\u4e2a\u4f1a\u8bdd\u5e76\u4fdd\u6301\u8fd0\u884c\u72b6\u6001\uff0c\u5373\u4f7f SSH \u4f1a\u8bdd\u65ad\u5f00\uff0c\u7a0b\u5e8f\u4ecd\u7136\u7ee7\u7eed\u8fd0\u884c\u3002\uff08No Hangup\uff09\u53ef\u4ee5\u8ba9\u7a0b\u5e8f\u5728\u540e\u53f0\u8fd0\u884c\uff0c\u9632\u6b62\u5b83\u56e0\u7ec8\u7aef\u65ad\u5f00\u800c\u505c\u6b62\u3002_vscode\u65ad\u5f00ssh\u8fde\u63a5","og_url":"https:\/\/www.wsisp.com\/helps\/20429.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-04-18T19:22:05+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"1 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/20429.html","url":"https:\/\/www.wsisp.com\/helps\/20429.html","name":"VS Code \u901a\u8fc7 SSH \u8fde\u63a5\u670d\u52a1\u5668, SSH \u4f1a\u8bdd\u65ad\u5f00\u5bfc\u81f4\u670d\u52a1\u5668\u8fd0\u884c\u7684\u7a0b\u5e8f\u4e2d\u65ad - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-04-18T19:22:05+00:00","dateModified":"2025-04-18T19:22:05+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/20429.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/20429.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/20429.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"VS Code \u901a\u8fc7 SSH \u8fde\u63a5\u670d\u52a1\u5668, SSH \u4f1a\u8bdd\u65ad\u5f00\u5bfc\u81f4\u670d\u52a1\u5668\u8fd0\u884c\u7684\u7a0b\u5e8f\u4e2d\u65ad"}]},{"@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\/20429","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=20429"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/20429\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=20429"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=20429"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=20429"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=20429"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}