Created
July 5, 2016 17:51
-
-
Save kellan/59556b91f7ba348e391a882f4c0b613f to your computer and use it in GitHub Desktop.
ec2 ssh by instance id
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
function ec2-ssh () { | |
FOO=$(aws ec2 describe-instances --filter Name=instance-id,Values=$1 | jq '.Reservations[0].Instances[0].PublicIpAddress,.Reservations[0].Instances[0].\ | |
KeyName' | tr -d '"') | |
IPADDR=$(echo $FOO | cut -d" " -f1) | |
KEYNAME=$(echo $FOO | cut -d" " -f2) | |
ssh -i ~/.ssh/$KEYNAME.pem ec2-user@$IPADDR | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment