Last active
July 22, 2016 20:22
-
-
Save scumola/a3fec67d1e0813b258fd1f9f1614db14 to your computer and use it in GitHub Desktop.
csshx-beanstalk.bash
This file contains hidden or 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 [ "$#" -ne 1 ]; | |
then echo "USAGE: $0 <EB Environment Name>" | |
exit | |
fi | |
rm /tmp/csshx-hosts.txt &> /dev/null | |
for id in `/usr/local/bin/aws elasticbeanstalk describe-environment-resources --output text --environment-name $1 | grep INSTANCES | awk '{print $2}'` ; | |
do | |
ids+=$(echo $id|tr '\n' ' ') | |
done | |
echo $ids | |
/usr/local/bin/aws ec2 describe-instances --output text --instance-ids $ids --query "Reservations[*].Instances[*].PublicIpAddress" >> /tmp/csshx-hosts.txt | |
tr '\t' ' ' < /tmp/csshx-hosts.txt | tr ' ' '\n' | sed '/^\s*$/d' | sort -n > /tmp/csshx-hosts2.txt ; mv /tmp/csshx-hosts2.txt /tmp/csshx-hosts.txt | |
csshX --ssh_args "-i /Users/stevenwebb/keys/mykey.priv -o IdentitiesOnly=yes -F /dev/null" -l ec2-user --hosts /tmp/csshx-hosts.txt | |
rm /tmp/csshx-hosts.txt &> /dev/null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment