#!/bin/bash set -e # Grab valid unique hostnames from the Ansible inventory. HOSTS=$(grep -ve '^[#\[]' hosts \ | grep -F adm.auro.re \ | sort -u) for host in $HOSTS; do echo "Handling host $host" # sshpass can be used for non-interactive password authentication. # place your password in ldap-password.txt. sshpass -f ldap-password.txt ssh-copy-id "$host" done