-
-
Save yureative/8a3f58369e2a253efe6f to your computer and use it in GitHub Desktop.
SSH login to EC2 instances by Name Tag
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 | |
if [ $# -lt 1 ] | |
then | |
echo 'Usage: c INSTANCE_NAME [REMOTE_COMMANDS...]' | |
exit 1 | |
fi | |
pdns=`aws ec2 describe-instances --filters "Name=tag:Name,Values=$1" | jq -r '.Reservations[].Instances[].PrivateDnsName'` | |
shift | |
ssh ec2-user@$pdns $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You first need to configure AWS region and credentials with
aws configure
.