前言
sshpass是ansible明码输出的必要条件,在Linux中应用yum install sshpass
或者apt-get install sshpass
都能够轻松装置,但在macOS新版本中因为平安起因无奈间接应用brew install sshpass
,须要采纳其它平安的方法绕过。
更新历史
2020年10月13日 - 初稿
浏览原文 - https://wsgzao.github.io/post...
应用sshpass的场景
在macOS下应用ansible命令(inventory文件中应用了明码验证的形式)或者应用iTerm2来实现主动明码填充等场景会应用到sshpass。
比方上面的样例:Inventory文件中应用了ansible_ssh_pass
选项
# 编辑inventorycat hosts10.10.66.66 ansible_port=22 ansible_user=root ansible_ssh_pass=test666# 应用ansible命令会失败,提醒短少sshpassansible all -i test.hosts -m ping10.10.66.66 | FAILED! => { "failed": true, "msg": "to use the 'ssh' connection type with passwords, you must install the sshpass program"}
装置sshpass及各种常见小问题解决
间接brew install
会提醒不平安,被回绝,brew install --force
强制装置也不行
brew install sshpass -fUpdating Homebrew...Error: No available formula with the name "sshpass"We won't add sshpass because it makes it too easy for novice SSH users toruin SSH's security.
能够通过上面的命令进行装置
brew install https://raw.githubusercontent.com/kadwanev/bigboybrew/master/Library/Formula/sshpass.rbError: 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.# 呈现上述报错能够下载至本地再次执行装置wget https://raw.githubusercontent.com/kadwanev/bigboybrew/master/Library/Formula/sshpass.rbbrew install sshpass.rb
sshpass.rb文件内容
require 'formula'class Sshpass < 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" endend
如果(因为家喻户晓的网络起因)通过brew install https://raw.githubusercontent.com/kadwanev/bigboybrew/master/Library/Formula/sshpass.rb
的形式不能失常工作,能够将下面rubby脚本sshpass.rb
的内容拷贝到本地执行 brew install sshpass.rb
再次尝试装置提醒短少xcode-select
命令行工具,能够通过xcode-select --install
进行装置
brew install sshpass.rbError: Xcode alone is not sufficient on Mojave.Install the Command Line Tools: xcode-select --installxcode-select --installxcode-select: note: install requested for command line developer tools
装置完xcode-select
之后从新执行brew install
命令,sshpass
装置胜利。
brew install sshpass.rbUpdating Homebrew...==> Downloading http://sourceforge.net/projects/sshpass/files/sshpass/1.06/sshpass-1.06.tar.gz==> Downloading from https://jaist.dl.sourceforge.net/project/sshpass/sshpass/1.06/sshpass-1.06.tar.g######################################################################## 100.0%==> ./configure --prefix=/usr/local/Cellar/sshpass/1.06==> make install???? /usr/local/Cellar/sshpass/1.06: 9 files, 41.6KB, built in 33 seconds