AWS Notes - SS67/project-docs GitHub Wiki

labex:project/ $ cat ssh_config Host *

  IdentityFile /home/labex/project/report-key
  IdentitiesOnly yes
  UserKnownHostsFile /home/labex/project/known_hosts
  StrictHostKeyChecking accept-new
  ConnectTimeout 5
  ProxyCommand nc -X 5 -x 127.0.0.1:1080 %h %p
 ssh -F ssh_config ubuntu@"$PUBLIC_IP" cat /home/ubuntu/portfolio/profile.json

aws ec2 describe-security-groups --group-ids "$SECURITY_GROUP_ID" --query 'SecurityGroups[0].IpPermissions'

  {
        "IpProtocol": "tcp",
        "FromPort": 22,
        "ToPort": 22,
        "UserIdGroupPairs": [],
        "IpRanges": [
            {
                "CidrIp": "198.51.100.10/32"
            }
        ],
        "Ipv6Ranges": [],
        "PrefixListIds": []
    },
    {
        "IpProtocol": "tcp",
        "FromPort": 8081,
        "ToPort": 8081,
        "UserIdGroupPairs": [],
        "IpRanges": [
            {
                "CidrIp": "198.51.100.10/32"
            }
        ],
        "Ipv6Ranges": [],
        "PrefixListIds": []
    }
 ]

The output lists only inbound rules. FromPort and ToPort mark the port range. You should find separate rules for 22 and 8081. Their source, 198.51.100.10/32, represents one prepared website visitor in this exercise; /32 means one IPv4 address. It is not your computer’s public address, so keep the supplied value.

Remove only the website permission. revoke-security-group-ingress removes a matching inbound rule; --protocol tcp selects its protocol, --port 8081 selects the website service and --cidr selects the allowed source:

aws ec2 revoke-security-group-ingress \

  --group-id "$SECURITY_GROUP_ID" \
  --protocol tcp \
  --port 8081 \
  --cidr 198.51.100.10/32
⚠️ **GitHub.com Fallback** ⚠️