Skip to content

Instantly share code, notes, and snippets.

@kingster
Last active August 29, 2015 14:07
Show Gist options
  • Save kingster/75832407bccc0e43d3b7 to your computer and use it in GitHub Desktop.
Save kingster/75832407bccc0e43d3b7 to your computer and use it in GitHub Desktop.
SSH Bulk Key Adder
#!/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