Ansible OS X Mavericks You Must Install the sshpass Program

• Updated January 21, 2019

While bootstraping a new Rackspace Public Cloud Server with Ansible 1.4.4 on OS X Mavericks, I received an error when running ansible-playbook bootstrap.yml --user root --ask-pass.

The error encountered was:

[11:48:04][user@host][playbooks] ansible-playbook bootstrap.yml --user root --ask-pass
SSH password: 

PLAY [newservers] ************************************************************* 

GATHERING FACTS *************************************************************** 
fatal: [] => to use the 'ssh' connection type with passwords, you must install the sshpass program

Ansible uses sshpass when logging in to a server via SSH using a password. Apparently, Apple removed sshpass and merged its functionality into the ssh, scp, and ssh-add commands.

For security reasons, you should have Ansible logging in to servers using SSH keys, but for new servers it is simpler to initially log in with a password, have Ansible setup your users and SSH keys, then have subsequent logins use SSH keys.

To get past the sshpass error, you can install sshpass from source code with the following steps:

  1. Install Xcode from the App Store.

  2. Once Xcode is installed, download and install the Command Line Tools by opening Xcode > opening Xcode’s Preferences > clicking the Downloads tab > clicking Command Line Tools > and finally clicking the Install button.

  3. Once the Command Line Tools are installed, download and un-tar the sshpass source code:

     cd ~/Downloads
     curl -O -L
     tar xvzf sshpass-1.05.tar.gz
     cd sshpass-1.05
  4. Configure, make, and install the sshpass binary:

     sudo make install

Now, re-running ansible-playbook bootstrap.yml --user root --ask-pass will work without a problem.

The steps in this post are no longer necessary if you are running Ansible 1.9.2 or newer. This issue was probably fixed in a version prior to Ansible 1.9.2, but I don’t know which version.

If you found this post useful, you can help support this site and get something for yourself by signing up for any of the services listed below through the provided links.

The following links are part of affiliate programs, and I will receive a referral payment from any of the services you sign-up for.

  • Read Curated News: Tired of mainstream news? Are you looking for more curated business, finance, and economic news that does not read like it was written by a machine learning algorithm? Then start your day with the Morning Brew, a free email newsletter delivered to your inbox each morning.
  • Get Faster Shipping: Perhaps you're about to order some stuff on Amazon but want to get more value out of the money you would normally pay for shipping. Sign-up for a free, 30-day trial of Amazon Prime to get free two-day shipping, access to thousands of movies and TV shows, and more.
  • Start Investing Now: Are you looking to start investing some of your disposable saved income? Get started by opening an account with Webull, where upon sign-up and opening a brokerage account with an initial deposit of at least $100 you will receive 1 stock valued (subject to change based on normal market movement) between $8 and $1600.

Thanks for reading and take care.