Last active
August 29, 2015 14:07
-
-
Save kingster/75832407bccc0e43d3b7 to your computer and use it in GitHub Desktop.
SSH Bulk Key Adder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ $# -eq 0 ];then | |
echo "$0 host-prefix{1..5}-postfix.domain.com" | |
exit 1; | |
fi; | |
echo "User : `whoami`" | |
echo -n "LDAP password: " | |
read -s password; | |
printf "\nStarting....\n" | |
hosts="$1"; | |
# echo "$hosts" | |
whost=`echo "$hosts" | sed 's/{.*}/@@/'` | |
# echo "$whost" | |
series=`echo "$hosts" | egrep -o '{.*}'` | |
# echo "$series" | |
for i in $(eval echo "$series"); do | |
host=`echo "$whost" | sed "s/@@/$i/"` | |
echo "Attempting for $host ....." | |
sshpass -p "$password" ssh-copy-id -o StrictHostKeyChecking=no $host | |
done; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment