{"id":912,"date":"2024-12-15T00:02:01","date_gmt":"2024-12-14T16:02:01","guid":{"rendered":"https:\/\/keyi.eu.org\/?p=912"},"modified":"2024-12-15T00:03:22","modified_gmt":"2024-12-14T16:03:22","slug":"serv00%e4%bf%9d%e6%b4%bb","status":"publish","type":"post","link":"https:\/\/keyi.eu.org\/?p=912","title":{"rendered":"Serv00\u4fdd\u6d3b"},"content":{"rendered":"<p><img src=\"https:\/\/keyi.eu.org\/wp-content\/uploads\/2024\/12\/blogServ00\u4fdd\u6d3b-1.png\" alt=\"Serv00\u4fdd\u6d3b\"><\/p>\n<p>Serv00\u8981\u6c42\u6bcf90\u5929\uff0c\u5fc5\u9808\u5f9eWEB\u6216\u8005SSH\u767b\u9304\u4e00\u6b21\uff0c\u4f5c\u7232\u201c\u6d3b\u8e8d\u4f7f\u7528\u201d\u7684\u6a19\u8b58\uff0c\u5426\u5247\u6703\u522a\u9664\u88ab\u9592\u7f6e\u7684\u5e33\u865f\u3002<\/p>\n<p>\u6211\u5728Euserv\u4e0a\uff0c\u90e8\u7f72\u4e86\u4e00\u500b\u8a08\u5283\u4efb\u52d9\uff0c\u6bcf\u9694\u4e00\u6bb5\u6642\u9593\uff0cSSH\u767b\u9304\u5230\u6bcf\u4e00\u81faServ00\u7684VPS\u4e0a\uff0c\u6aa2\u6e2c\u662f\u5426\u6709\u6b63\u5e38\u7684\u5728\u904b\u884c\u7740\u54ea\u5412\u76e3\u63a7\u7684\u5ba2\u6236\u7aef\u3002\u5982\u679c\u6c92\u6709\uff0c\u5247\u901a\u904epm2\u4f86\u559a\u8d77\u5b83\u7684\u57f7\u884c\u3002<\/p>\n<blockquote>\n<p><small>#!\/bin\/bash<\/small><\/p>\n<p><small># \u901a\u7528 SSH \u53c3\u6578\u8a2d\u7f6e\uff0c\u8a18\u5f97\u5728\u9019\u88cf\uff0c\u5beb\u597dserv00\u7684\u5bc6\u78bc<\/small><br \/>\n<small>SSH_OPTIONS=&quot;-tt -o StrictHostKeyChecking=no -o UserKnownHostsFile=\/dev\/null&quot;<\/small><br \/>\n<small>PASSWORD=&quot;\u5bc6\u78bc&quot;<\/small><\/p>\n<p><small>for i in {1..2}<\/small><br \/>\n<small>do<\/small><br \/>\n<small>echo &quot;Execution round $i&quot;<\/small><\/p>\n<p><small># \u7b2c\u4e00\u53f0\u4e3b\u6a5f<\/small><br \/>\n<small>sshpass -p &quot;$PASSWORD&quot; ssh $SSH_OPTIONS \u7b2c\u4e00\u500b\u5e33\u865f@s7.serv00.com &lt;&lt; &#8216;EOF1&#8217;<\/small><br \/>\n<small>if pgrep -x &quot;nezha-agent&quot; &gt; \/dev\/null<\/small><br \/>\n<small>then<\/small><br \/>\n<small>echo &quot;nezha-agent is running on \u7b2c\u4e00\u500b\u5e33\u865f&quot;<\/small><br \/>\n<small>else<\/small><br \/>\n<small>\/home\/\u7b2c\u4e00\u500b\u5e33\u865f\/.npm-global\/bin\/pm2 resurrect<\/small><br \/>\n<small>echo &quot;pm2 resurrect command executed on \u7b2c\u4e00\u500b\u5e33\u865f&quot;<\/small><br \/>\n<small>fi<\/small><br \/>\n<small>exit<\/small><br \/>\n<small>EOF1<\/small><\/p>\n<p><small># \u7b2c\u4e8c\u53f0\u4e3b\u6a5f<\/small><br \/>\n<small>sshpass -p &quot;$PASSWORD&quot; ssh $SSH_OPTIONS \u7b2c\u4e8c\u500b\u5e33\u865f@s7.serv00.com &lt;&lt; &#8216;EOF2&#8217;<\/small><br \/>\n<small>if pgrep -x &quot;nezha-agent&quot; &gt; \/dev\/null<\/small><br \/>\n<small>then<\/small><br \/>\n<small>echo &quot;nezha-agent is running on \u7b2c\u4e8c\u500b\u5e33\u865f&quot;<\/small><br \/>\n<small>else<\/small><br \/>\n<small>\/home\/\u7b2c\u4e8c\u500b\u5e33\u865f\/.npm-global\/bin\/pm2 start 1<\/small><br \/>\n<small>echo &quot;pm2 resurrect command executed on \u7b2c\u4e8c\u500b\u5e33\u865f&quot;<\/small><br \/>\n<small>fi<\/small><br \/>\n<small>exit<\/small><br \/>\n<small>EOF2<\/small><\/p>\n<p><small>done<\/small><\/p>\n<p><small>echo &quot;Script execution completed&quot;<\/small><\/p>\n<\/blockquote>\n<p>\u8f6c\u8f7d\u8bf7\u6ce8\u660e\uff1a<a href=\"https:\/\/keyi.eu.org\">\u5218\u592a\u76d1\u7684\u79c1\u85cf<\/a> &raquo; <a href=\"https:\/\/keyi.eu.org\/?p=912\">Serv00\u4fdd\u6d3b<\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>Serv00\u8981\u6c42\u6bcf90\u5929\uff0c\u5fc5\u9808\u5f9eWEB\u6216\u8005SSH\u767b\u9304\u4e00\u6b21\uff0c\u4f5c\u7232\u201c\u6d3b\u8e8d\u4f7f\u7528\u201d\u7684\u6a19\u8b58\uff0c\u5426\u5247\u6703\u522a\u9664\u88ab\u9592\u7f6e\u7684\u5e33\u865f\u3002 \u6211 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[4],"tags":[],"_links":{"self":[{"href":"https:\/\/keyi.eu.org\/index.php?rest_route=\/wp\/v2\/posts\/912"}],"collection":[{"href":"https:\/\/keyi.eu.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/keyi.eu.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/keyi.eu.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/keyi.eu.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=912"}],"version-history":[{"count":2,"href":"https:\/\/keyi.eu.org\/index.php?rest_route=\/wp\/v2\/posts\/912\/revisions"}],"predecessor-version":[{"id":915,"href":"https:\/\/keyi.eu.org\/index.php?rest_route=\/wp\/v2\/posts\/912\/revisions\/915"}],"wp:attachment":[{"href":"https:\/\/keyi.eu.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=912"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/keyi.eu.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=912"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/keyi.eu.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=912"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}