{"id":43928,"date":"2024-10-06T11:34:17","date_gmt":"2024-10-06T03:34:17","guid":{"rendered":"https:\/\/server.hk\/cnblog\/43928\/"},"modified":"2024-10-06T11:34:17","modified_gmt":"2024-10-06T03:34:17","slug":"centos-7-%e4%b8%ad%e5%ae%89%e8%a3%9d%e8%bc%95%e9%87%8f%e7%b4%9a%e9%81%8b%e7%b6%ad%e5%88%a9%e5%99%a8%ef%bc%9apssh","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/43928\/","title":{"rendered":"CentOS 7 \u4e2d\u5b89\u88dd\u8f15\u91cf\u7d1a\u904b\u7dad\u5229\u5668\uff1apssh"},"content":{"rendered":"<h1 id=\"centos-7-%e4%b8%ad%e5%ae%89%e8%a3%9d%e8%bc%95%e9%87%8f%e7%b4%9a%e9%81%8b%e7%b6%ad%e5%88%a9%e5%99%a8%ef%bc%9apssh-PflASmXkuc\">CentOS 7 \u4e2d\u5b89\u88dd\u8f15\u91cf\u7d1a\u904b\u7dad\u5229\u5668\uff1apssh<\/h1>\n<p>\u5728\u73fe\u4ee3\u7684\u4f3a\u670d\u5668\u7ba1\u7406\u4e2d\uff0c\u904b\u7dad\u4eba\u54e1\u7d93\u5e38\u9700\u8981\u540c\u6642\u5c0d\u591a\u53f0\u4f3a\u670d\u5668\u9032\u884c\u64cd\u4f5c\u3002\u9019\u6a23\u7684\u9700\u6c42\u4fc3\u4f7f\u4e86\u8a31\u591a\u5de5\u5177\u7684\u8a95\u751f\uff0c\u5176\u4e2d <strong>pssh<\/strong>\uff08Parallel SSH\uff09\u662f\u4e00\u500b\u8f15\u91cf\u7d1a\u4e14\u9ad8\u6548\u7684\u9078\u64c7\u3002\u672c\u6587\u5c07\u4ecb\u7d39\u5982\u4f55\u5728 CentOS 7 \u4e0a\u5b89\u88dd\u548c\u4f7f\u7528 pssh\uff0c\u5e6b\u52a9\u904b\u7dad\u4eba\u54e1\u63d0\u9ad8\u5de5\u4f5c\u6548\u7387\u3002<\/p>\n<h2 id=\"%e4%bb%80%e9%ba%bc%e6%98%af-pssh%ef%bc%9f-PflASmXkuc\">\u4ec0\u9ebc\u662f pssh\uff1f<\/h2>\n<p>pssh \u662f\u4e00\u500b\u7528\u65bc\u540c\u6642\u5728\u591a\u53f0\u4f3a\u670d\u5668\u4e0a\u57f7\u884c\u547d\u4ee4\u7684\u5de5\u5177\u3002\u5b83\u53ef\u4ee5\u901a\u904e SSH \u5354\u8b70\u9023\u63a5\u5230\u591a\u53f0\u4f3a\u670d\u5668\uff0c\u4e26\u5141\u8a31\u7528\u6236\u5728\u9019\u4e9b\u4f3a\u670d\u5668\u4e0a\u4e26\u884c\u57f7\u884c\u547d\u4ee4\u3002\u9019\u5c0d\u65bc\u9700\u8981\u5728\u591a\u53f0\u4f3a\u670d\u5668\u4e0a\u9032\u884c\u76f8\u540c\u64cd\u4f5c\u7684\u60c5\u6cc1\u7279\u5225\u6709\u7528\uff0c\u4f8b\u5982\u66f4\u65b0\u8edf\u4ef6\u3001\u91cd\u555f\u670d\u52d9\u7b49\u3002<\/p>\n<h2 id=\"%e5%ae%89%e8%a3%9d-pssh-PflASmXkuc\">\u5b89\u88dd pssh<\/h2>\n<p>\u5728 CentOS 7 \u4e0a\u5b89\u88dd pssh \u975e\u5e38\u7c21\u55ae\u3002\u4ee5\u4e0b\u662f\u5177\u9ad4\u6b65\u9a5f\uff1a<\/p>\n<pre><code>sudo yum install pssh<\/code><\/pre>\n<p>\u9019\u689d\u547d\u4ee4\u5c07\u6703\u5f9e CentOS \u7684\u5b98\u65b9\u8edf\u4ef6\u5eab\u4e2d\u4e0b\u8f09\u4e26\u5b89\u88dd pssh\u3002\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6aa2\u67e5 pssh \u662f\u5426\u5b89\u88dd\u6210\u529f\uff1a<\/p>\n<pre><code>pssh -V<\/code><\/pre>\n<p>\u5982\u679c\u5b89\u88dd\u6210\u529f\uff0c\u60a8\u5c07\u770b\u5230 pssh \u7684\u7248\u672c\u865f\u3002<\/p>\n<h2 id=\"%e4%bd%bf%e7%94%a8-pssh-PflASmXkuc\">\u4f7f\u7528 pssh<\/h2>\n<p>pssh \u7684\u57fa\u672c\u7528\u6cd5\u662f\u901a\u904e\u4e00\u500b\u5305\u542b\u4f3a\u670d\u5668\u5730\u5740\u7684\u6587\u4ef6\u4f86\u6307\u5b9a\u8981\u9023\u63a5\u7684\u4f3a\u670d\u5668\u3002\u9996\u5148\uff0c\u60a8\u9700\u8981\u5275\u5efa\u4e00\u500b\u6587\u672c\u6587\u4ef6\uff0c\u5c07\u6240\u6709\u4f3a\u670d\u5668\u7684 IP \u5730\u5740\u6216\u4e3b\u6a5f\u540d\u5217\u51fa\uff0c\u6bcf\u884c\u4e00\u500b\u3002\u4f8b\u5982\uff0c\u5275\u5efa\u4e00\u500b\u540d\u70ba <strong>hosts.txt<\/strong> \u7684\u6587\u4ef6\uff1a<\/p>\n<pre><code>192.168.1.1\n192.168.1.2\n192.168.1.3<\/code><\/pre>\n<p>\u63a5\u4e0b\u4f86\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5728\u6240\u6709\u4f3a\u670d\u5668\u4e0a\u57f7\u884c\u4e00\u500b\u7c21\u55ae\u7684\u547d\u4ee4\uff0c\u4f8b\u5982\u6aa2\u67e5\u7cfb\u7d71\u6642\u9593\uff1a<\/p>\n<pre><code>pssh -h hosts.txt -i date<\/code><\/pre>\n<p>\u9019\u689d\u547d\u4ee4\u6703\u5728 <strong>hosts.txt<\/strong> \u4e2d\u5217\u51fa\u7684\u6240\u6709\u4f3a\u670d\u5668\u4e0a\u57f7\u884c <code>date<\/code> \u547d\u4ee4\uff0c\u4e26\u986f\u793a\u6bcf\u53f0\u4f3a\u670d\u5668\u7684\u8f38\u51fa\u3002<\/p>\n<h2 id=\"pssh-%e7%9a%84%e5%85%b6%e4%bb%96%e5%8a%9f%e8%83%bd-PflASmXkuc\">pssh \u7684\u5176\u4ed6\u529f\u80fd<\/h2>\n<p>pssh \u9084\u63d0\u4f9b\u4e86\u4e00\u4e9b\u5176\u4ed6\u6709\u7528\u7684\u529f\u80fd\uff0c\u4f8b\u5982\uff1a<\/p>\n<ul>\n<li><strong>-i<\/strong>\uff1a\u986f\u793a\u6bcf\u53f0\u4f3a\u670d\u5668\u7684\u8f38\u51fa\u3002<\/li>\n<li><strong>-p<\/strong>\uff1a\u8a2d\u7f6e\u540c\u6642\u57f7\u884c\u7684\u6700\u5927\u4f3a\u670d\u5668\u6578\u91cf\u3002<\/li>\n<li><strong>-l<\/strong>\uff1a\u6307\u5b9a\u7528\u6236\u540d\uff0c\u65b9\u4fbf\u5728\u591a\u53f0\u4f3a\u670d\u5668\u4e0a\u4f7f\u7528\u76f8\u540c\u7684\u7528\u6236\u540d\u9032\u884c\u767b\u9304\u3002<\/li>\n<li><strong>-A<\/strong>\uff1a\u4f7f\u7528 SSH \u5bc6\u78bc\u9032\u884c\u8eab\u4efd\u9a57\u8b49\u3002<\/li>\n<\/ul>\n<p>\u4f8b\u5982\uff0c\u5982\u679c\u60a8\u60f3\u8981\u5728\u6700\u591a 5 \u53f0\u4f3a\u670d\u5668\u4e0a\u540c\u6642\u57f7\u884c\u547d\u4ee4\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code>pssh -h hosts.txt -p 5 -i uptime<\/code><\/pre>\n<h2 id=\"%e7%b8%bd%e7%b5%90-PflASmXkuc\">\u7e3d\u7d50<\/h2>\n<p>pssh \u662f\u4e00\u500b\u5f37\u5927\u4e14\u9748\u6d3b\u7684\u5de5\u5177\uff0c\u80fd\u5920\u5e6b\u52a9\u904b\u7dad\u4eba\u54e1\u9ad8\u6548\u5730\u7ba1\u7406\u591a\u53f0\u4f3a\u670d\u5668\u3002\u901a\u904e\u7c21\u55ae\u7684\u5b89\u88dd\u548c\u6613\u65bc\u4f7f\u7528\u7684\u547d\u4ee4\uff0cpssh \u53ef\u4ee5\u986f\u8457\u63d0\u9ad8\u65e5\u5e38\u904b\u7dad\u5de5\u4f5c\u7684\u6548\u7387\u3002\u5982\u679c\u60a8\u6b63\u5728\u5c0b\u627e\u4e00\u500b\u53ef\u9760\u7684 <a href=\"https:\/\/server.hk\">VPS<\/a> \u89e3\u6c7a\u65b9\u6848\u4f86\u904b\u884c\u60a8\u7684\u4f3a\u670d\u5668\uff0cServer.HK \u63d0\u4f9b\u591a\u7a2e\u9078\u64c7\uff0c\u6eff\u8db3\u4e0d\u540c\u9700\u6c42\u3002\u7121\u8ad6\u662f <a href=\"https:\/\/server.hk\">\u9999\u6e2f\u4f3a\u670d\u5668<\/a> \u9084\u662f\u5176\u4ed6\u5730\u5340\u7684\u670d\u52d9\uff0cServer.HK \u90fd\u80fd\u70ba\u60a8\u63d0\u4f9b\u7a69\u5b9a\u7684\u652f\u6301\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b78\u7fd2\u5982\u4f55\u5728 CentOS 7 \u4e0a\u5b89\u88dd\u8f15\u91cf\u7d1a\u904b\u7dad\u5de5\u5177 pssh\uff0c\u63d0\u5347\u591a\u4f3a\u670d\u5668\u7ba1\u7406\u6548\u7387\uff0c\u7c21\u5316\u6279\u91cf\u64cd\u4f5c\u6d41\u7a0b\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4924],"tags":[],"class_list":["post-43928","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43928","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=43928"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43928\/revisions"}],"predecessor-version":[{"id":43929,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43928\/revisions\/43929"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=43928"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=43928"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=43928"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}