本地编译安装

下载源码包到本地

1
wget https://nchc.dl.sourceforge.net/project/sshpass/sshpass/1.08/sshpass-1.08.tar.gz

解压并切换到安装包目录

1
2
tar xzvf sshpass-1.08.tar.gz
cd sshpass-1.08

编译并编译安装

1
2
3
4
./configure
echo $?
sudo make&&sudo make install
echo $?

检查是否安装成功

1
2
3
4
5
6
7
8
9
10
11
12
13
sshpass
Usage: sshpass [-f|-d|-p|-e] [-hV] command parameters
-f filename Take password to use from file
-d number Use number as file descriptor for getting password
-p password Provide password as argument (security unwise)
-e Password is passed as env-var "SSHPASS"
With no parameters - password will be taken from stdin

-P prompt Which string should sshpass search for to detect a password prompt
-v Be verbose about what you're doing
-h Show help (this screen)
-V Print version information
At most one of -f, -d, -p or -e should be used

在线安装

1
brew install sshpass

macOS新版本中由于安全原因无法直接使用此方法安装,需要采用其它安全的办法绕过。

1
brew install https://raw.githubusercontent.com/kadwanev/bigboybrew/master/Library/Formula/sshpass.rb

由于你懂的原因,我两种方式都安装失败了,所以推荐下载到本地的安装方式

1
2
3
4
5
6
▶ brew install sshpass
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
Error: No available formula or cask with the name "sshpass".
We won't add sshpass because it makes it too easy for novice SSH users to
ruin SSH's security.
1
2
3
4
▶ brew install https://raw.githubusercontent.com/kadwanev/bigboybrew/master/Library/Formula/sshpass.rb
Traceback (most recent call last):
`brew extract` or `brew create` and `brew tap-new` to create a formula file in a tap on GitHub instead.: Invalid usage: Non-checksummed download of sshpass formula file from an arbitrary URL is unsupported! (UsageError)
`brew extract` or `brew create` and `brew tap-new` to create a formula file in a tap on GitHub instead.: Invalid usage: Non-checksummed download of sshpass formula file from an arbitrary URL is unsupported! (UsageError)