{"id":19573,"date":"2017-05-26T06:13:03","date_gmt":"2017-05-25T22:13:03","guid":{"rendered":"https:\/\/2blog.ilc.edu.tw\/25793\/2017\/05\/26\/ssh-server-%e4%bd%bf%e7%94%a8-pssh-%e4%b8%80%e6%ac%a1%e5%90%8c%e6%99%82%e6%93%8d%e6%8e%a7%e5%a4%9a%e5%8f%b0-server\/"},"modified":"2021-03-18T17:25:02","modified_gmt":"2021-03-18T09:25:02","slug":"ssh-server-%e4%bd%bf%e7%94%a8-pssh-%e4%b8%80%e6%ac%a1%e5%90%8c%e6%99%82%e6%93%8d%e6%8e%a7%e5%a4%9a%e5%8f%b0-server","status":"publish","type":"post","link":"https:\/\/2blog.ilc.edu.tw\/25793\/2017\/05\/26\/ssh-server-%e4%bd%bf%e7%94%a8-pssh-%e4%b8%80%e6%ac%a1%e5%90%8c%e6%99%82%e6%93%8d%e6%8e%a7%e5%a4%9a%e5%8f%b0-server\/","title":{"rendered":"SSH Server &#8211; \u4f7f\u7528 pssh \u4e00\u6b21\u540c\u6642\u64cd\u63a7\u591a\u53f0 Server"},"content":{"rendered":"<p>\u53c3\u8003\u7db2\u9801\uff1a <br \/><a href=\"https:\/\/www.server-world.info\/en\/note?os=CentOS_7&amp;p=ssh&amp;f=9\" target=\"_blank\" rel=\"noopener noreferrer\">CentOS 7 : SSH Server : Use Parallel SSH : Server World<\/a> <\/p>\n<p>\u5982\u679c\u6709\u591a\u53f0 Server \u8981\u67e5\u770b\u6216\u9032\u884c\u8a2d\u5b9a\uff0c\u53ef\u4ee5\u8003\u616e\u4f7f\u7528 pssh\u3002 <br \/>\u4f7f\u7528\u9650\u5236\uff1a <br \/>\u9019\u5e7e\u53f0 Server \u7684\u5bc6\u78bc\u8981\u4e00\u6a23\uff0c\u6216\u662f\u5148\u597d <a href=\"http:\/\/blog.ilc.edu.tw\/blog\/blog\/25793\/post\/78484\/688203\" target=\"_blank\" rel=\"noopener noreferrer\">\u982d\u57ce\u570b\u5c0f\u8cc7\u8a0a\u7d44 | \u514d\u5bc6\u78bc\u767b\u5165 SSH Server<\/a> \u7684\u8a2d\u5b9a\u3002 <\/p>\n<p>1. \u5b89\u88dd pssh <br \/># <span style=\"color: #ff0000\">yum install pssh &#8211;enablerepo=epel<\/span> <\/p>\n<p>2. \u67e5\u770b <span style=\"color: #0000ff\">192.168.1.9<\/span> \/ <span style=\"color: #0000ff\">192.168.1.10<\/span> \u7684\u958b\u6a5f\u6642\u9593 <br \/><span style=\"color: #0000ff\">-H \u8981\u64cd\u4f5c\u7684\u4e3b\u6a5f <\/span><br \/><span style=\"color: #0000ff\">-i \u8981\u57f7\u884c\u7684\u547d\u4ee4<\/span> <br \/># <span style=\"color: #ff0000\">pssh -H &#8220;192.168.1.9 192.168.1.10&#8221; -i &#8220;uptime&#8221;<\/span> <br \/><span style=\"color: #0000ff\">[1] 11:19:10 [FAILURE] 192.168.1.10 Exited with error code 255 <\/span><br \/><span style=\"color: #0000ff\">Stderr: pssh error: SSH requested a password. Please create SSH keys or use <\/span><br \/><span style=\"color: #0000ff\">the -A option to provide a password. <\/span><br \/><span style=\"color: #0000ff\">Permission denied (publickey,password). <\/span><br \/><span style=\"color: #0000ff\">[2] 11:19:20 [FAILURE] 192.168.1.9 Exited with error code 255 <\/span><br \/><span style=\"color: #0000ff\">Stderr: pssh error: SSH requested a password. Please create SSH keys or use <\/span><br \/><span style=\"color: #0000ff\">the -A option to provide a password. <\/span><br \/><span style=\"color: #0000ff\">Permission denied (publickey,password).<\/span> <\/p>\n<p>\u4e0a\u9762\u63d0\u793a\u9700\u8981\u8f38\u5165\u5bc6\u78bc\uff0c\u53ef\u4ee5\u4f7f\u7528 <span style=\"color: #ff0000\">-A<\/span> \u53c3\u6578[@more@]3. \u52a0\u4e0a <span style=\"color: #ff0000\">-A<\/span> \u53c3\u6578 <br \/># <span style=\"color: #ff0000\">pssh -A -H &#8220;192.168.1.9 192.168.1.10&#8221; -i &#8220;uptime&#8221;<\/span> <br \/><span style=\"color: #0000ff\">Warning: do not enter your password if anyone else has superuser <\/span><br \/><span style=\"color: #0000ff\">privileges or access to your account. <\/span><br \/><span style=\"color: #0000ff\">Password: <\/span><br \/><span style=\"color: #0000ff\">[1] 11:24:20 [SUCCESS] 192.168.1.9 <\/span><br \/><span style=\"color: #0000ff\"> 11:24:20 up 13 days, 16:43, 2 users, load average: 0.57, 0.48, 0.47 <\/span><br \/><span style=\"color: #0000ff\">[2] 11:24:20 [SUCCESS] 192.168.1.10 <\/span><br \/><span style=\"color: #0000ff\"> 11:24:20 up 4 days, 20:20, 0 users, load average: 0.02, 0.06, 0.07<\/span> <\/p>\n<p>4. \u5982\u679c\u4e8c\u53f0\u5bc6\u78bc\u4e0d\u76f8\u540c\uff0c\u5c31\u8981\u4f7f\u7528 ssh key \u7684\u65b9\u5f0f\u4f86\u8655\u7406 <br \/># <span style=\"color: #ff0000\">pssh -A -H &#8220;192.168.1.99 192.168.1.8&#8221; -i &#8220;uptime&#8221;<\/span> <br \/><span style=\"color: #0000ff\">Warning: do not enter your password if anyone else has superuser <\/span><br \/><span style=\"color: #0000ff\">privileges or access to your account. <\/span><br \/><span style=\"color: #0000ff\">Password: <\/span><br \/><span style=\"color: #0000ff\">[1] 11:26:18 [SUCCESS] 192.168.1.99 <\/span><br \/><span style=\"color: #0000ff\"> 11:26:18 up 13 days, 16:45, 2 users, load average: 0.29, 0.39, 0.44 <\/span><br \/><span style=\"color: #0000ff\">[2] 11:26:20 [FAILURE] 192.168.1.8 Exited with error code 255 <\/span><br \/><span style=\"color: #0000ff\">Stderr: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).<\/span> <\/p>\n<p>5. \u5c07\u8981\u9023\u7dda\u7684 Server \u6e05\u55ae\u653e\u5728\u6a94\u6848\u4e4b\u4e2d <br \/># <span style=\"color: #ff0000\">cat pssh_hosts.txt<\/span> <br \/><span style=\"color: #0000ff\">root@192.168.1.9 <\/span><br \/><span style=\"color: #0000ff\">root@192.168.1.10<\/span> <br \/># <span style=\"color: #ff0000\">pssh -A -h pssh_hosts.txt -i &#8220;uptime&#8221;<\/span> <br \/><span style=\"color: #0000ff\">Warning: do not enter your password if anyone else has superuser <\/span><br \/><span style=\"color: #0000ff\">privileges or access to your account. <\/span><br \/><span style=\"color: #0000ff\">Password: <\/span><br \/><span style=\"color: #0000ff\">[1] 11:24:20 [SUCCESS] 192.168.1.9 <\/span><br \/><span style=\"color: #0000ff\"> 11:24:20 up 13 days, 16:43, 2 users, load average: 0.57, 0.48, 0.47 <\/span><br \/><span style=\"color: #0000ff\">[2] 11:24:20 [SUCCESS] 192.168.1.10 <\/span><br \/><span style=\"color: #0000ff\"> 11:24:20 up 4 days, 20:20, 0 users, load average: 0.02, 0.06, 0.07<\/span> <\/p>\n<p>6. \u66f4\u591a\u7684\u53c3\u6578 <br \/># <span style=\"color: #ff0000\">pssh &#8211;help<\/span> <br \/><span style=\"color: #0000ff\">Usage: pssh [OPTIONS] command [&#8230;]<\/span> <\/p>\n<p><span style=\"color: #0000ff\">Options:<\/span> <br \/><span style=\"color: #0000ff\"> &#8211;version show program&#8217;s version number and exit<\/span> <br \/><span style=\"color: #0000ff\"> &#8211;help show this help message and exit<\/span> <br \/><span style=\"color: #0000ff\"> -h HOST_FILE, &#8211;hosts=HOST_FILE<\/span> <br \/><span style=\"color: #0000ff\"> hosts file (each line &#8220;[user@]host[:port]&#8221;)<\/span> <br \/><span style=\"color: #0000ff\"> -H HOST_STRING, &#8211;host=HOST_STRING<\/span> <br \/><span style=\"color: #0000ff\"> additional host entries (&#8220;[user@]host[:port]&#8221;)<\/span> <br \/><span style=\"color: #0000ff\"> -l USER, &#8211;user=USER username (OPTIONAL)<\/span> <br \/><span style=\"color: #0000ff\"> -p PAR, &#8211;par=PAR max number of parallel threads (OPTIONAL)<\/span> <br \/><span style=\"color: #0000ff\"> -o OUTDIR, &#8211;outdir=OUTDIR<\/span> <br \/><span style=\"color: #0000ff\"> output directory for stdout files (OPTIONAL)<\/span> <br \/><span style=\"color: #0000ff\"> -e ERRDIR, &#8211;errdir=ERRDIR<\/span> <br \/><span style=\"color: #0000ff\"> output directory for stderr files (OPTIONAL)<\/span> <br \/><span style=\"color: #0000ff\"> -t TIMEOUT, &#8211;timeout=TIMEOUT<\/span> <br \/><span style=\"color: #0000ff\"> timeout (secs) (0 = no timeout) per host (OPTIONAL)<\/span> <br \/><span style=\"color: #0000ff\"> -O OPTION, &#8211;option=OPTION<\/span> <br \/><span style=\"color: #0000ff\"> SSH option (OPTIONAL)<\/span> <br \/><span style=\"color: #0000ff\"> -v, &#8211;verbose turn on warning and diagnostic messages (OPTIONAL)<\/span> <br \/><span style=\"color: #0000ff\"> -A, &#8211;askpass Ask for a password (OPTIONAL)<\/span> <br \/><span style=\"color: #0000ff\"> -x ARGS, &#8211;extra-args=ARGS<\/span> <br \/><span style=\"color: #0000ff\"> Extra command-line arguments, with processing for<\/span> <br \/><span style=\"color: #0000ff\"> spaces, quotes, and backslashes<\/span> <br \/><span style=\"color: #0000ff\"> -X ARG, &#8211;extra-arg=ARG<\/span> <br \/><span style=\"color: #0000ff\"> Extra command-line argument<\/span> <br \/><span style=\"color: #0000ff\"> -i, &#8211;inline inline aggregated output and error for each server<\/span> <br \/><span style=\"color: #0000ff\"> &#8211;inline-stdout inline standard output for each server<\/span> <br \/><span style=\"color: #0000ff\"> -I, &#8211;send-input read from standard input and send as input to ssh<\/span> <br \/><span style=\"color: #0000ff\"> -P, &#8211;print print output as we get it<\/span> <\/p>\n<p><span style=\"color: #0000ff\">Example: pssh -h hosts.txt -l irb2 -o \/tmp\/foo uptime<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u53c3\u8003\u7db2\u9801\uff1a CentOS 7 : SSH Server : Use Parallel SSH : Server &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/2blog.ilc.edu.tw\/25793\/2017\/05\/26\/ssh-server-%e4%bd%bf%e7%94%a8-pssh-%e4%b8%80%e6%ac%a1%e5%90%8c%e6%99%82%e6%93%8d%e6%8e%a7%e5%a4%9a%e5%8f%b0-server\/\" class=\"more-link\">\u95b1\u8b80\u5168\u6587<span class=\"screen-reader-text\">\u3008SSH Server &#8211; \u4f7f\u7528 pssh \u4e00\u6b21\u540c\u6642\u64cd\u63a7\u591a\u53f0 Server\u3009<\/span><\/a><\/p>\n","protected":false},"author":55,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[117,139],"tags":[],"class_list":["post-19573","post","type-post","status-publish","format-standard","hentry","category-c-78462","category-c-78484"],"meta_key":{"_pingme":["1"],"_encloseme":["1"],"lt_post_id":["688384"]},"_links":{"self":[{"href":"https:\/\/2blog.ilc.edu.tw\/25793\/wp-json\/wp\/v2\/posts\/19573"}],"collection":[{"href":"https:\/\/2blog.ilc.edu.tw\/25793\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/2blog.ilc.edu.tw\/25793\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/2blog.ilc.edu.tw\/25793\/wp-json\/wp\/v2\/users\/55"}],"replies":[{"embeddable":true,"href":"https:\/\/2blog.ilc.edu.tw\/25793\/wp-json\/wp\/v2\/comments?post=19573"}],"version-history":[{"count":1,"href":"https:\/\/2blog.ilc.edu.tw\/25793\/wp-json\/wp\/v2\/posts\/19573\/revisions"}],"predecessor-version":[{"id":21081,"href":"https:\/\/2blog.ilc.edu.tw\/25793\/wp-json\/wp\/v2\/posts\/19573\/revisions\/21081"}],"wp:attachment":[{"href":"https:\/\/2blog.ilc.edu.tw\/25793\/wp-json\/wp\/v2\/media?parent=19573"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/2blog.ilc.edu.tw\/25793\/wp-json\/wp\/v2\/categories?post=19573"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/2blog.ilc.edu.tw\/25793\/wp-json\/wp\/v2\/tags?post=19573"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}