{"id":184781,"date":"2020-10-26T18:12:38","date_gmt":"2020-10-26T10:12:38","guid":{"rendered":"http:\/\/4563.org\/?p=184781"},"modified":"2020-10-26T18:12:38","modified_gmt":"2020-10-26T10:12:38","slug":"macos-%e5%ae%89%e8%a3%85-sshpass","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=184781","title":{"rendered":"macOS \u5b89\u88c5 sshpass"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  macOS \u5b89\u88c5 sshpass               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : wsgzao <\/span>  <span><i><\/i> 5<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<h2>\u524d\u8a00<\/h2>\n<p>sshpass \u662f ansible \u5bc6\u7801\u8f93\u5165\u7684\u5fc5\u8981\u6761\u4ef6\uff0c\u5728 Linux \u4e2d\u4f7f\u7528<code>yum install sshpass<\/code>\u6216\u8005<code>apt-get install sshpass<\/code>\u90fd\u53ef\u4ee5\u8f7b\u677e\u5b89\u88c5\uff0c\u4f46\u5728 macOS \u65b0\u7248\u672c\u4e2d\u7531\u4e8e\u5b89\u5168\u539f\u56e0\u65e0\u6cd5\u76f4\u63a5\u4f7f\u7528<code>brew install sshpass<\/code>\uff0c\u9700\u8981\u91c7\u7528\u5176\u5b83\u5b89\u5168\u7684\u529e\u6cd5\u7ed5\u8fc7\u3002<\/p>\n<h2>\u66f4\u65b0\u5386\u53f2<\/h2>\n<p>2020 \u5e74 10 \u6708 13 \u65e5 &#8211; \u521d\u7a3f<\/p>\n<p>\u9605\u8bfb\u539f\u6587 &#8211; https:\/\/wsgzao.github.io\/post\/sshpass\/<\/p>\n<h2>\u4f7f\u7528 sshpass \u7684\u573a\u666f<\/h2>\n<p>\u5728 macOS \u4e0b\u4f7f\u7528 ansible \u547d\u4ee4(inventory \u6587\u4ef6\u4e2d\u4f7f\u7528\u4e86\u5bc6\u7801\u9a8c\u8bc1\u7684\u65b9\u5f0f)\u6216\u8005\u4f7f\u7528 iTerm2 \u6765\u5b8c\u6210\u81ea\u52a8\u5bc6\u7801\u586b\u5145\u7b49\u573a\u666f\u4f1a\u4f7f\u7528\u5230 sshpass \u3002<\/p>\n<p>\u6bd4\u5982\u4e0b\u9762\u7684\u6837\u4f8b\uff1aInventory \u6587\u4ef6\u4e2d\u4f7f\u7528\u4e86<code>ansible_ssh_pass<\/code>\u9009\u9879<\/p>\n<pre><code># \u7f16\u8f91 inventory cat hosts 10.10.66.66 ansible_port=22 ansible_user=root ansible_ssh_pass=test666  # \u4f7f\u7528 ansible \u547d\u4ee4\u4f1a\u5931\u8d25\uff0c\u63d0\u793a\u7f3a\u5c11 sshpass ansible all -i test.hosts  -m ping 10.10.66.66 | FAILED! =&gt; {     \"failed\": true,     \"msg\": \"to use the 'ssh' connection type with passwords, you must install the sshpass program\" }  <\/code><\/pre>\n<h2>\u5b89\u88c5 sshpass \u53ca\u5404\u79cd\u5e38\u89c1\u5c0f\u95ee\u9898\u5904\u7406<\/h2>\n<p>\u76f4\u63a5<code>brew install<\/code>\u4f1a\u63d0\u793a\u4e0d\u5b89\u5168\uff0c\u88ab\u62d2\u7edd\uff0c<code>brew install --force<\/code>\u5f3a\u5236\u5b89\u88c5\u4e5f\u4e0d\u884c<\/p>\n<pre><code>brew install sshpass -f Updating Homebrew... Error: No available formula with the name \"sshpass\" We won't add sshpass because it makes it too easy for novice SSH users to ruin SSH's security.   <\/code><\/pre>\n<p>\u53ef\u4ee5\u901a\u8fc7\u4e0b\u9762\u7684\u547d\u4ee4\u8fdb\u884c\u5b89\u88c5<\/p>\n<pre><code>brew install https:\/\/raw.githubusercontent.com\/kadwanev\/bigboybrew\/master\/Library\/Formula\/sshpass.rb  Error: Calling Non-checksummed download of sshpass formula file from an arbitrary URL is disabled! Use 'brew extract' or 'brew create' and 'brew tap-new' to create a formula file in a tap on GitHub instead.  # \u51fa\u73b0\u4e0a\u8ff0\u62a5\u9519\u53ef\u4ee5\u4e0b\u8f7d\u81f3\u672c\u5730\u518d\u6b21\u6267\u884c\u5b89\u88c5 wget https:\/\/raw.githubusercontent.com\/kadwanev\/bigboybrew\/master\/Library\/Formula\/sshpass.rb brew install sshpass.rb <\/code><\/pre>\n<p>sshpass.rb \u6587\u4ef6\u5185\u5bb9<\/p>\n<pre><code>require 'formula'  class Sshpass &lt; Formula   url 'http:\/\/sourceforge.net\/projects\/sshpass\/files\/sshpass\/1.06\/sshpass-1.06.tar.gz'   homepage 'http:\/\/sourceforge.net\/projects\/sshpass'   sha256 'c6324fcee608b99a58f9870157dfa754837f8c48be3df0f5e2f3accf145dee60'    def install     system \".\/configure\", \"--disable-debug\", \"--disable-dependency-tracking\",                           \"--prefix=#{prefix}\"     system \"make install\"   end    def test     system \"sshpass\"   end end  <\/code><\/pre>\n<p>\u5982\u679c(\u56e0\u4e3a\u4f17\u6240\u5468\u77e5\u7684\u7f51\u7edc\u539f\u56e0)\u901a\u8fc7<code>brew install https:\/\/raw.githubusercontent.com\/kadwanev\/bigboybrew\/master\/Library\/Formula\/sshpass.rb<\/code>\u7684\u65b9\u5f0f\u4e0d\u80fd\u6b63\u5e38\u5de5\u4f5c\uff0c\u53ef\u4ee5\u5c06\u4e0a\u9762 rubby \u811a\u672c<code>sshpass.rb<\/code>\u7684\u5185\u5bb9\u62f7\u8d1d\u5230\u672c\u5730\u6267\u884c <code>brew install sshpass.rb<\/code><\/p>\n<p>\u518d\u6b21\u5c1d\u8bd5\u5b89\u88c5\u63d0\u793a\u7f3a\u5c11<code>xcode-select<\/code>\u547d\u4ee4\u884c\u5de5\u5177\uff0c\u53ef\u4ee5\u901a\u8fc7<code>xcode-select --install<\/code>\u8fdb\u884c\u5b89\u88c5<\/p>\n<pre><code>brew install sshpass.rb Error: Xcode alone is not sufficient on Mojave. Install the Command Line Tools:   xcode-select --install  xcode-select --install xcode-select: note: install requested for command line developer tools  <\/code><\/pre>\n<p>\u5b89\u88c5\u5b8c<code>xcode-select<\/code>\u4e4b\u540e\u91cd\u65b0\u6267\u884c<code>brew install<\/code>\u547d\u4ee4\uff0c<code>sshpass<\/code>\u5b89\u88c5\u6210\u529f\u3002<\/p>\n<pre><code>brew install sshpass.rb Updating Homebrew... ==&gt; Downloading http:\/\/sourceforge.net\/projects\/sshpass\/files\/sshpass\/1.06\/sshpass-1.06.tar.gz ==&gt; Downloading from https:\/\/jaist.dl.sourceforge.net\/project\/sshpass\/sshpass\/1.06\/sshpass-1.06.tar.g ######################################################################## 100.0% ==&gt; .\/configure --prefix=\/usr\/local\/Cellar\/sshpass\/1.06 ==&gt; make install       <\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>5<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"3979694\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : cz5424 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u611f\u8c22\u4e3b\u5206\u4eab\uff0c\u4f46\u662f\u8fd8\u662f\u79c1\u94a5\u767b\u5f55\u6bd4\u8f83\u9999                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3979695\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : justsosososo <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             CRT \u4e0d\u9999\u4e48                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3979696\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Keyes <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             sshpss \u8fd9\u79cd\u9b54\u9b3c\u5de5\u5177\u5e94\u8be5\u88ab\u5168\u7403 rm -rf                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3979697\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : bluehtt <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @justsosososo #2 \u4e0d\u9999\u3002\u9996\u5148\u662f\u4ed8\u8d39\u8f6f\u4ef6\uff0c\u5176\u6b21\u4e0d\u80fd\u901a\u8fc7\u7ec8\u7aef\u547d\u4ee4\u64cd\u4f5c                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3979698\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : tairan2006 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e00\u822c ssh-copy-id \u4e0d\u5c31\u591f\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>macOS \u5b89\u88c5 sshpass &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/184781"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=184781"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/184781\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=184781"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=184781"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=184781"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}