Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save goyuninfo/8f5e1567539c0d5bf1fae1733da34981 to your computer and use it in GitHub Desktop.
Save goyuninfo/8f5e1567539c0d5bf1fae1733da34981 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Set Security Group id. ID is better than name if not in default VPC
SG_ID="sg-goyun"
# Retrieve current IP address
IP=`curl -s http://checkip.amazonaws.com/`
# Authorize access on ports 22
aws ec2 authorize-security-group-ingress --group-id "$SG_ID" --protocol tcp --port 22 --cidr "$IP/32"
# To remove
$ aws ec2 revoke-security-group-ingress --group-id "$SG_ID" --protocol tcp --port 22 --cidr "$IP/32"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment