我想要自动化从我的 Mac 登录 ssh。
这确实有一个简单的解决方案:
sshpass -p my_password ssh m_username@hostname
但我的问题是在我的Mac上安装sshpass。
2022年更新:很遗憾,Aleks Hudochenkov不再更新他的存储库。在GitHub上有许多其他存储库声称包含sshpass的Homebrew配方。你可以自行决定信任哪一个(如果有的话)。
几年过去了,现在有一个适用于sshpass
的合适Homebrew Tap,由Aleks Hudochenkov维护。要从此tap安装sshpass
,请运行:
brew install hudochenkov/sshpass/sshpass
点击源代码
sudo rm -rf /Library/Developer/CommandLineTools
和 sudo xcode-select --install
。 - ikreb这里有关于如何安装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
curl -L https://raw.githubusercontent.com/kadwanev/bigboybrew/master/Library/Formula/sshpass.rb > sshpass.rb && brew install sshpass.rb && rm sshpass.rb
- Konstantin Nikolskii2020 年的另一个选择是这个自制 tap,由 esolitos 维护
brew install esolitos/ipa/sshpass
以下方法适用于我
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
curl
命令中添加--insecure
选项。 - nezort11$ brew install http://git.io/sshpass.rb
Error: Non-checksummed download of sshpass formula file from an arbitrary URL is unsupported!
brew extractor
brew createand
brew tap-new to create a formula file in a tap on GitHub instead.
- rogerdpackcurl -L https://sourceforge.net/projects/sshpass/files/latest/download -o sshpass.tar.gz && tar xvzf sshpass.tar.gz
cd sshpass-*
./configure
sudo make install
configure: error: in /Users/ME/sshpass-1.08: configure: error: C compiler cannot create executables See config.log for more details
- Khom Nazid请按照以下步骤在 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
/linux/privat/sshpass-1.09.tar.gz
。 - Ambareesh为避免依赖于未知的Github仓库(直接或通过Homebrew taps),只需使用MacPorts即可 :)
只需安装MacPorts然后输入:
sudo port install sshpass
这个想法是通过MacPorts而不是Homebrew安装sshpass。
您可以在同一台机器上同时安装Homebrew和MacPorts,但要小心,因为有些软件包可在两个来源上获得,在这种情况下,您应该保持一致以避免冲突。
在这种情况下,通常我会优先考虑Homebrew,但是他们不提供sshpass,因为他们明确表示了这一点。
事实上,如果您键入:
brew install sshpass
We won't add sshpass because it makes it too easy for novice SSH users to ruin SSH's security.
如果你真的想使用sshpass,那么在这种情况下MacPorts是唯一的选择。
我刚刚按照这篇文章的说明进行操作,它对我很有帮助。
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
由于简单的原因:
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.
ssh-keygen -b 2048
,它将生成一对密钥并将它们存储在~/.ssh.
中,其中私钥称为id_rsa
,公钥称为id_rsa.pub
。将id_rsa.pub
复制到Linux的目录~/.ssh/
中,并将其命名为authorized_keys
。从现在开始,当您连接到Linux时,您将不需要密码,而是使用私钥/公钥对进行身份验证。 - alvitsid_rsa
文件,2)将id_rsa.pub
通过scp
复制到服务器的相应文件夹中,如建议所示,并3)在服务器上重命名id_ras.pub
文件。 - yuqli