News for hackers. Stuff that matters.
Re:Ask HN: How can I secure my AWS instance's SSH access if ... by mhio on Friday February 18, 2022 @04:35AM (#30383795)
ip=$(curl https://api.ipify.org)

tag_name="tmpip"

tag_time=$(date -u '+%Y-%m-%dT%H:%M:%SZ')

aws ec2 authorize-security-group-ingress --group-id sg-86169665d2453e4 --protocol tcp --port 22 --cidr "$ip/32" --tag-specifications "ResourceType=security-group-rule,Tags=[{Key=Name,Value=${tag_name}},{Key=added,Value=${tag_time}}]"

The tag enables replacing the existing rule via tag Name, the further you go the easier it is to use the API SDKs

Re:Ask HN: How can I secure my AWS instance's SSH access if ... by gkrishna on Friday February 18, 2022 @10:17AM (#30386780)
This is really a creative solution with no extra costs!