Skip to content

Instantly share code, notes, and snippets.

@indiejoseph
Created August 19, 2021 03:15
Show Gist options
  • Save indiejoseph/e96c3cce39ac1ef7b0c8002d96a49b40 to your computer and use it in GitHub Desktop.
Save indiejoseph/e96c3cce39ac1ef7b0c8002d96a49b40 to your computer and use it in GitHub Desktop.
auto whitelist local ip into AWS security group
#!/bin/bash
# script to pull my current public IP address
# and add a rule to my EC2 security group allowing me SSH access
curl v4.ifconfig.co/ip > ip.txt
awk '{ print $0 "/32" }' < ip.txt > ipnew.txt
export stuff=$(cat ipnew.txt)
aws ec2 authorize-security-group-ingress --group-name NewGroup \
--protocol tcp --port 22 --cidr $stuff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment