ansible/copy-keys.sh
Yohaï-Eliel BERREBY 29991141f5 misc: add script to copy SSH keys
This one has the advantage of actually working :)
I had to blacklist some hosts because they would either outright refuse
connections or would refuse my LDAP credentials.
2020-05-03 11:26:53 +02:00

17 lines
421 B
Bash
Executable file

#!/bin/bash
set -e
# Grab valid unique hostnames from the Ansible inventory.
HOSTS=$(grep -ve '^[#\[]' hosts \
| grep -ve '^$' \
| grep -F adm.auro.re \
| grep -vf ssh-blacklist.txt \
| 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