ThorneLabs

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: [127.0.0.1] => 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 http://downloads.sourceforge.net/project/sshpass/sshpass/1.05/sshpass-1.05.tar.gz
    
     tar xvzf sshpass-1.05.tar.gz
    
     cd sshpass-1.05
    
  4. Configure, make, and install the sshpass binary:

     ./configure
    
     make
    
     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 and would like to help support this site - and get something for yourself - sign up for any of the services listed below through the provided affiliate links. I will receive a referral payment from any of the services you sign-up for.

Get faster shipping and more with Amazon Prime: About to order something from 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.

Thanks for reading and take care.