Thursday, May 6, 2021

Install sshpass on MacOS

 If you are using Ansible, and connecting to hosts via password and not ssh keys you'll need the sshpass program to run playbooks or you may see an error similar to this:

TASK [Gathering Facts] ************************************************************************************
fatal: [host01]: FAILED! => {"msg": "to use the 'ssh' connection type with passwords, you must install the sshpass program"}

To get around this, you can install it with brew. From stackoverflow this one liner worked to install it.

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

You can also download the tar file from sourceforge and build it locally:

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

Hope this helps. Please comment if you have found a better way, Thanks!