Using Console
Using CLI
<security-group-id>
with the Group ID of the security group that allows unrestricted SSH access.<security-group-id>
with the Group ID of the security group that allows unrestricted SSH access.Using Python
boto3
library to interact with AWS services.boto3.client()
.describe_security_groups()
method to retrieve all the security groups in your AWS account.0.0.0.0/0
).revoke_security_group_ingress()
method to remove the rule allowing SSH access from any IP address.