Skip to content

Instantly share code, notes, and snippets.

@tuvshuud
Created January 7, 2020 01:59
Show Gist options
  • Save tuvshuud/4c4dc9eb232f1a64fa56f40305232fdf to your computer and use it in GitHub Desktop.
Save tuvshuud/4c4dc9eb232f1a64fa56f40305232fdf to your computer and use it in GitHub Desktop.
AWS EC2 ssh without remembering their IP addresses
#! /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