Created
October 27, 2012 23:55
-
-
Save tokudu/3966918 to your computer and use it in GitHub Desktop.
A helper script for SSH'ing into EC2 instances by name
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 | |
# SSH into an EC2 instance by name | |
# Author: [email protected] (SoThree.com). | |
set -e | |
if [ $# -lt 1 ] | |
then | |
echo "Usage: `basename $0` instance_name" | |
exit 1 | |
fi | |
# get instance id | |
instance_name=$1 | |
# get the instance address so that we can SSH into it | |
echo "Obtaining the instance address..." | |
instance_address=`ec2-describe-instances --filter "tag:Name=${instance_name}" | grep INSTANCE | awk '{print $4}'` | |
echo "Done. Instance address: ${instance_address}" | |
ssh ${instance_address} |
Is this using an old version of the AWS console API? I working through a couple of small issues, one being that ec2-describe-instances
is now aws ec2 describe-instances
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Many thanks.