如何在 Mac 上安装 sshpass?

How to install sshpass on Mac?

我想从我的 Mac.

自动执行 ssh 登录

它确实有一个简单的解决方案:

sshpass -p my_password ssh m_username@hostname

但我的问题是在 Mac.

上安装 sshpass

这里有关于如何安装 sshpass 的说明:

https://gist.github.com/arunoda/7790979

对于 Mac,您需要安装 xcode 和命令行工具,然后使用非官方的 Homewbrew 命令:

curl -L https://raw.githubusercontent.com/kadwanev/bigboybrew/master/Library/Formula/sshpass.rb > sshpass.rb && brew install sshpass.rb && rm sshpass.rb

来自github的lukesUbuntu提供的解决方案对我有效:

只需使用 brew

$ brew install http://git.io/sshpass.rb

请按照以下步骤在 mac 中安装 sshpass

curl -O -L https://fossies.org/linux/privat/sshpass-1.06.tar.gz && tar xvzf sshpass-1.06.tar.gz

cd sshpass-1.06

./configure

sudo make install

原因很简单:

Andy-B-MacBook:~ l.admin$ brew install sshpass
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.

因此,在 Mac 上执行 curl/configure/install 的答案对我来说非常有用。

2022 年更新: 不幸的是,Aleks Hudochenkov 不再更新他的存储库。 a bunch of other repos on GitHub 声称包含 sshpass 的 Homebrew 配方。信任他们中的哪一个(如果有的话)取决于你。

几年过去了,现在有了合适的 Homebrew Tap for sshpass, maintained by Aleks Hudochenkov。要从此点击安装 sshpass,运行:

brew install hudochenkov/sshpass/sshpass

点击source

以下对我有用

curl -O -L  https://sourceforge.net/projects/sshpass/files/sshpass/1.06/sshpass-1.06.tar.gz && tar xvzf sshpass-1.06.tar.gz
cd sshpass-1.06/
./configure
sudo make install

2020 年的另一个选择是这个自制水龙头,由 esolitos

维护
brew install esolitos/ipa/sshpass

我只是按照 this article 的说明进行操作,这很有帮助,

curl -O -L http://downloads.sourceforge.net/project/sshpass/sshpass/1.05/sshpass-1.05.tar.gz && tar xvzf sshpass-1.05.tar.gz

//This creates a directory sshpass-1.05

cd sshpass-1.05
./configure
make
sudo make install

哎呀,过时链接的问题。 只需转到 https://sourceforge.net/projects/sshpass/ 下载最新版本,然后 tar xvzf 它,最后 cd to the dir where it got unpacked 并安装: ./configure make sudo make install 我想这也适用于安装了受支持的 C sdk 的每个 OS...

对之前的回答稍作更新

curl -O -L  https://fossies.org/linux/privat/sshpass-1.09.tar.gz && tar xvzf sshpass-1.09.tar.gz
cd sshpass-1.09/
./configure
sudo make install

这与 2021 年 10 月一样有效

我发现这里列出的大部分答案都已过时。要安装最新的,我 运行 这个并直接从 sourceforge.net 下载,基于这里的其他答案。

curl -L https://sourceforge.net/projects/sshpass/files/latest/download -o sshpass.tar.gz && tar xvzf sshpass.tar.gz
cd sshpass-*
./configure
sudo make install