{"id":8119,"date":"2020-07-18T20:50:33","date_gmt":"2020-07-18T12:50:33","guid":{"rendered":"https:\/\/www.linuxcool.com\/?p=8119"},"modified":"2020-07-18T20:50:35","modified_gmt":"2020-07-18T12:50:35","slug":"sshpass","status":"publish","type":"post","link":"https:\/\/www.linuxcool.com\/sshpass","title":{"rendered":"sshpass\u547d\u4ee4 – \u7528\u4e8e\u975e\u4ea4\u4e92\u7684ssh \u5bc6\u7801\u9a8c\u8bc1"},"content":{"rendered":"\n
sshpass\u547d\u4ee4\u7528\u4e8e\u975e\u4ea4\u4e92\u7684 ssh \u5bc6\u7801\u9a8c\u8bc1\u3002\u53ef\u4ee5\u5728\u547d\u4ee4\u884c\u76f4\u63a5\u4f7f\u7528\u5bc6\u7801\u6765\u8fdb\u884c\u8fdc\u7a0b\u8fde\u63a5\u548c\u8fdc\u7a0b\u62c9\u53d6\u6587\u4ef6\u3002\u4f7f\u7528\u524d\u63d0\uff1a\u5bf9\u4e8e\u672a\u8fde\u63a5\u8fc7\u7684\u4e3b\u673a\u3002\u800c\u53c8\u4e0d\u8f93\u5165yes\u8fdb\u884c\u786e\u8ba4\uff0c\u9700\u8981\u8fdb\u884csshd\u670d\u52a1\u7684\u4f18\u5316\u3002<\/p>\n\n\n\n
\u8bed\u6cd5\u683c\u5f0f\uff1a<\/strong>sshpass [\u53c2\u6570]<\/p>\n\n\n\n \u5e38\u7528\u53c2\u6570\uff1a<\/strong><\/p>\n\n\n\n \u53c2\u8003\u5b9e\u4f8b<\/strong><\/p>\n\n\n\n \u5b89\u88c5sshpass\uff1a<\/p>\n\n\n\n \u57fa\u672c\u4f7f\u7528\u65b9\u6cd5\uff1a<\/p>\n\n\n\n \u5f53\u8fdc\u7a0b\u4e3b\u673a\u7aef\u53e3\u4e0d\u518d\u662f22\u9ed8\u8ba4\u7aef\u53e3\u65f6\u5019\uff1a<\/p>\n\n\n\n \u76f4\u63a5\u8fdc\u7a0b\u8fde\u63a5\u67d0\u53f0\u4e3b\u673a\uff1a<\/p>\n\n\n\n \u672c\u5730\u6267\u884c\u8fdc\u7a0b\u673a\u5668\u7684\u547d\u4ee4\uff1a<\/p>\n\n\n\n \u8fdc\u7a0b\u8fde\u63a5\u6307\u5b9assh\u7684\u7aef\u53e3\uff1a<\/p>\n\n\n\n \u4ece\u5bc6\u7801\u6587\u4ef6\u8bfb\u53d6\u6587\u4ef6\u5185\u5bb9\u4f5c\u4e3a\u5bc6\u7801\u53bb\u8fdc\u7a0b\u8fde\u63a5\u4e3b\u673a\uff1a<\/p>\n\n\n\n \u4ece\u8fdc\u7a0b\u4e3b\u673a\u4e0a\u62c9\u53d6\u6587\u4ef6\u5230\u672c\u5730\uff1a<\/p>\n\n\n\n sshpass\u547d\u4ee4\u7528\u4e8e\u975e\u4ea4\u4e92\u7684 ssh \u5bc6\u7801\u9a8c\u8bc1\u3002\u53ef\u4ee5\u5728\u547d\u4ee4\u884c\u76f4\u63a5\u4f7f\u7528\u5bc6\u7801\u6765\u8fdb\u884c\u8fdc\u7a0b\u8fde\u63a5\u548c\u8fdc\u7a0b\u62c9\u53d6\u6587\u4ef6\u3002\u4f7f\u7528\u524d […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[11],"tags":[],"_links":{"self":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/8119"}],"collection":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/comments?post=8119"}],"version-history":[{"count":3,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/8119\/revisions"}],"predecessor-version":[{"id":8365,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/8119\/revisions\/8365"}],"wp:attachment":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/media?parent=8119"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/categories?post=8119"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/tags?post=8119"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}-p<\/td> \u6307\u5b9a\u5bc6\u7801<\/td><\/tr> -f<\/td> \u6307\u5b9a\u6587\u4ef6<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n [root@linuxcool ~]# yum install -y epel-release\n[root@linuxcool ~]# yum install -y sshpass\n[root@linuxcool ~]# sshpass -V<\/pre>\n\n\n\n
[root@linuxcool ~]# sshpass -p \"password\" ssh username@ip<\/pre>\n\n\n\n
[root@linuxcool ~]# sshpass -p \"password\" ssh -p 8443 username@ip<\/pre>\n\n\n\n
[root@linuxcool ~]# sshpass -p xxx ssh root@192.168.11.11<\/pre>\n\n\n\n
[root@linuxcool ~]# sshpass -p xxx ssh root@192.168.11.11 \"ethtool eth0\"<\/pre>\n\n\n\n
[root@linuxcool ~]# sshpass -p 123456 ssh -p 1000 root@192.168.11.11<\/pre>\n\n\n\n
[root@linuxcool ~]# sshpass -f xxx.txt ssh root@192.168.11.11<\/pre>\n\n\n\n
[root@linuxcool ~]# sshpass -p '123456' scp root@host_ip:\/home\/test\/t .\/tmp\/<\/pre>\n","protected":false},"excerpt":{"rendered":"