Skip to content

Instantly share code, notes, and snippets.

@mageddo
Created June 3, 2018 00:25
Show Gist options
  • Select an option

  • Save mageddo/94ffce410f600d117aee79b4bc2f4c36 to your computer and use it in GitHub Desktop.

Select an option

Save mageddo/94ffce410f600d117aee79b4bc2f4c36 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
PUBLIC_KEY='tacape.mageddo.com.pub'
for i in $(cat /tmp/servers.txt); do
sudo cp "$HOME/.ssh/$PUBLIC_KEY" /tmp
echo "Installing ssh key in server: $i"
# rsync -ave ssh "~/.ssh/$PUBLIC_KEY" "root@$i:~/.ssh/"
sudo scp "/tmp/$PUBLIC_KEY" "root@$i:~/.ssh/"
echo "Trusting installed certificated"
ssh "root@$i" "cat ~/.ssh/$PUBLIC_KEY >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/*"
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment