Each EC2 instance is protected by its own virtual firewall known as security groups. This acts like a typical firewall and manages access to the EC2 instance by controlling inbound and outbound traffic. While setting up an EC2 instance, we can add rules to allow or deny traffic to the associated EC2 instance. EC2 instances can also be grouped into a security group, which is useful when one firewall rule needs to be applied to multiple EC2 instances. Once the rules have been modified, changes take effect immediately.
EC2 instances that run Linux AMI images have the SSH port allowed by default for remote access. In the case of Windows machines, RDP is allowed by default:
As we can see, since our AMI is an Ubuntu Linux image, that AWS has automatically configured the network rules to allow SSH (port 22) only. Let's add a few more network rules...