Skip to content

Instantly share code, notes, and snippets.

@mrmichalis
Last active December 15, 2015 00:19
Show Gist options
  • Save mrmichalis/5172546 to your computer and use it in GitHub Desktop.
Save mrmichalis/5172546 to your computer and use it in GitHub Desktop.
for IP in 201 202 247; do ssh root@$IP 'sh -s' < getip.sh >> /etc/hosts; done
#!/usr/bin/env bash
if [ $# -lt 1 ]; then
echo "usage: $0 [hosts list]" 1>&2
exit 1
fi
HOSTSLIST=$1
IPADDR=$(ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}')
if [ -a $HOSTSLIST ]; then
for IP in $(cat $HOSTSLIST | grep -v $IPADDR)); do ssh root@$IP "grep 192.168.1. /etc/hosts" >> /etc/hosts; done
for IP in $(cat $HOSTSLIST | grep -v $IPADDR); do scp /etc/hosts root@$IP:/etc/hosts; done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment