Last active
September 30, 2020 23:17
-
-
Save goyuninfo/8f5e1567539c0d5bf1fae1733da34981 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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