Created
January 7, 2020 01:59
-
-
Save tuvshuud/4c4dc9eb232f1a64fa56f40305232fdf to your computer and use it in GitHub Desktop.
AWS EC2 ssh without remembering their IP addresses
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/sh | |
INPUT=$1 | |
USER=$(cut -d'@' -f1 <<< $INPUT) | |
INSTANCE=$(cut -d'@' -f2 <<< $INPUT) | |
ADDR=$(aws ec2 describe-instances --filters "Name=tag:Name,Values=$INSTANCE" --query 'Reservations[*].Instances[*].PublicIpAddress' --output text --profile sys-admin) | |
ssh -i $2 $USER@$ADDR |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment