MacOS Mojave 安装sshpass
2024-09-05 19:15:17
使用sshpass的场景
在MacOS下使用ansible命令(inventory文件中使用了密码验证的方式)或者使用iTerm2来完成自动密码填充等场景会使用到sshpass。
比如下面的样例:Inventory文件中使用了ansible_ssh_pass
选项
stephens-New-MacBook-Pro:ansible stephen$ cat test.hosts
10.10.66.66 ansible_port=22 ansible_user=root ansible_ssh_pass=test666
stephens-New-MacBook-Pro:ansible stephen$
使用ansible命令会失败,提示缺少sshpass
。
stephens-New-MacBook-Pro:ansible stephen$ ansible all -i test.hosts -m ping
10.10.66.66 | FAILED! => {
"failed": true,
"msg": "to use the 'ssh' connection type with passwords, you must install the sshpass program"
}
stephens-New-MacBook-Pro:ansible stephen$
安装sshpass及各种常见小问题处理
直接brew install
会提示不安全,被拒绝,brew install --force
强制安装也不行
stephens-New-MacBook-Pro:ansible stephen$ 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.
stephens-New-MacBook-Pro:ansible stephen$
可以通过下面的命令进行安装
brew install https://raw.githubusercontent.com/kadwanev/bigboybrew/master/Library/Formula/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"
end
end
如果(因为众所周知的网络原因)通过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
进行安装
stephens-New-MacBook-Pro:ansible stephen$ brew install sshpass.rb
Error: Xcode alone is not sufficient on Mojave.
Install the Command Line Tools:
xcode-select --install
stephens-New-MacBook-Pro:ansible stephen$ xcode-select --install
xcode-select: note: install requested for command line developer tools
stephens-New-MacBook-Pro:ansible stephen$
安装完xcode-select
之后重新执行brew install
命令,sshpass
安装成功。
stephens-New-MacBook-Pro:ansible stephen$ brew install sshpass.rb
Updating 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
最新文章
- 学习shell中遇到的一些基础问题总结
- C#函数式程序设计之用闭包封装数据
- Bulk Insert &; BCP执行效率对比
- 实用项目管理前台框架:EasyUI,ExtJs
- jQuery 源码解析二:jQuery.fn.extend=jQuery.extend 方法探究
- 搜索引擎爬虫蜘蛛的USERAGENT大全
- MD5处理图片加密算法
- tp框架知识 之(链接数据库和操作数据)
- H5 表单元素
- HighCharts之2D对数饼图
- Ext.grid.panel 改变某一行的字体颜色
- [JLOI2015]骗我呢
- Silverlight中使用MVVM(1)--基础
- k8s 隔离context+namespace
- [整理]CSS3 滤镜
- [USACO14MAR]破坏Sabotage
- Delphi实例分析:远程传输数据和文件
- vue-compile概述
- 【转】Android:No implementation found for native
- Linux对包管理阐述
热门文章
- iptables添加、删除端口
- leetcode 27. 移除元素(python)
- seleniumIDE回放找不到页面元素
- Html/CSS 初步介绍html和css部分重要标签
- C# Setting.settings . 用法 2 使用配置文件(.settings、.config)存储应用程序配置
- c++ 加载资源文件
- Servlet 响应 响应相关与重定向 请求 获取表单数据2种方法
- 可持久化并查集 by zky
- 【DSP开发】【Linux开发】基于ARM+DSP进行应用开发
- Linux 项目上线流程