Installing sshpass On OSX Mavericks

When setting up a server for the first time with Ansible you will need to pass ssh credentials to Ansible directly to set up ssh keys. This is done by the use of the sshpass program which allows Ansible to pass your user credentials directly to ssh in order to open a connection to the server. The sshpass program is easily installed on Linux systems with the apt or yum package managers, but on OSX you will need to install it manually.

In order to install command line software on OSX you will need some of the command line tools bundled with Xcode. Xcode and the command line tools are free programs from Apple and is available on the Appstore. Once Xcode is installed you will need to open it and install the command line tools. You can do this by going to Preferences > Downloads > Command Line Tools and clicking on the Install button. Once everything is installed and setup you can continue with the installation of sshpass.

The sshpass program is an open source project, currently available on sourceforge. You can either download the latest version manually and or you can use the following command will download the sshpass tar from sourceforge, and unzip it.

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 will create a directory called 'sshpass-1.05', open this directory in your terminal and run the following commands. This will configure, compile and install the sshpass program.

./configure
make
sudo make install

Once complete you can run sshpass with the -V flag to see if the install has taken and also to view the current version installed.

$ sshpass -V
sshpass 1.05 (C) 2006-2011 Lingnu Open Source Consulting Ltd.
This program is free software, and can be distributed under the terms of the GPL
See the COPYING file for more information.

I should note that it is poor security practice to rely on the sshpass to interface with servers, even through Ansible. This is because you will be placing ssh credentials into the command line or even within your codebase.

Comments

Haha, I just tried to install it via Homebrew:$ brew search sshpass We won't add sshpass because it makes it too easy for novice SSH users to ruin SSH's security.
Permalink
you can do
brew install https://raw.github.com/eugeneoden/homebrew/eca9de1/Library/Formula/sshpass.rb
Permalink
Hi Phil, Thanks for putting this together! I'm provisioning a lot of new servers and I've got to log into 1000+ servers and this will do the trick for my scripts. I had hoped for a DMG but this was just as simple - Thanks for putting this post together! Much appreciated, Jay
Permalink
Thanks!
Permalink
$ brew install https://raw.github.com/eugeneoden/homebrew/eca9de1/Library/Formula/sshpass.rb ######################################################################## 100.0% ==> Downloading http://sourceforge.net/projects/sshpass/files/sshpass/1.05/sshpass-1.05.tar.gz ######################################################################## 100.0% Error: MD5 support has been dropped for security reasons. Please switch this formula to SHA256.
Permalink
Same error
Permalink
How did you solve it?
Name
Philip Norton
Permalink
On Yoshemite$ brew install https://raw.githubusercontent.com/kadwanev/bigboybrew/master/Library/Formula/sshpass.rb ######################################################################## 100.0% ==> Downloading http://sourceforge.net/projects/sshpass/files/sshpass/1.05/sshpass-1.05.tar.gz Already downloaded: /Library/Caches/Homebrew/sshpass-1.05.tar.gz Error: SHA256 mismatch Expected: c3f78752a68a0c3f62efb3332cceea0c8a1f04f7cf6b46e00ec0c3000bc8483e Actual: 96ca20a16a86083b1eb666fecbfa5b3f9eb7317ec9e6fcfcae5a91d96777b767 Archive: /Library/Caches/Homebrew/sshpass-1.05.tar.gz To retry an incomplete download, remove the file above.
Permalink
It works, thanks
Permalink
Hi, i have upgraded the Mac to 10.11. When i try to install the sshpass using above commands, i get the following message after the make install command. I see that sshpass is not installed. Any idea what is missing on new Mac ? Please note that I have installed the x-code command line tools. /usr/bin/install -c -m 644 sshpass.1 '/usr/local/share/man/man1'ocal/share/man/man1"
Permalink
Thanks for article, this is work's for me.
Permalink

Add new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
12 + 8 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.