MacOS安装sshpass

本文介绍了如何在Mac上安装sshpass工具的过程。由于Homebrew中未包含sshpass,因此通过安装Homebrew开始,并尝试从Homebrew安装但未成功。最终采用源码方式成功安装了sshpass。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

最先想到的是使用brew安装sshpass命令;

奈何Mac上没有brew命令,首先安装Homebrew包:

参考:https://www.cnblogs.com/yaogengzhu/p/10833285.html 

➜ % /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
==> Downloading and installing Homebrew...
remote: Enumerating objects: 192884, done.
remote: Counting objects: 100% (2221/2221), done.
remote: Compressing objects: 100% (1120/1120), done.
remote: Total 192884 (delta 1253), reused 1918 (delta 1017), pack-reused 190663
Receiving objects: 100% (192884/192884), 52.91 MiB | 1.60 MiB/s, done.
Resolving deltas: 100% (142592/142592), done.
From https://github.com/Homebrew/brew
HEAD is now at f9cedd1fa Merge pull request #12102 from Homebrew/dependabot/bundler/Library/Homebrew/sorbet-0.5.9152
==> Tapping homebrew/core
remote: Enumerating objects: 1044853, done.
remote: Counting objects: 100% (75/75), done.
remote: Compressing objects: 100% (49/49), done.
remote: Total 1044853 (delta 41), reused 56 (delta 26), pack-reused 1044778
Receiving objects: 100% (1044853/1044853), 393.34 MiB | 1.59 MiB/s, done.
Resolving deltas: 100% (717292/717292), done.
From https://github.com/Homebrew/homebrew-core
 * [new branch]            master     -> origin/master
Updating files: 100% (6138/6138), done.
HEAD is now at 6400b5b862 appium: update 1.22.0 bottle.
==> Installation successful!

==> Homebrew has enabled anonymous aggregate formulae and cask analytics.
Read the analytics documentation (and how to opt-out) here:
  https://docs.brew.sh/Analytics
No analytics data has been sent yet (or will be during this `install` run).

==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
  https://github.com/Homebrew/brew#donations

==> Next steps:
- Run `brew help` to get started
- Further documentation:
    https://docs.brew.sh

brew安装成功后,使用brew安装sshpass提示无法安装;

➜ % brew install sshpass
Updating Homebrew...
==> Tapping homebrew/cask
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask'...
remote: Enumerating objects: 593301, done.
remote: Counting objects: 100% (24/24), done.
remote: Compressing objects: 100% (18/18), done.
remote: Total 593301 (delta 10), reused 15 (delta 6), pack-reused 593277
Receiving objects: 100% (593301/593301), 263.81 MiB | 1.36 MiB/s, done.
Resolving deltas: 100% (419270/419270), done.
Updating files: 100% (4003/4003), done.
Tapped 3934 casks (4,014 files, 282.8MB).
Warning: No available formula or cask with the name "sshpass". Did you mean sshfs?
==> Searching for similarly named formulae...
This similarly named formula was found:
sshfs
To install it, run:
  brew install sshfs
We won't add sshpass because it makes it too easy for novice SSH users to ruin SSH's security.

最后使用源码包进行安装:

下载sshpass-1.08.tar.gz : https://sourceforge.net/projects/sshpass/

➜  Downloads % tar zxvf sshpass-1.08.tar.gz
➜  Downloads % cd sshpass-1.08
➜  sshpass-1.08 % ./configure
➜  sshpass-1.08 make
/Library/Developer/CommandLineTools/usr/bin/make  all-am
gcc -DHAVE_CONFIG_H -I.     -g -O2 -MT main.o -MD -MP -MF .deps/main.Tpo -c -o main.o main.c
mv -f .deps/main.Tpo .deps/main.Po
gcc  -g -O2   -o sshpass main.o
➜  sshpass-1.08 make install
 ./install-sh -c -d '/usr/local/bin'
  /usr/bin/install -c sshpass '/usr/local/bin'
 ./install-sh -c -d '/usr/local/share/man/man1'
 /usr/bin/install -c -m 644 sshpass.1 '/usr/local/share/man/man1'

验证下已经安装成功:

➜  sshpass-1.08 sshpass -V
sshpass 1.08
(C) 2006-2011 Lingnu Open Source Consulting Ltd.
(C) 2015-2016, 2021 Shachar Shemesh
This program is free software, and can be distributed under the terms of the GPL
See the COPYING file for more information.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值