Skip to content

Instantly share code, notes, and snippets.

View socratesx's full-sized avatar

Socrates Chouridis socratesx

View GitHub Profile
@socratesx
socratesx / add_pub_ip_to_sg.sh
Created June 20, 2019 14:31
Add your current public IP Address to AWS security group, replacing your old one. This is useful for admins on the go that have very strict SGs and need a temporary access to EC2 resources
#!/bin/bash
# The script requires the following permissions:
# ec2:RevokeSecurityGroupIngress
# ec2:AuthorizeSecurityGroupIngress
# ec2:DescribeSecurityGroups
# Of coure the user must have access to the security group that wants to add/remove rules
#Get The current public ip to be added
current_pub_ip="$(curl -s https://ipinfo.io/ip)/32"
@socratesx
socratesx / remove_pub_ip_from_sg.sh
Created June 20, 2019 14:45
Revoke Access from a specific temporary rule of a security group.
#!/bin/bash
#The script requires the following permissions:
# ec2:RevokeSecurityGroupIngress
# ec2:DescribeSecurityGroups
# Of coure the user must have access to the security group that wants to add/remove rules
group_id="The Group you need to edit (sg-xxxx)"
# The following description will be searched and return the ip rule that is associated with it.