Skip to content

Instantly share code, notes, and snippets.

@VildMedPap
Created May 21, 2021 13:58
Show Gist options
  • Save VildMedPap/56e13b8f7503e656a439bbdfb220cd53 to your computer and use it in GitHub Desktop.
Save VildMedPap/56e13b8f7503e656a439bbdfb220cd53 to your computer and use it in GitHub Desktop.
AWS: Whitelist current IP address on desired ec2 and the port of your choice
INSTANCE_ID="i-xxx"
PORT=22
SG_ID=`aws ec2 describe-instance-attribute --instance-id $INSTANCE_ID --attribute groupSet | python -c "import sys, json; print(json.load(sys.stdin)['Groups'][0]['GroupId'])"`
CURRENT_IP=`curl -s http://whatismyip.akamai.com/`
aws ec2 authorize-security-group-ingress --group-id $SG_ID --protocol tcp --port $PORT --cidr $CURRENT_IP/32
@VildMedPap
Copy link
Author

You need to have a set of credentials in the .aws directory as well as python installed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment